Commit 7cdb436f56e689e94e2ec728f9b427565c6f9454
1 parent
a1f02e70
Exists in
master
and in
29 other branches
Fix missing variable in funcional test
also, removing lots of TAB characters ActionItem3048
Showing
1 changed file
with
51 additions
and
50 deletions
Show diff stats
test/functional/search_controller_test.rb
| ... | ... | @@ -74,14 +74,14 @@ class SearchControllerTest < ActionController::TestCase |
| 74 | 74 | assert_includes assigns(:searches)[:articles][:results], art |
| 75 | 75 | end |
| 76 | 76 | |
| 77 | - should 'redirect contents to articles' do | |
| 77 | + should 'redirect contents to articles' do | |
| 78 | 78 | person = fast_create(Person) |
| 79 | 79 | art = create_article_with_optional_category('an article to be found', person) |
| 80 | 80 | |
| 81 | 81 | get 'contents', :query => 'article found' |
| 82 | - # full description to avoid deprecation warning | |
| 82 | + # full description to avoid deprecation warning | |
| 83 | 83 | assert_redirected_to :controller => :search, :action => :articles, :query => 'article found' |
| 84 | - end | |
| 84 | + end | |
| 85 | 85 | |
| 86 | 86 | # 'assets' outside any category |
| 87 | 87 | should 'list articles in general' do |
| ... | ... | @@ -259,10 +259,10 @@ class SearchControllerTest < ActionController::TestCase |
| 259 | 259 | |
| 260 | 260 | should 'render specific action when only one asset is enabled' do |
| 261 | 261 | environment = Environment.default |
| 262 | - # article is not disabled | |
| 262 | + # article is not disabled | |
| 263 | 263 | [:enterprises, :people, :communities, :products, :events].select do |key, name| |
| 264 | - environment.enable('disable_asset_' + key.to_s) | |
| 265 | - end | |
| 264 | + environment.enable('disable_asset_' + key.to_s) | |
| 265 | + end | |
| 266 | 266 | environment.save! |
| 267 | 267 | @controller.stubs(:environment).returns(environment) |
| 268 | 268 | |
| ... | ... | @@ -274,25 +274,25 @@ class SearchControllerTest < ActionController::TestCase |
| 274 | 274 | assert !assigns(:searches).has_key?(:communities) |
| 275 | 275 | assert !assigns(:searches).has_key?(:products) |
| 276 | 276 | assert !assigns(:searches).has_key?(:events) |
| 277 | - end | |
| 277 | + end | |
| 278 | 278 | |
| 279 | 279 | should 'search all enabled assets in general search' do |
| 280 | 280 | ent1 = create_profile_with_optional_category(Enterprise, 'test enterprise') |
| 281 | 281 | prod_cat = ProductCategory.create!(:name => 'pctest', :environment => Environment.default) |
| 282 | 282 | prod = ent1.products.create!(:name => 'test product', :product_category => prod_cat) |
| 283 | - art = Article.create!(:name => 'test article', :profile_id => fast_create(Person).id) | |
| 284 | - per = Person.create!(:name => 'test person', :identifier => 'test-person', :user_id => fast_create(User).id) | |
| 285 | - com = Community.create!(:name => 'test community') | |
| 286 | - eve = Event.create!(:name => 'test event', :profile_id => fast_create(Person).id) | |
| 283 | + art = Article.create!(:name => 'test article', :profile_id => fast_create(Person).id) | |
| 284 | + per = Person.create!(:name => 'test person', :identifier => 'test-person', :user_id => fast_create(User).id) | |
| 285 | + com = Community.create!(:name => 'test community') | |
| 286 | + eve = Event.create!(:name => 'test event', :profile_id => fast_create(Person).id) | |
| 287 | 287 | |
| 288 | 288 | get :index, :query => 'test' |
| 289 | 289 | |
| 290 | 290 | [:articles, :enterprises, :people, :communities, :products, :events].select do |key, name| |
| 291 | - !assigns(:environment).enabled?('disable_asset_' + key.to_s) | |
| 292 | - end.each do |asset| | |
| 293 | - assert !assigns(:searches)[asset][:results].empty? | |
| 294 | - end | |
| 295 | - end | |
| 291 | + !assigns(:environment).enabled?('disable_asset_' + key.to_s) | |
| 292 | + end.each do |asset| | |
| 293 | + assert !assigns(:searches)[asset][:results].empty? | |
| 294 | + end | |
| 295 | + end | |
| 296 | 296 | |
| 297 | 297 | should 'display category image while in directory' do |
| 298 | 298 | parent = Category.create!(:name => 'category1', :environment => Environment.default) |
| ... | ... | @@ -318,8 +318,8 @@ class SearchControllerTest < ActionController::TestCase |
| 318 | 318 | person = create_user('someone').person |
| 319 | 319 | ten_days_ago = Date.today - 10.day |
| 320 | 320 | |
| 321 | - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 322 | - ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 321 | + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 322 | + ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 323 | 323 | |
| 324 | 324 | get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year |
| 325 | 325 | assert_equal [ev1], assigns(:events) |
| ... | ... | @@ -329,7 +329,7 @@ class SearchControllerTest < ActionController::TestCase |
| 329 | 329 | person = create_user('someone').person |
| 330 | 330 | ten_days_ago = Date.today - 10.day |
| 331 | 331 | |
| 332 | - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 332 | + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 333 | 333 | ev2 = create_event(person, :name => 'event 2', :start_date => ten_days_ago) |
| 334 | 334 | |
| 335 | 335 | get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/') |
| ... | ... | @@ -339,8 +339,8 @@ class SearchControllerTest < ActionController::TestCase |
| 339 | 339 | |
| 340 | 340 | should 'return events of today when no date specified' do |
| 341 | 341 | person = create_user('someone').person |
| 342 | - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => Date.today) | |
| 343 | - ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 342 | + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => Date.today) | |
| 343 | + ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 344 | 344 | |
| 345 | 345 | get :events |
| 346 | 346 | |
| ... | ... | @@ -351,9 +351,9 @@ class SearchControllerTest < ActionController::TestCase |
| 351 | 351 | person = create_user('someone').person |
| 352 | 352 | |
| 353 | 353 | ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], |
| 354 | - :start_date => Date.today + 2.month) | |
| 354 | + :start_date => Date.today + 2.month) | |
| 355 | 355 | ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], |
| 356 | - :start_date => Date.today + 2.day) | |
| 356 | + :start_date => Date.today + 2.day) | |
| 357 | 357 | |
| 358 | 358 | get :events |
| 359 | 359 | |
| ... | ... | @@ -373,8 +373,9 @@ class SearchControllerTest < ActionController::TestCase |
| 373 | 373 | end |
| 374 | 374 | |
| 375 | 375 | should 'see the events paginated' do |
| 376 | + person = create_user('pagination').person | |
| 376 | 377 | 30.times do |i| |
| 377 | - create_event(person, :name => "Event #{i}", :start_date => Date.today) | |
| 378 | + create_event(person, :name => "Event #{i}", :start_date => Date.today) | |
| 378 | 379 | end |
| 379 | 380 | get :events |
| 380 | 381 | assert_equal 20, assigns(:events).count |
| ... | ... | @@ -433,8 +434,8 @@ class SearchControllerTest < ActionController::TestCase |
| 433 | 434 | end |
| 434 | 435 | |
| 435 | 436 | should 'show link to article asset in the see all foot link of the articles block in the category page' do |
| 436 | - (1..SearchController::MULTIPLE_SEARCH_LIMIT+1).each do |i| | |
| 437 | - a = create_user("test#{i}").person.articles.create!(:name => "article #{i} to be found") | |
| 437 | + (1..SearchController::MULTIPLE_SEARCH_LIMIT+1).each do |i| | |
| 438 | + a = create_user("test#{i}").person.articles.create!(:name => "article #{i} to be found") | |
| 438 | 439 | ArticleCategorization.add_category_to_article(@category, a) |
| 439 | 440 | end |
| 440 | 441 | |
| ... | ... | @@ -580,55 +581,55 @@ class SearchControllerTest < ActionController::TestCase |
| 580 | 581 | assert_not_includes assigns(:searches)[:communities][:results], p1 |
| 581 | 582 | end |
| 582 | 583 | |
| 583 | - should 'keep old urls working' do | |
| 584 | - get :assets, :asset => 'articles' | |
| 584 | + should 'keep old urls working' do | |
| 585 | + get :assets, :asset => 'articles' | |
| 585 | 586 | assert_redirected_to :controller => :search, :action => :articles |
| 586 | - get :assets, :asset => 'people' | |
| 587 | + get :assets, :asset => 'people' | |
| 587 | 588 | assert_redirected_to :controller => :search, :action => :people |
| 588 | - get :assets, :asset => 'communities' | |
| 589 | + get :assets, :asset => 'communities' | |
| 589 | 590 | assert_redirected_to :controller => :search, :action => :communities |
| 590 | - get :assets, :asset => 'products' | |
| 591 | + get :assets, :asset => 'products' | |
| 591 | 592 | assert_redirected_to :controller => :search, :action => :products |
| 592 | - get :assets, :asset => 'enterprises' | |
| 593 | + get :assets, :asset => 'enterprises' | |
| 593 | 594 | assert_redirected_to :controller => :search, :action => :enterprises |
| 594 | - get :assets, :asset => 'events' | |
| 595 | + get :assets, :asset => 'events' | |
| 595 | 596 | assert_redirected_to :controller => :search, :action => :events |
| 596 | - end | |
| 597 | + end | |
| 597 | 598 | |
| 598 | - should 'show tag cloud' do | |
| 599 | - @controller.stubs(:is_cache_expired?).returns(true) | |
| 599 | + should 'show tag cloud' do | |
| 600 | + @controller.stubs(:is_cache_expired?).returns(true) | |
| 600 | 601 | a = Article.create!(:name => 'my article', :profile_id => fast_create(Person).id) |
| 601 | 602 | a.tag_list = ['one', 'two'] |
| 602 | - a.save_tags | |
| 603 | + a.save_tags | |
| 603 | 604 | |
| 604 | - get :tags | |
| 605 | + get :tags | |
| 605 | 606 | |
| 606 | - assert assigns(:tags)["two"] = 1 | |
| 607 | - assert assigns(:tags)["one"] = 1 | |
| 608 | - end | |
| 607 | + assert assigns(:tags)["two"] = 1 | |
| 608 | + assert assigns(:tags)["one"] = 1 | |
| 609 | + end | |
| 609 | 610 | |
| 610 | 611 | should 'show tagged content' do |
| 611 | - @controller.stubs(:is_cache_expired?).returns(true) | |
| 612 | + @controller.stubs(:is_cache_expired?).returns(true) | |
| 612 | 613 | a = Article.create!(:name => 'my article', :profile_id => fast_create(Person).id) |
| 613 | 614 | a2 = Article.create!(:name => 'my article 2', :profile_id => fast_create(Person).id) |
| 614 | 615 | a.tag_list = ['one', 'two'] |
| 615 | 616 | a2.tag_list = ['two', 'three'] |
| 616 | - a.save_tags | |
| 617 | + a.save_tags | |
| 617 | 618 | a2.save_tags |
| 618 | 619 | |
| 619 | - get :tag, :tag => 'two' | |
| 620 | + get :tag, :tag => 'two' | |
| 620 | 621 | |
| 621 | 622 | assert_equivalent [a, a2], assigns(:searches)[:tag][:results] |
| 622 | 623 | |
| 623 | - get :tag, :tag => 'one' | |
| 624 | + get :tag, :tag => 'one' | |
| 624 | 625 | |
| 625 | 626 | assert_equivalent [a], assigns(:searches)[:tag][:results] |
| 626 | 627 | end |
| 627 | 628 | |
| 628 | 629 | should 'not show assets from other environments' do |
| 629 | 630 | other_env = Environment.create!(:name => 'Another environment') |
| 630 | - p1 = Person.create!(:name => 'Hildebrando', :identifier => 'hild', :user_id => fast_create(User).id, :environment_id => other_env.id) | |
| 631 | - p2 = Person.create!(:name => 'Adamastor', :identifier => 'adam', :user_id => fast_create(User).id) | |
| 631 | + p1 = Person.create!(:name => 'Hildebrando', :identifier => 'hild', :user_id => fast_create(User).id, :environment_id => other_env.id) | |
| 632 | + p2 = Person.create!(:name => 'Adamastor', :identifier => 'adam', :user_id => fast_create(User).id) | |
| 632 | 633 | art1 = Article.create!(:name => 'my article', :profile_id => p1.id) |
| 633 | 634 | art2 = Article.create!(:name => 'my article', :profile_id => p2.id) |
| 634 | 635 | |
| ... | ... | @@ -639,9 +640,9 @@ class SearchControllerTest < ActionController::TestCase |
| 639 | 640 | |
| 640 | 641 | should 'order articles by more recent' do |
| 641 | 642 | Article.destroy_all |
| 642 | - art1 = Article.create!(:name => 'review C', :profile_id => fast_create(Person).id, :created_at => Time.now-1.days) | |
| 643 | - art2 = Article.create!(:name => 'review A', :profile_id => fast_create(Person).id, :created_at => Time.now) | |
| 644 | - art3 = Article.create!(:name => 'review B', :profile_id => fast_create(Person).id, :created_at => Time.now-2.days) | |
| 643 | + art1 = Article.create!(:name => 'review C', :profile_id => fast_create(Person).id, :created_at => Time.now-1.days) | |
| 644 | + art2 = Article.create!(:name => 'review A', :profile_id => fast_create(Person).id, :created_at => Time.now) | |
| 645 | + art3 = Article.create!(:name => 'review B', :profile_id => fast_create(Person).id, :created_at => Time.now-2.days) | |
| 645 | 646 | |
| 646 | 647 | get :articles, :filter => :more_recent |
| 647 | 648 | ... | ... |