Commit 3371aaf9310bd7c545b7282dffc8e33d94216499
1 parent
8c2f7656
Exists in
staging
and in
42 other branches
Fixed test on search controller
Showing
1 changed file
with
21 additions
and
18 deletions
Show diff stats
test/functional/search_controller_test.rb
| ... | ... | @@ -138,22 +138,22 @@ class SearchControllerTest < ActionController::TestCase |
| 138 | 138 | end |
| 139 | 139 | |
| 140 | 140 | should 'get facets with people search results' do |
| 141 | - state = fast_create(State, :name => 'Acre', :acronym => 'AC') | |
| 142 | - city = fast_create(City, :name => 'Rio Branco', :parent_id => state.id) | |
| 143 | - person = Person.create!(:name => 'Hildebrando', :identifier => 'hild', :user_id => fast_create(User).id, :region_id => city.id) | |
| 144 | - cat1 = fast_create(Category, :name => 'cat1') | |
| 145 | - cat2 = fast_create(Category, :name => 'cat2') | |
| 146 | - person.add_category cat1 | |
| 147 | - person.add_category cat2 | |
| 141 | + state = fast_create(State, :name => 'Acre', :acronym => 'AC') | |
| 142 | + city = fast_create(City, :name => 'Rio Branco', :parent_id => state.id) | |
| 143 | + person = Person.create!(:name => 'Hildebrando', :identifier => 'hild', :user_id => fast_create(User).id, :region_id => city.id) | |
| 144 | + cat1 = fast_create(Category, :name => 'cat1') | |
| 145 | + cat2 = fast_create(Category, :name => 'cat2') | |
| 146 | + person.add_category cat1 | |
| 147 | + person.add_category cat2 | |
| 148 | 148 | |
| 149 | 149 | get 'people', :query => 'Hildebrando' |
| 150 | 150 | |
| 151 | - assert !assigns(:results)[:people].facets.blank? | |
| 152 | - assert assigns(:results)[:people].facets['facet_fields']['f_region_facet'][0][0] == city.id.to_s | |
| 151 | + assert !assigns(:results)[:people].facets.blank? | |
| 152 | + assert assigns(:results)[:people].facets['facet_fields']['f_region_facet'][0][0] == city.id.to_s | |
| 153 | 153 | |
| 154 | - assert assigns(:results)[:people].facets['facet_fields']['f_categories_facet'].count == 2 | |
| 155 | - assert assigns(:results)[:people].facets['facet_fields']['f_categories_facet'][0][0] == cat1.id.to_s | |
| 156 | - assert assigns(:results)[:people].facets['facet_fields']['f_categories_facet'][1][0] == cat2.id.to_s | |
| 154 | + categories_facet = assigns(:results)[:people].facets['facet_fields']['f_categories_facet'] | |
| 155 | + assert_equal 2, categories_facet.count | |
| 156 | + assert_equivalent [cat1.id.to_s, cat2.id.to_s], [categories_facet[0][0], categories_facet[1][0]] | |
| 157 | 157 | end |
| 158 | 158 | |
| 159 | 159 | # 'assets' menu outside any category |
| ... | ... | @@ -411,20 +411,23 @@ class SearchControllerTest < ActionController::TestCase |
| 411 | 411 | |
| 412 | 412 | should 'return events of the day' do |
| 413 | 413 | person = create_user('someone').person |
| 414 | - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => Date.today - 10.day) | |
| 415 | - ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 414 | + ten_days_ago = Date.today - 10.day | |
| 416 | 415 | |
| 417 | - get :events, :day => (Date.today - 10.day).day | |
| 416 | + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 417 | + ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month) | |
| 418 | 418 | |
| 419 | + get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year | |
| 419 | 420 | assert_equal [ev1], assigns(:events_of_the_day) |
| 420 | 421 | end |
| 421 | 422 | |
| 422 | 423 | should 'return events of the day with category' do |
| 423 | 424 | person = create_user('someone').person |
| 424 | - ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => Date.today - 10.day) | |
| 425 | - ev2 = create_event(person, :name => 'event 2', :start_date => Date.today - 10.day) | |
| 425 | + ten_days_ago = Date.today - 10.day | |
| 426 | + | |
| 427 | + ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) | |
| 428 | + ev2 = create_event(person, :name => 'event 2', :start_date => ten_days_ago) | |
| 426 | 429 | |
| 427 | - get :events, :day => (Date.today - 10.day).day, :category_path => @category.path.split('/') | |
| 430 | + get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/') | |
| 428 | 431 | |
| 429 | 432 | assert_equal [ev1], assigns(:events_of_the_day) |
| 430 | 433 | end | ... | ... |