Commit 60c4a40ce4bcf1a106c8fec04903b24a4cd84bd6

Authored by Rafael Martins
1 parent 51dfc2df

Fixes for SearchControllerTest

* Domain name
* New search results object
* Missing category on products
* 'See all' only appears when MULTIPLE_SEARCH_LIMIT is reached
Showing 1 changed file with 10 additions and 6 deletions   Show diff stats
test/functional/search_controller_test.rb
@@ -17,7 +17,7 @@ class SearchControllerTest < ActionController::TestCase @@ -17,7 +17,7 @@ class SearchControllerTest < ActionController::TestCase
17 env = Environment.default 17 env = Environment.default
18 domain = env.domains.first 18 domain = env.domains.first
19 if !domain 19 if !domain
20 - domain = Domain.create!(:name => "localhost") 20 + domain = Domain.create!(:name => "127.0.0.1")
21 env.domains = [domain] 21 env.domains = [domain]
22 env.save! 22 env.save!
23 end 23 end
@@ -152,7 +152,7 @@ class SearchControllerTest < ActionController::TestCase @@ -152,7 +152,7 @@ class SearchControllerTest < ActionController::TestCase
152 prod2 = ent2.products.create!(:name => 'another beautiful product', :product_category => @product_category) 152 prod2 = ent2.products.create!(:name => 'another beautiful product', :product_category => @product_category)
153 153
154 get :products 154 get :products
155 - assert_equivalent [prod2, prod1], assigns(:results)[:products] 155 + assert_equivalent [prod2, prod1], assigns(:results)[:products].docs
156 end 156 end
157 157
158 should 'include extra content supplied by plugins on product asset' do 158 should 'include extra content supplied by plugins on product asset' do
@@ -169,7 +169,8 @@ class SearchControllerTest < ActionController::TestCase @@ -169,7 +169,8 @@ class SearchControllerTest < ActionController::TestCase
169 end 169 end
170 170
171 enterprise = fast_create(Enterprise) 171 enterprise = fast_create(Enterprise)
172 - product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1"}, :search => true) 172 + prod_cat = fast_create(ProductCategory)
  173 + product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
173 174
174 e = Environment.default 175 e = Environment.default
175 e.enable_plugin(Plugin1.name) 176 e.enable_plugin(Plugin1.name)
@@ -193,7 +194,8 @@ class SearchControllerTest < ActionController::TestCase @@ -193,7 +194,8 @@ class SearchControllerTest < ActionController::TestCase
193 end 194 end
194 end 195 end
195 enterprise = fast_create(Enterprise) 196 enterprise = fast_create(Enterprise)
196 - product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1"}, :search => true) 197 + prod_cat = fast_create(ProductCategory)
  198 + product = fast_create(Product, {:enterprise_id => enterprise.id, :name => "produto1", :product_category_id => prod_cat.id}, :search => true)
197 199
198 environment = Environment.default 200 environment = Environment.default
199 environment.enable_plugin(Plugin1.name) 201 environment.enable_plugin(Plugin1.name)
@@ -355,8 +357,10 @@ class SearchControllerTest < ActionController::TestCase @@ -355,8 +357,10 @@ class SearchControllerTest < ActionController::TestCase
355 end 357 end
356 358
357 should 'show link to article asset in the see all foot link of the articles block in the category page' do 359 should 'show link to article asset in the see all foot link of the articles block in the category page' do
358 - a = create_user('test1').person.articles.create!(:name => 'an article to be found')  
359 - a.categories << @category 360 + (1..SearchController::MULTIPLE_SEARCH_LIMIT+1).each do |i|
  361 + a = create_user("test#{i}").person.articles.create!(:name => "article #{i} to be found")
  362 + a.categories << @category
  363 + end
360 364
361 get :category_index, :category_path => [ 'my-category' ] 365 get :category_index, :category_path => [ 'my-category' ]
362 assert_tag :tag => 'div', :attributes => {:class => /search-results-articles/} , :descendant => {:tag => 'a', :attributes => { :href => '/search/articles/my-category'}} 366 assert_tag :tag => 'div', :attributes => {:class => /search-results-articles/} , :descendant => {:tag => 'a', :attributes => { :href => '/search/articles/my-category'}}