Commit 1e7dd760881e03ef91bf3bd565f2874344c44fbb

Authored by MoisesMachado
1 parent 69526673

ActionItem243: added test to specify how the search inside a category should function for profiles


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1601 3f533792-8f58-4932-b0fe-aaf55b0a4547
test/functional/category_controller_test.rb
... ... @@ -50,4 +50,9 @@ class CategoryControllerTest < Test::Unit::TestCase
50 50 assert_same most_commented, assigns(:most_commented_articles)
51 51 end
52 52  
  53 + should 'display category of products' do
  54 + cat = ProductCategory.create!(:name => 'Food', :environment => Environment.default)
  55 + get :view, :category_path => cat.path.split('/')
  56 + end
  57 +
53 58 end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -73,4 +73,13 @@ class ProfileEditorControllerTest < Test::Unit::TestCase
73 73 get :index, :profile => 'test_user'
74 74 end
75 75  
  76 + should 'display categories to choose to associate profile' do
  77 + cat = Environment.default.categories.build(:name => 'a category'); cat.save!
  78 + person = create_user('test_user').person
  79 + get :edit, :profile => 'test_user'
  80 + assert_tag :tag => 'input', :attributes => {:name => 'profile[category_ids][]'}
  81 + end
  82 +
  83 + should 'save categorization of profile'
  84 +
76 85 end
... ...
test/functional/search_controller_test.rb
... ... @@ -61,6 +61,9 @@ class SearchControllerTest < Test::Unit::TestCase
61 61 assert_includes assigns(:results)[:articles], art1
62 62 assert_not_includes assigns(:results)[:articles], art2
63 63 end
  64 +
  65 + # 'assets' menu
  66 + should 'list articles in a specific category'
64 67  
65 68 should 'search in comments' do
66 69 person = create_user('teste').person
... ... @@ -71,7 +74,25 @@ class SearchControllerTest < Test::Unit::TestCase
71 74 assert_includes assigns(:results)[:comments], comment
72 75 end
73 76  
74   - should 'search in comments in a specific category'
  77 + should 'search in comments in a specific category' do
  78 + person = create_user('teste').person
  79 + category = Category.create!(:name => 'my category', :environment => Environment.default)
  80 +
  81 + # in category
  82 + art1 = person.articles.build(:name => 'an article to be found')
  83 + art1.categories << category
  84 + art1.save!
  85 + comment1 = art1.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment1.save!
  86 +
  87 + # not in category
  88 + art2 = person.articles.build(:name => 'another article to be found')
  89 + art2.save!
  90 + comment2 = art2.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment2.save!
  91 + get 'filter', :category_path => ['my-category'], :query => 'found', :find_in => [ 'comments' ]
  92 +
  93 + assert_includes assigns(:results)[:comments], comment1
  94 + assert_not_includes assigns(:results)[:comments], comment2
  95 + end
75 96  
76 97  
77 98 should 'find in environment' do
... ... @@ -88,15 +109,44 @@ class SearchControllerTest &lt; Test::Unit::TestCase
88 109 assert_same articles, finder.articles
89 110 end
90 111  
91   - should 'find people'
92   - should 'find communities'
93   -
94 112 should 'find enterprises' do
95 113 ent = Enterprise.create!(:name => 'teste', :identifier => 'teste')
96 114 get 'index', :query => 'teste'
97 115 assert_includes assigns(:results)[:enterprises], ent
98 116 end
  117 +
  118 + should 'find enterprises in a specified category' do
  119 + category = Category.create!(:name => 'my category', :environment => Environment.default)
  120 +
  121 + # in category
  122 + ent1 = Enterprise.create!(:name => 'test enterprise 1', :identifier => 'test1', :categories => [category])
  123 +
  124 + # not in category
  125 + ent2 = Enterprise.create!(:name => 'test enterprise 2', :identifier => 'test1')
  126 +
  127 + get :filter, :category_path => [ 'my-category' ], :query => 'test', :find_in => [ 'enterprises' ]
  128 +
  129 + assert_includes ent1, assigns(:results)[:enterprises]
  130 + assert_not_includes ent2, assigns(:results)[:enterprises]
  131 + end
  132 +
  133 + # 'assets' menu
  134 + should 'list enterprises in a specified category'
  135 +
  136 + should 'find people'
  137 + should 'find people in a specific category'
  138 +
  139 + # 'assets' menu
  140 + should 'list people in a specified category'
  141 +
  142 + should 'find communities'
  143 + should 'find communities in a specified category'
  144 + # 'assets' menu
  145 + should 'list communities in a specified category'
99 146  
100 147 should 'find products'
  148 + should 'find products in a specific category'
  149 + # 'assets' menu
  150 + should 'list products in a specific category'
101 151  
102 152 end
... ...
test/unit/category_test.rb
... ... @@ -229,7 +229,6 @@ class CategoryTest &lt; Test::Unit::TestCase
229 229 assert_equivalent [a1, a2], c.recent_articles
230 230 end
231 231  
232   -
233 232 should 'list recent comments' do
234 233 c = @env.categories.build(:name => 'my category'); c.save!
235 234 person = create_user('testuser').person
... ... @@ -261,9 +260,7 @@ class CategoryTest &lt; Test::Unit::TestCase
261 260 10.times { a3.comments.build(:title => 'test', :body => 'kajsdsa', :author => person).save! }
262 261  
263 262 assert_equal [a3, a2], c.most_commented_articles(2)
264   -
265 263 end
266   -
267 264 should 'have comments' do
268 265 c = @env.categories.build(:name => 'my category'); c.save!
269 266 person = create_user('testuser').person
... ...