diff --git a/test/functional/category_controller_test.rb b/test/functional/category_controller_test.rb index fae659b..955b19d 100644 --- a/test/functional/category_controller_test.rb +++ b/test/functional/category_controller_test.rb @@ -50,4 +50,9 @@ class CategoryControllerTest < Test::Unit::TestCase assert_same most_commented, assigns(:most_commented_articles) end + should 'display category of products' do + cat = ProductCategory.create!(:name => 'Food', :environment => Environment.default) + get :view, :category_path => cat.path.split('/') + end + end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 03b34b6..629b3c8 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -73,4 +73,13 @@ class ProfileEditorControllerTest < Test::Unit::TestCase get :index, :profile => 'test_user' end + should 'display categories to choose to associate profile' do + cat = Environment.default.categories.build(:name => 'a category'); cat.save! + person = create_user('test_user').person + get :edit, :profile => 'test_user' + assert_tag :tag => 'input', :attributes => {:name => 'profile[category_ids][]'} + end + + should 'save categorization of profile' + end diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index cda0bc3..8ffc3e7 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -61,6 +61,9 @@ class SearchControllerTest < Test::Unit::TestCase assert_includes assigns(:results)[:articles], art1 assert_not_includes assigns(:results)[:articles], art2 end + + # 'assets' menu + should 'list articles in a specific category' should 'search in comments' do person = create_user('teste').person @@ -71,7 +74,25 @@ class SearchControllerTest < Test::Unit::TestCase assert_includes assigns(:results)[:comments], comment end - should 'search in comments in a specific category' + should 'search in comments in a specific category' do + person = create_user('teste').person + category = Category.create!(:name => 'my category', :environment => Environment.default) + + # in category + art1 = person.articles.build(:name => 'an article to be found') + art1.categories << category + art1.save! + comment1 = art1.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment1.save! + + # not in category + art2 = person.articles.build(:name => 'another article to be found') + art2.save! + comment2 = art2.comments.build(:title => 'comment to be found', :body => 'hfyfyh', :author => person); comment2.save! + get 'filter', :category_path => ['my-category'], :query => 'found', :find_in => [ 'comments' ] + + assert_includes assigns(:results)[:comments], comment1 + assert_not_includes assigns(:results)[:comments], comment2 + end should 'find in environment' do @@ -88,15 +109,44 @@ class SearchControllerTest < Test::Unit::TestCase assert_same articles, finder.articles end - should 'find people' - should 'find communities' - should 'find enterprises' do ent = Enterprise.create!(:name => 'teste', :identifier => 'teste') get 'index', :query => 'teste' assert_includes assigns(:results)[:enterprises], ent end + + should 'find enterprises in a specified category' do + category = Category.create!(:name => 'my category', :environment => Environment.default) + + # in category + ent1 = Enterprise.create!(:name => 'test enterprise 1', :identifier => 'test1', :categories => [category]) + + # not in category + ent2 = Enterprise.create!(:name => 'test enterprise 2', :identifier => 'test1') + + get :filter, :category_path => [ 'my-category' ], :query => 'test', :find_in => [ 'enterprises' ] + + assert_includes ent1, assigns(:results)[:enterprises] + assert_not_includes ent2, assigns(:results)[:enterprises] + end + + # 'assets' menu + should 'list enterprises in a specified category' + + should 'find people' + should 'find people in a specific category' + + # 'assets' menu + should 'list people in a specified category' + + should 'find communities' + should 'find communities in a specified category' + # 'assets' menu + should 'list communities in a specified category' should 'find products' + should 'find products in a specific category' + # 'assets' menu + should 'list products in a specific category' end diff --git a/test/unit/category_test.rb b/test/unit/category_test.rb index 4612b45..3954b2e 100644 --- a/test/unit/category_test.rb +++ b/test/unit/category_test.rb @@ -229,7 +229,6 @@ class CategoryTest < Test::Unit::TestCase assert_equivalent [a1, a2], c.recent_articles end - should 'list recent comments' do c = @env.categories.build(:name => 'my category'); c.save! person = create_user('testuser').person @@ -261,9 +260,7 @@ class CategoryTest < Test::Unit::TestCase 10.times { a3.comments.build(:title => 'test', :body => 'kajsdsa', :author => person).save! } assert_equal [a3, a2], c.most_commented_articles(2) - end - should 'have comments' do c = @env.categories.build(:name => 'my category'); c.save! person = create_user('testuser').person -- libgit2 0.21.2