From 2cad0a738b3342b291031197ff1756a2dfe09cbf Mon Sep 17 00:00:00 2001 From: Larissa Reis Date: Thu, 15 Jan 2015 02:58:20 -0300 Subject: [PATCH] [search-improvements] Fixes cucumber tests in Noosfero 1.0 --- app/helpers/search_helper.rb | 7 ++++--- app/models/product.rb | 2 +- features/search_enterprises.feature | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index f916ab1..3e7fa90 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -90,12 +90,12 @@ module SearchHelper end end - def select_filter(name, options) + def select_filter(name, options, default = nil) if options.size <= 1 return else options = options.map {|option| [FILTERS_OPTIONS_TRANSLATION[name][option], option]} - options = options_for_select(options, :selected => params[name]) + options = options_for_select(options, :selected => (params[name] || default)) select_tag(name, options) end end @@ -104,7 +104,8 @@ module SearchHelper return if !asset klass = asset_class(asset) content_tag('div', klass::SEARCH_FILTERS.map do |name, options| - select_filter(name, options) + default = klass.respond_to?("default_search_#{name}") ? klass.send("default_search_#{name}".to_s) : nil + select_filter(name, options, default) end.join("\n"), :id => 'search-filters') end diff --git a/app/models/product.rb b/app/models/product.rb index 958642f..174f3a8 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -7,7 +7,7 @@ class Product < ActiveRecord::Base SEARCH_FILTERS = { :order => %w[more_recent], - :display => %w[map full] + :display => %w[full map] } attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs diff --git a/features/search_enterprises.feature b/features/search_enterprises.feature index 299f373..05c852b 100644 --- a/features/search_enterprises.feature +++ b/features/search_enterprises.feature @@ -47,6 +47,7 @@ Feature: search enterprises When I follow "Shoes shop" Then I should be on shop1's homepage + @selenium Scenario: show clean enterprise homepage on search results Given the following enterprises | identifier | name | @@ -59,12 +60,13 @@ Feature: search enterprises Then I should see "This is the homepage of" within ".search-enterprise-description" And I should see "about sho..." within ".search-enterprise-description" + @selenium Scenario: show clean enterprise description on search results Given the following enterprises | identifier | name | description | | shop4 | Clothes shop | This clothes shop also sells shoes! This too has a very long and pretty vague description, just so we can test wether the system will correctly create an excerpt of this text. Clothes are a really important part of our lives. | When I search enterprises for "clothes" - And I follow "Full" + And I choose the search filter "Full" And I should see "This clothes shop" within ".search-enterprise-description" And I should see "really import..." within ".search-enterprise-description" -- libgit2 0.21.2