Commit 2cad0a738b3342b291031197ff1756a2dfe09cbf

Authored by Larissa Reis
1 parent 4032bfa4

[search-improvements] Fixes cucumber tests in Noosfero 1.0

app/helpers/search_helper.rb
... ... @@ -90,12 +90,12 @@ module SearchHelper
90 90 end
91 91 end
92 92  
93   - def select_filter(name, options)
  93 + def select_filter(name, options, default = nil)
94 94 if options.size <= 1
95 95 return
96 96 else
97 97 options = options.map {|option| [FILTERS_OPTIONS_TRANSLATION[name][option], option]}
98   - options = options_for_select(options, :selected => params[name])
  98 + options = options_for_select(options, :selected => (params[name] || default))
99 99 select_tag(name, options)
100 100 end
101 101 end
... ... @@ -104,7 +104,8 @@ module SearchHelper
104 104 return if !asset
105 105 klass = asset_class(asset)
106 106 content_tag('div', klass::SEARCH_FILTERS.map do |name, options|
107   - select_filter(name, options)
  107 + default = klass.respond_to?("default_search_#{name}") ? klass.send("default_search_#{name}".to_s) : nil
  108 + select_filter(name, options, default)
108 109 end.join("\n"), :id => 'search-filters')
109 110 end
110 111  
... ...
app/models/product.rb
... ... @@ -7,7 +7,7 @@ class Product &lt; ActiveRecord::Base
7 7  
8 8 SEARCH_FILTERS = {
9 9 :order => %w[more_recent],
10   - :display => %w[map full]
  10 + :display => %w[full map]
11 11 }
12 12  
13 13 attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs
... ...
features/search_enterprises.feature
... ... @@ -47,6 +47,7 @@ Feature: search enterprises
47 47 When I follow "Shoes shop"
48 48 Then I should be on shop1's homepage
49 49  
  50 + @selenium
50 51 Scenario: show clean enterprise homepage on search results
51 52 Given the following enterprises
52 53 | identifier | name |
... ... @@ -59,12 +60,13 @@ Feature: search enterprises
59 60 Then I should see "This is the homepage of" within ".search-enterprise-description"
60 61 And I should see "about sho..." within ".search-enterprise-description"
61 62  
  63 + @selenium
62 64 Scenario: show clean enterprise description on search results
63 65 Given the following enterprises
64 66 | identifier | name | description |
65 67 | shop4 | Clothes shop | This <b>clothes</b> 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. |
66 68 When I search enterprises for "clothes"
67   - And I follow "Full"
  69 + And I choose the search filter "Full"
68 70 And I should see "This clothes shop" within ".search-enterprise-description"
69 71 And I should see "really import..." within ".search-enterprise-description"
70 72  
... ...