Commit 0ffb25193b3d72fd5842ea7b5b8cd6c1b8812816

Authored by Rafael Martins
1 parent e4e0c085

Updated features and views for searchable models

app/helpers/search_helper.rb
... ... @@ -157,7 +157,7 @@ module SearchHelper
157 157 ret.map do |label, name, url|
158 158 content_tag('div', content_tag('span', label, :class => 'facet-selected-label') +
159 159 content_tag('span', name, :class => 'facet-selected-name') +
160   - link_to('', url, :class => 'facet-selected-remove'), :class => 'facet-selected')
  160 + link_to('', url, :class => 'facet-selected-remove', :title => 'remove facet'), :class => 'facet-selected')
161 161 end.join
162 162 end
163 163  
... ...
app/views/map_balloon/profile.rhtml
... ... @@ -16,7 +16,7 @@
16 16 <% unless @profile.address.nil? %>
17 17 <strong><%= _('Address: ') + @profile.address %></strong><br/>
18 18 <% end %>
19   - <% unless @profile.products.empty? %>
  19 + <% if @profile.respond_to?(:products) and !@profile.products.blank? %>
20 20 <strong><%= _('Products/Services: ') + @profile.products.map{|i| link_to(i.name, :controller => 'manage_products', :profile => @profile.identifier, :action => 'show', :id => i.id)}.join(', ') %></strong><br/>
21 21 <% end %>
22 22 <% if @profile.respond_to?(:distance) and !@profile.distance.nil? %>
... ...
app/views/search/_article_description.rhtml
... ... @@ -5,7 +5,9 @@
5 5  
6 6 <% if !article.body.blank? %>
7 7 <% description = strip_tags(article.body.to_s) %>
8   - <% description = excerpt(description, description.first(3), 200).gsub!(/\s{2,}/, ' ') %>
  8 + <% description.gsub!(/\s{2,}/, ' ') %>
  9 + <% description = excerpt(description, description.first(3), 200) %>
  10 +
9 11 <td class="search-article-body"><%= description %></td>
10 12 <% else %>
11 13 <td class="search-field-none"><%= _('None') %></td>
... ...
app/views/search/_event.rhtml
1 1 <li class="search-event-item article-item">
2   - <%= link_to(event.title, event.url, :class => "search-result-title") %>
3   - <div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => event %>
5   - </div>
6   - <table class="noborder search-content-second-column">
7   - <% if event.start_date %>
8   - <tr class="searc-article-event-date">
9   - <td class="search-field-label"><%= _('Start date') %></td>
10   - <td class="article-item-date"><%= event.start_date %></td>
11   - </tr>
12   - <% end %>
13   - <% if event.end_date %>
14   - <tr class="searc-article-event-date">
15   - <td class="search-field-label"><%= _('End date') %></td>
16   - <td class="article-item-date"><%= event.end_date %></td>
17   - </tr>
18   - <% end %>
  2 +<%= link_to(event.title, event.url, :class => "search-result-title") %>
  3 +<div class="search-content-first-column">
  4 + <%= render :partial => 'image', :object => event %>
  5 +</div>
  6 +<table class="noborder search-content-second-column">
  7 + <% if event.start_date %>
  8 + <tr class="search-article-event-date">
  9 + <td class="search-field-label"><%= _('Start date') %></td>
  10 + <td class="article-item-date"><%= event.start_date %></td>
  11 + </tr>
  12 + <% end %>
  13 + <% if event.end_date %>
  14 + <tr class="search-article-event-date">
  15 + <td class="search-field-label"><%= _('End date') %></td>
  16 + <td class="article-item-date"><%= event.end_date %></td>
  17 + </tr>
  18 + <% end %>
19 19  
20   - <%= render :partial => 'article_common', :object => event %>
21   - </table>
22   - <%= render :partial => 'article_last_change', :object => event %>
  20 + <%= render :partial => 'article_common', :object => event %>
  21 +</table>
  22 +<%= render :partial => 'article_last_change', :object => event %>
23 23  
24   - <div style="clear: both"></div>
  24 +<div style="clear: both"></div>
25 25 </li>
... ...
app/views/search/_product.rhtml
... ... @@ -30,7 +30,7 @@
30 30 <% title = product.inputs.map{ |i|
31 31 '<div class="search-product-input-dots-to-price">' +
32 32 '<div class="search-product-input-name">' + i.product_category.name + '</div>' +
33   - price_span(i.price_per_unit*i.amount_used, :class => 'search-product-input-price') +
  33 + price_span(i.cost, :class => 'search-product-input-price') +
34 34 '</div>' }.join('') %>
35 35 <% title += product.price_details.map{ |p|
36 36 '<div class="search-product-input-dots-to-price">' +
... ...
app/views/search/_profile.rhtml
1 1 <li class="search-profile-item">
2   - <% if @empty_query or @results.size > 1 or !profile.enterprise? %>
3   - <%= profile_image_link profile, :portrait, 'div' %>
4   - <% else %>
5   - <div class="search-enterprise-item">
6   - <div class="search-enterprise-item-column-left">
7   - <%= profile_image_link profile, :portrait, 'div' %>
  2 +<% if @empty_query or @results.size > 1 or !profile.enterprise? %>
  3 + <%= profile_image_link profile, :portrait, 'div' %>
  4 +<% else %>
  5 + <div class="search-enterprise-item">
  6 + <div class="search-enterprise-item-column-left">
  7 + <%= profile_image_link profile, :portrait, 'div' %>
  8 + </div>
  9 + <div class="search-enterprise-item-column-right">
  10 + <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %>
  11 + <div class="search-enterprise-description">
  12 + <% if profile.description %>
  13 + <% body_stripped = strip_tags(profile.description) %>
  14 + <% elsif profile.home_page and profile.home_page.body %>
  15 + <% body_stripped = strip_tags(profile.home_page.body) %>
  16 + <% end %>
  17 + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
8 18 </div>
9   - <div class="search-enterprise-item-column-right">
10   - <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %>
11   - <div class="search-enterprise-description">
12   - <% if profile.description %>
13   - <% body_stripped = strip_tags(profile.description) %>
14   - <% elsif profile.home_page and profile.home_page.body %>
15   - <% body_stripped = strip_tags(profile.home_page.body) %>
16   - <% end %>
17   - <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
18   - </div>
19   - <div class="search-enterprise-region">
20   - <span class="search-enterprise-region-label"><%= _("City") %></span>
21   - <% if profile.region %>
22   - <span class="search-enterprise-region-name"><%= city_with_state(profile.region) %></span>
23   - <% end %>
24   - </div>
25   - <% if !profile.description.blank? %>
26   - <div><%= profile.description %></div><br />
  19 + <div class="search-enterprise-region">
  20 + <span class="search-enterprise-region-label"><%= _("City") %></span>
  21 + <% if profile.region %>
  22 + <span class="search-enterprise-region-name"><%= city_with_state(profile.region) %></span>
27 23 <% end %>
  24 + </div>
28 25  
29   - <div class="search-enterprise-categorization">
30   - <% profile.top_level_categorization.each do |parent, children| %>
31   - <% if parent.name != "Territórios" %>
32   - <div class="search-enterprise-category-<%=parent.id%> search-enterprise-category">
33   - <span class="search-enterprise-categorization-parent"><%= parent.name %></span>
34   - <span class="search-enterprise-categorization-children">
35   - <%= children.collect(&:name).join(', ') %>
36   - </span>
37   - </div>
38   - <% end %>
  26 + <div class="search-enterprise-categorization">
  27 + <% profile.top_level_categorization.each do |parent, children| %>
  28 + <% if parent.name != "Territórios" %>
  29 + <div class="search-enterprise-category-<%=parent.id%> search-enterprise-category">
  30 + <span class="search-enterprise-categorization-parent"><%= parent.name %></span>
  31 + <span class="search-enterprise-categorization-children">
  32 + <%= children.collect(&:name).join(', ') %>
  33 + </span>
  34 + </div>
39 35 <% end %>
40   - </div>
  36 + <% end %>
41 37 </div>
42   -
43   - <hr class="clearfix" />
44 38 </div>
45   - <% end %>
  39 +
  40 + <hr class="clearfix" />
  41 + </div>
  42 +<% end %>
46 43 </li>
... ...
app/views/search/products.rhtml
1   -<%= search_page_title( @titles[:products], @category ) %>
  1 +<% if @environment.settings[:disable_asset_products_enabled] %>
  2 + Product search disabled
  3 +<% else %>
2 4  
3   -<div id="search-column-left">
4   - <% if !@empty_query %>
5   - <% button_bar do %>
6   - <%= display_map_list_button %>
  5 + <%= search_page_title( @titles[:products], @category ) %>
  6 +
  7 + <div id="search-column-left">
  8 + <% if !@empty_query %>
  9 + <% button_bar do %>
  10 + <%= display_map_list_button %>
  11 + <% end %>
  12 + <%= facets_menu(:products, @facets) %>
7 13 <% end %>
8   - <%= facets_menu(:products, @facets) %>
9   - <% end %>
10   -</div>
  14 + </div>
  15 +
  16 + <div id="search-column-right">
  17 + <%= render :partial => 'search_form', :locals => { :hint => _('Type the product, service, city or qualifier desired') } %>
  18 + <%= render :partial => 'results_header' %>
11 19  
12   -<div id="search-column-right">
13   - <%= render :partial => 'search_form', :locals => { :hint => _('Type the product, service, city or qualifier desired') } %>
14   - <%= render :partial => 'results_header' %>
  20 + <%= display_results(true) %>
  21 + <% if !@one_page and params[:display] != 'map' %>
  22 + <%= pagination_links @results[:products] %>
  23 + <% end %>
  24 + </div>
15 25  
16   - <%= display_results(true) %>
17   - <% if !@one_page and params[:display] != 'map' %>
18   - <%= pagination_links @results[:products] %>
19   - <% end %>
20   -</div>
  26 +<% end %>
21 27  
22 28 <div style="clear: both"></div>
... ...
features/search.feature
... ... @@ -7,12 +7,22 @@ Feature: search
7 7 Given the search index is empty
8 8 And feature "disable_asset_products" is disabled on environment
9 9  
10   - Scenario: search with empty results
  10 + Scenario: show empty results in all enabled assets
11 11 Given I go to the search page
12 12 And I fill in "query" with "Anything"
13 13 And I press "Search"
14   - Then I should see "None" within ".multiple-results-boxes"
15   - And I should see "None" within ".search-results-empty"
  14 + Then I should see "People" within ".search-results-people"
  15 + And I should see "None" within ".search-results-people"
  16 + And I should see "Communities" within ".search-results-communities"
  17 + And I should see "None" within ".search-results-communities"
  18 + And I should see "Enterprises" within ".search-results-enterprises"
  19 + And I should see "None" within ".search-results-enterprises"
  20 + And I should see "Contents" within ".search-results-articles"
  21 + And I should see "None" within ".search-results-articles"
  22 + And I should see "Products" within ".search-results-products"
  23 + And I should see "None" within ".search-results-products"
  24 + And I should see "Events" within ".search-results-events"
  25 + And I should see "None" within ".search-results-events"
16 26  
17 27 Scenario: simple search for person
18 28 Given the following users
... ... @@ -22,18 +32,42 @@ Feature: search
22 32 When I go to the search page
23 33 And I fill in "query" with "Silva"
24 34 And I press "Search"
25   - Then I should see "Joao Silva" within "div.search-results-people"
  35 + Then I should see "Joao Silva" within ".common-profile-list-block"
26 36 And I should not see "Jose Araujo"
27 37  
  38 + Scenario: show link to see all results
  39 + Given the following users
  40 + | login | name |
  41 + | joaosilva | Joao Silva |
  42 + And the following articles
  43 + | owner | name |
  44 + | joaosilva | article #1 |
  45 + | joaosilva | article #2 |
  46 + | joaosilva | article #3 |
  47 + | joaosilva | article #4 |
  48 + | joaosilva | article #5 |
  49 + | joaosilva | article #6 |
  50 + | joaosilva | article #7 |
  51 + | joaosilva | article #8 |
  52 + | joaosilva | article #9 |
  53 + When I go to the search page
  54 + And I fill in "query" with "article"
  55 + And I press "Search"
  56 + Then I should see "article #8" within ".search-results-articles"
  57 + And I should not see "article #9" within ".search-results-articles"
  58 + And I should see "see all (9)"
  59 + When I follow "see all (9)"
  60 + Then I should be on the search articles page
  61 +
28 62 Scenario: simple search for community
29 63 Given the following communities
30   - | identifier | name |
31   - | boring-community | Boring community |
32   - | fancy-community | Fancy community |
  64 + | identifier | name | img |
  65 + | boring-community | Boring community | semterrinha |
  66 + | fancy-community | Fancy community | agrotox |
33 67 And I go to the search page
34 68 And I fill in "query" with "fancy"
35 69 And I press "Search"
36   - Then I should see "Fancy community" within "div.search-results-communities"
  70 + Then I should see "Fancy community" within ".common-profile-list-block"
37 71 And I should not see "Boring community"
38 72  
39 73 Scenario: simple search for enterprise
... ... @@ -44,7 +78,7 @@ Feature: search
44 78 And I go to the search page
45 79 And I fill in "query" with "shoes"
46 80 And I press "Search"
47   - Then I should see "Shoes shop" within "div.search-results-enterprises"
  81 + Then I should see "Shoes shop" within ".common-profile-list-block"
48 82 And I should not see "Fruits shop"
49 83  
50 84 Scenario: simple search for content
... ... @@ -94,11 +128,11 @@ Feature: search
94 128  
95 129 Scenario: search different types of entities with the same query
96 130 Given the following enterprises
97   - | identifier | name |
  131 + | identifier | name |
98 132 | colivre_dev | Colivre - Noosfero dev. |
99 133 And the following communities
100 134 | identifier | name |
101   - | noosfero-users | Noosfero users |
  135 + | noosfero-users | Noosfero users |
102 136 And the following product_categories
103 137 | name |
104 138 | Development |
... ...
features/search_communities.feature
1 1 Feature: search communities
2 2 As a noosfero user
3 3 I want to search communities
4   - In order to find ones that interest me
  4 + In order to find ones that interest me
5 5  
6 6 Background:
7 7 Given the search index is empty
8 8 And the following category
9 9 | name |
10   - | social network |
  10 + | social network |
11 11 And the following community
12   - | identifier | name | category |
13   - | noosfero | Noosfero Community | social-network |
  12 + | identifier | name | category | img |
  13 + | noosfero | Noosfero Community | social-network | noosfero-network |
14 14  
15   - Scenario: show recent communities on index (empty query)
  15 + Scenario: show recent communities on index
16 16 Given the following community
17   - | identifier | name | category |
18   - | linux | Linux Community | social-network |
  17 + | identifier | name | category | img |
  18 + | linux | Linux Community | social-network | tux |
19 19 When I go to the search communities page
20 20 Then I should see "Noosfero Community" within "#search-results"
  21 + And I should see Noosfero Community's community image
21 22 And I should see "Linux Community" within "#search-results"
  23 + And I should see Linux Community's community image
  24 +
  25 + Scenario: show empty search results
  26 + When I search communities for "something unrelated"
  27 + Then I should see "None" within ".search-results-type-empty"
22 28  
23 29 Scenario: simple search for community
24 30 When I go to the search communities page
25 31 And I fill in "query" with "noosfero"
26 32 And I press "Search"
27 33 Then I should see "Noosfero Community" within "#search-results"
  34 + And I should see "Noosfero Community" within ".only-one-result-box"
  35 + And I should see Noosfero Community's community image
28 36  
29 37 Scenario: search communities by category
30 38 Given the following category
31 39 | name |
32   - | Software Livre |
  40 + | Software Livre |
33 41 And the following community
34 42 | identifier | name | category |
35 43 | noos-comm | Noosfero Community | software-livre |
... ... @@ -44,7 +52,7 @@ Feature: search communities
44 52 | Temáticas |
45 53 And the following category
46 54 | name | parent |
47   - | Software Livre | tematicas |
  55 + | Software Livre | tematicas |
48 56 And the following community
49 57 | identifier | name | category |
50 58 | linux | Linux Community | software-livre |
... ... @@ -80,6 +88,9 @@ Feature: search communities
80 88 And I follow "Software Livre" within "#facets-menu"
81 89 Then I should see "Noosfero Developers" within "#search-results"
82 90 And I should not see "Facebook Developers"
  91 + # facet should also be de-selectable
  92 + When I follow "remove facet" within ".facet-selected"
  93 + Then I should see "Facebook Developers"
83 94  
84 95 Scenario: remember facet filter when searching new query
85 96 Given the following categories as facets
... ...
features/search_contents.feature
1 1 Feature: search contents
2 2 As a noosfero user
3 3 I want to search contents
4   - In order to find ones that interest me
  4 + In order to find ones that interest me
5 5  
6 6 Background:
7 7 Given the search index is empty
... ... @@ -9,44 +9,293 @@ Feature: search contents
9 9 | login | name |
10 10 | joaosilva | Joao Silva |
11 11 And the following articles
12   - | owner | name | body |
  12 + | owner | name | body |
13 13 | joaosilva | bees and butterflies | this is an article about bees and butterflies |
14 14 | joaosilva | whales and dolphins | this is an article about whales and dolphins |
  15 + And the following categories as facets
  16 + | name |
  17 + | Temáticas |
15 18  
16   - Scenario: show recent contents on index (empty query)
17   - When I go to the search contents page
  19 + Scenario: show recent content on index
  20 + When I go to the search articles page
18 21 Then I should see "bees and butterflies" within "#search-results"
19 22 And I should see "whales and dolphins" within "#search-results"
20 23  
21   - Scenario: simple search for content
22   - When I go to the search contents page
  24 + Scenario: simple search for text articles
  25 + When I search contents for "whales"
  26 + Then I should see "whales and dolphins" within ".search-text-article-item"
  27 + And I should see "whales and dolphins" within ".only-one-result-box"
  28 + And I should not see "bees and butterflies"
  29 + And I should see content inside ".icon-content-textile-article"
  30 + When I follow "whales and dolphins"
  31 + Then I should be on article "whales and dolphins"
  32 +
  33 + Scenario: simple search for event
  34 + Given the following communities
  35 + | identifier | name |
  36 + | nice-people | Nice people |
  37 + And the following events
  38 + | owner | name | start_date | end_date |
  39 + | nice-people | Group meeting | 2009-01-01 | 2009-01-02 |
  40 + | nice-people | John Doe's birthday | 2009-09-01 | 2009-09-02 |
  41 + When I search contents for "birthday"
  42 + Then I should see "John Doe's birthday" within ".search-event-item"
  43 + And I should see "Start date"
  44 + And I should see "2009-09-01"
  45 + And I should see "End date"
  46 + And I should see "2009-09-02"
  47 + And I should not see "Group meeting"
  48 + When I follow "John Doe's birthday"
  49 + Then I should be on article "John Doe's birthday"
  50 +
  51 + Scenario: simple search for folder
  52 + Given the following folders
  53 + | owner | name |
  54 + | joaosilva | Music Folder |
  55 + | joaosilva | Videos Folder |
  56 + When I search contents for "Music"
  57 + Then I should see "Music Folder" within ".search-folder-item"
  58 + And I should see "None" within ".search-folder-items"
  59 + And I should not see "Videos Folder"
  60 + When I follow "Music Folder"
  61 + Then I should be on article "Music Folder"
  62 +
  63 + Scenario: simple search for forum
  64 + Given the following forums
  65 + | owner | name |
  66 + | joaosilva | Games Forum |
  67 + | joaosilva | Movies Folder |
  68 + When I search contents for "Games"
  69 + Then I should see "Games Forum" within ".search-forum-item"
  70 + And I should see "None" within ".search-forum-items"
  71 + And I should not see "Movies Folder"
  72 + When I follow "Games Forum"
  73 + Then I should be on article "Games Forum"
  74 +
  75 + Scenario: simple search for gallery
  76 + Given the following galleries
  77 + | owner | name |
  78 + | joaosilva | Landscape Photos |
  79 + | joaosilva | People Photos |
  80 + When I search contents for "Landscape"
  81 + Then I should see "Landscape Photos" within ".search-gallery"
  82 + And I should not see "People Photos"
  83 + When I follow "Landscape Photos"
  84 +
  85 + Scenario: simple search for uploaded file
  86 + Given the following uploaded files
  87 + | owner | name | filename |
  88 + | joaosilva | Uploaded Executable | rails |
  89 + | joaosilva | Uploaded Spreadsheet | rails |
  90 + When I search contents for "Executable"
  91 + Then I should see "Uploaded Executable" within ".search-uploaded-file-item"
  92 + And I should not see "Uploaded Spreadsheet"
  93 + When I follow "Uploaded Executable"
  94 + Then I should be on content "Uploaded Executable"
  95 +
  96 + Scenario: show event search results without end date
  97 + Given the following communities
  98 + | identifier | name |
  99 + | nice-people | Nice people |
  100 + And the following events
  101 + | owner | name |
  102 + | nice-people | John Doe's birthday |
  103 + When I search contents for "birthday"
  104 + Then I should see "John Doe's birthday" within ".search-event-item"
  105 + And I should not see "End date"
  106 +
  107 + Scenario: show and link last items on folder search results
  108 + Given the following folders
  109 + | owner | name |
  110 + | joaosilva | Music Folder |
  111 + And the following articles
  112 + | owner | name | parent |
  113 + | joaosilva | Steven Wilson | Music Folder |
  114 + | joaosilva | Porcupine Tree | Music Folder |
  115 + | joaosilva | Blackfield | Music Folder |
  116 + When I search contents for "Music"
  117 + Then I should see "Last items" within ".search-folder-items"
  118 + And I should see "Blackfield"
  119 + And I should see "Porcupine Tree"
  120 + And I should see "Steven Wilson"
  121 + When I follow "Porcupine Tree"
  122 + Then I should be on article "Porcupine Tree"
  123 +
  124 + Scenario: show and link last topics on forum search results
  125 + Given the following forums
  126 + | owner | name |
  127 + | joaosilva | Games Forum |
  128 + And the following articles
  129 + | owner | name | parent |
  130 + | joaosilva | The Old Republic | Games Forum |
  131 + | joaosilva | Mass Effect 3 | Games Forum |
  132 + | joaosilva | The Witcher 2 | Games Forum |
  133 + | joaosilva | Syndicate | Games Forum |
  134 + And the following rss feeds
  135 + | joaosilva | Diablo 3 News Feed | Games Forum |
  136 + When I search contents for "Games"
  137 + Then I should see "Last topics" within ".search-forum-items"
  138 + And I should see "Syndicate"
  139 + And I should see "The Witcher 2"
  140 + And I should see "Mass Effect 3"
  141 + And I should not see "The Old Republic"
  142 + And I should not see "Diablo 3"
  143 + When I follow "The Witcher 2"
  144 + Then I should be on article "The Witcher 2"
  145 +
  146 + Scenario: link to parent in uploaded file search results
  147 + Given the following folders
  148 + | owner | name |
  149 + | joaosilva | Folder for Uploaded Files |
  150 + Given the following uploaded files
  151 + | owner | name | parent | filename |
  152 + | joaosilva | Uploaded Executable 2 | Folder for Uploaded Files | rails |
  153 + When I search contents for "Executable"
  154 + Then I should see "Folder for Uploaded Files" within ".search-uploaded-file-parent"
  155 + When I follow "Folder for Uploaded Files"
  156 + Then I should be on content "Folder for Uploaded Files"
  157 +
  158 + Scenario: link to author on search results
  159 + When I go to the search articles page
23 160 And I fill in "query" with "whales"
24 161 And I press "Search"
25   - Then I should see "whales and dolphins" within "#search-results"
26   - And I should not see "bees and butterflies"
  162 + Then I should see "Author" within ".search-article-author"
  163 + Then I should see "Joao Silva" within ".search-article-author-name"
  164 + When I follow "Joao Silva"
  165 + Then I should be on Joao Silva's profile
  166 +
  167 + Scenario: show clean description excerpt on search results
  168 + Given the following articles
  169 + | owner | name | body |
  170 + | joaosilva | Herreninsel | The island <b>Herreninsel</b>, with an area of 238 hectares, is the biggest of the three main islands of the Chiemsee, a lake in the state of Bavaria, Germany. Together with the islands of Fraueninsel and Krautinsel it forms the municipality of Chiemsee. |
  171 + When I go to the search articles page
  172 + And I fill in "query" with "island"
  173 + And I press "Search"
  174 + Then I should see "Description" within ".search-article-description"
  175 + And I should see "The island Herreninsel, with" within ".search-article-description"
  176 + And I should see "and Kraut..." within ".search-article-description"
  177 +
  178 + Scenario: show empty description on search results
  179 + Given the following articles
  180 + | owner | name | body |
  181 + | joaosilva | Herreninsel | |
  182 + When I go to the search articles page
  183 + And I fill in "query" with "Herreninsel"
  184 + And I press "Search"
  185 + Then I should see "None" within ".search-article-description"
27 186  
28   - Scenario: search contents by category
  187 + Scenario: link to tags on search results
  188 + Given the following tags
  189 + | article | name |
  190 + | bees and butterflies | Hymenoptera |
  191 + | bees and butterflies | Lepidoptera |
  192 + When I go to the search articles page
  193 + And I fill in "query" with "bees"
  194 + And I press "Search"
  195 + Then I should see "Tags" within ".search-article-tags"
  196 + And I should see "Hymenoptera" within ".search-article-tags"
  197 + And I should see "Lepidoptera" within ".search-article-tags"
  198 + When I follow "Hymenoptera"
  199 + Then I should be on Hymenoptera's tag page
  200 +
  201 + Scenario: show empty tags in search results
  202 + When I go to the search articles page
  203 + And I fill in "query" with "dolphins"
  204 + And I press "Search"
  205 + Then I should see "None" within ".search-article-tags"
  206 +
  207 + Scenario: link to categories on search results
  208 + Given the following category
  209 + | name |
  210 + | Soviet ice hockey players |
  211 + And the following articles
  212 + | owner | name | body | category |
  213 + | joaosilva | Sergei Sorokin | Retired ice hockey player | Soviet ice hockey players |
  214 + When I go to the search articles page
  215 + And I fill in "query" with "hockey"
  216 + And I press "Search"
  217 + Then I should see "Categories" within ".search-article-categories"
  218 + And I should see "Soviet ice hockey players" within ".search-article-categories"
  219 + When I follow "Soviet ice hockey players"
  220 + Then I should be on Joao Silva's profile
  221 +
  222 + Scenario: show empty categories on search results
  223 + When I go to the search articles page
  224 + And I fill in "query" with "whales"
  225 + And I press "Search"
  226 + Then I should see "whales and dolphins"
  227 + And I should see "None" within ".search-article-categories-container"
  228 +
  229 + Scenario: show date of last update from original author
  230 + When I search contents for "whales"
  231 + Then I should see "Last update:" within ".search-article-author-changes"
  232 +
  233 + Scenario: show date of last update from another author
  234 + Given the following users
  235 + | login | name |
  236 + | sglaspell | Susan Glaspell |
  237 + And the article "whales and dolphins" is updated by "Susan Glaspell"
  238 + When I search contents for "whales"
  239 + Then show me the page
  240 + Then I should see "by Susan Glaspell at" within ".search-article-author-changes"
  241 +
  242 + Scenario: search articles by category
29 243 Given the following category
30 244 | name |
31   - | Software Livre |
  245 + | Software Livre |
32 246 And the following articles
33 247 | owner | name | body | category |
34 248 | joaosilva | using noosfero | noosfero is a great CMS | software-livre |
35 249 When I go to the search articles page
36   - And I fill in "query" with "software livre"
  250 + And I fill in "query" with "Software"
37 251 And I press "Search"
38 252 Then I should see "using noosfero" within "#search-results"
39 253 And I should not see "bees and butterflies"
40 254 And I should not see "whales and dolphins"
41 255  
  256 + Scenario: show basic info on blog search results
  257 + Given the following blogs
  258 + | owner | name |
  259 + | joaosilva | JSilva blog |
  260 + When I search contents for "JSilva"
  261 + Then I should see "JSilva blog" within ".search-result-title"
  262 + And I should see content inside ".icon-content-blog"
  263 +
  264 + Scenario: show and link last posts on blog search results
  265 + Given the following blogs
  266 + | owner | name |
  267 + | joaosilva | JSilva blog |
  268 + And the following articles
  269 + | owner | parent | name |
  270 + | joaosilva | JSilva blog | post #1 |
  271 + | joaosilva | JSilva blog | post #2 |
  272 + | joaosilva | JSilva blog | post #4 |
  273 + And the following rss feeds
  274 + | joaosilva | JSilva blog | post #3 |
  275 + When I search contents for "JSilva"
  276 + Then I should see "Last posts" within ".search-blog-items"
  277 + And I should see "post #1"
  278 + And I should see "post #2"
  279 + And I should not see "post #3"
  280 + And I should see "post #4"
  281 + When I follow "post #1"
  282 + Then I should be on article "post #1"
  283 +
  284 + Scenario: show empty last posts on blog search results
  285 + Given the following blogs
  286 + | owner | name |
  287 + | joaosilva | JSilva blog |
  288 + When I search contents for "JSilva"
  289 + Then I should see "None" within ".search-blog-items"
  290 +
42 291 Scenario: see default facets when searching
43 292 When I go to the search articles page
44 293 And I fill in "query" with "bees"
45 294 And I press "Search"
46 295 Then I should see "Type" within "#facets-menu"
47   - Then I should see "Published date" within "#facets-menu"
48   - Then I should see "Profile" within "#facets-menu"
49   - Then I should see "Categories" within "#facets-menu"
  296 + And I should see "Published date" within "#facets-menu"
  297 + And I should see "Profile" within "#facets-menu"
  298 + And I should see "Categories" within "#facets-menu"
50 299  
51 300 Scenario: find enterprises without exact query
52 301 When I go to the search articles page
... ... @@ -55,10 +304,7 @@ Feature: search contents
55 304 Then I should see "bees and butterflies" within "#search-results"
56 305  
57 306 Scenario: filter contents by facet
58   - Given the following categories as facets
59   - | name |
60   - | Temáticas |
61   - And the following categories
  307 + Given the following categories
62 308 | name | parent |
63 309 | Software Livre | tematicas |
64 310 | Big Brother | tematicas |
... ... @@ -69,15 +315,16 @@ Feature: search contents
69 315 When I go to the search articles page
70 316 And I fill in "query" with "this is an article"
71 317 And I press "Search"
  318 + Then show me the page
72 319 And I follow "Software Livre" within "#facets-menu"
73 320 Then I should see "noosfero and debian" within "#search-results"
74 321 And I should not see "facebook and 1984"
  322 + # facet should also be de-selectable
  323 + When I follow "remove facet" within ".facet-selected"
  324 + Then I should see "facebook and 1984"
75 325  
76 326 Scenario: remember facet filter when searching new query
77   - Given the following categories as facets
78   - | name |
79   - | Temáticas |
80   - And the following category
  327 + Given the following category
81 328 | name | parent |
82 329 | Software Livre | tematicas |
83 330 And the following articles
... ...
features/search_enterprises.feature
1 1 Feature: search enterprises
2 2 As a noosfero user
3 3 I want to search enterprises
4   - In order to find ones that interest me
  4 + In order to find ones that interest me
5 5  
6 6 Background:
7 7 Given the search index is empty
8 8 And the following enterprises
9   - | identifier | name |
10   - | shop1 | Shoes shop |
11   - | shop2 | Fruits shop |
  9 + | identifier | name | img |
  10 + | shop1 | Shoes shop | shoes |
  11 + | shop2 | Fruits shop | fruits |
12 12 And the following categories as facets
13 13 | name |
14   - | Temáticas |
  14 + | Temáticas |
15 15  
16   - Scenario: show recent enterprises on index (empty query)
  16 + Scenario: show recent enterprises on index
17 17 When I go to the search enterprises page
18 18 Then I should see "Shoes shop" within "#search-results"
  19 + And I should see Shoes shop's profile image
19 20 And I should see "Fruits shop" within "#search-results"
  21 + And I should see Fruits shop's profile image
  22 +
  23 + Scenario: show empty search results
  24 + When I search enterprises for "something unrelated"
  25 + Then I should see "None" within ".search-results-type-empty"
20 26  
21 27 Scenario: simple search for enterprise
22 28 When I go to the search enterprises page
23 29 And I fill in "query" with "shoes"
24 30 And I press "Search"
25   - Then I should see "Shoes shop"
  31 + Then I should see "Shoes shop" within ".only-one-result-box"
  32 + And I should see Shoes shop's profile image
26 33 And I should not see "Fruits shop"
  34 + And I should not see Fruits shop's profile image
  35 +
  36 + Scenario: link to enterprise homepage on search results
  37 + Given I search enterprises for "shoes"
  38 + When I follow "Shoes shop"
  39 + Then I should be on "Shoes shop" homepage
  40 +
  41 + Scenario: show clean enterprise description on search results
  42 + Given the following articles
  43 + | owner | name | body |
  44 + | shop1 | Shoes home | This is the <i>homepage</i> of Shoes shop! It has a very long and pretty vague description, just so we can test wether the system will correctly create an excerpt of this text. We should probably talk about shoes. |
  45 + And the following enterprises
  46 + | identifier | name | description |
  47 + | shop3 | 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. |
  48 + When I search enterprises for "shoes"
  49 + Then I should see "This is the homepage of" within ".search-enterprise-description"
  50 + And I should see "probably talk..." within ".search-enterprise-description"
  51 + And I should see "This clothes shop" within ".search-enterprise-description"
  52 + And I should see "are a re..." within ".search-enterprise-description"
27 53  
28 54 Scenario: see default facets when searching
29 55 When I go to the search enterprises page
... ... @@ -49,7 +75,8 @@ Feature: search enterprises
49 75 And I press "Search"
50 76 Then I should see "Pres. Prudente" within "#facet-menu-f_region"
51 77 And I should see ", SP" within "#facet-menu-f_region"
52   - And I should see "Pres. Prudente, SP" within "#search-results"
  78 + And I should see "City" within ".search-enterprise-region-label"
  79 + And I should see "Pres. Prudente, SP" within ".search-enterprise-region-name"
53 80  
54 81 Scenario: find enterprise by region
55 82 Given the following cities
... ... @@ -62,11 +89,11 @@ Feature: search enterprises
62 89 And I fill in "query" with "Prudente"
63 90 And I press "Search"
64 91 Then I should see "Artesanato PP" within "#search-results"
65   -
  92 +
66 93 Scenario: find enterprise by category
67 94 Given the following categories
68 95 | name |
69   - | Software Livre |
  96 + | Software Livre |
70 97 And the following enterprises
71 98 | identifier | name | category |
72 99 | noosfero | Noosfero | software-livre |
... ... @@ -74,6 +101,19 @@ Feature: search enterprises
74 101 And I fill in "query" with "software"
75 102 And I press "Search"
76 103 Then I should see "Noosfero" within "#search-results"
  104 + And I should see "Software Livre" within ".search-enterprise-category"
  105 +
  106 + Scenario: show category hierarchy on search results
  107 + Given the following categories
  108 + | name | parent |
  109 + | Software Livre | |
  110 + | Rails | software-livre |
  111 + And the following enterprises
  112 + | identifier | name | category |
  113 + | noosfero | Noosfero | Rails |
  114 + When I search enterprises for "Rails"
  115 + Then I should see "Software Livre" within ".search-enterprise-category"
  116 + And I should see "Rails" within ".search-enterprise-category"
77 117  
78 118 Scenario: find enterprises without exact query
79 119 Given the following enterprises
... ... @@ -98,6 +138,9 @@ Feature: search enterprises
98 138 And I follow "Software Livre" within "#facets-menu"
99 139 Then I should see "Noosfero Developers" within "#search-results"
100 140 And I should not see "Facebook Developers"
  141 + # facet should also be de-selectable
  142 + When I follow "remove facet" within ".facet-selected"
  143 + Then I should see "Facebook Developers"
101 144  
102 145 Scenario: remember facet filter when searching new query
103 146 Given the following category
... ...
features/search_people.feature
1 1 Feature: search people
2 2 As a noosfero user
3 3 I want to search people
4   - In order to find ones that interest me
  4 + In order to find ones that interest me
5 5  
6 6 Background:
7 7 Given the search index is empty
... ... @@ -20,12 +20,17 @@ Feature: search people
20 20 And I fill in "query" with "Silva"
21 21 And I press "Search"
22 22 Then I should see "Joao Silva" within "#search-results"
  23 + And I should see "Joao Silva" within ".only-one-result-box"
23 24 And I should not see "Jose Araujo"
24 25  
  26 + Scenario: show empty search results
  27 + When I search people for "something unrelated"
  28 + Then I should see "None" within ".search-results-type-empty"
  29 +
25 30 Scenario: see category facets when searching
26 31 Given the following categories as facets
27 32 | name |
28   - | Temáticas |
  33 + | Temáticas |
29 34 When I go to the search people page
30 35 And I fill in "query" with "joao"
31 36 And I press "Search"
... ... @@ -34,7 +39,7 @@ Feature: search people
34 39 Scenario: search people by category
35 40 Given the following category
36 41 | name |
37   - | Software Livre |
  42 + | Software Livre |
38 43 And the following users
39 44 | login | name | category |
40 45 | linus | Linus Torvalds | software-livre |
... ... @@ -57,10 +62,10 @@ Feature: search people
57 62 Scenario: filter people by facet
58 63 Given the following categories as facets
59 64 | name |
60   - | Temáticas |
  65 + | Temáticas |
61 66 And the following category
62 67 | name | parent |
63   - | Software Livre | tematicas |
  68 + | Software Livre | tematicas |
64 69 And the following users
65 70 | login | name | category |
66 71 | linus | Linus Torvalds | software-livre |
... ... @@ -71,14 +76,17 @@ Feature: search people
71 76 And I follow "Software Livre" within "#facets-menu"
72 77 Then I should see "Linus Torvalds" within "#search-results"
73 78 And I should not see "Other Linus"
  79 + # facet should also be de-selectable
  80 + When I follow "remove facet" within ".facet-selected"
  81 + Then I should see "Other Linus"
74 82  
75 83 Scenario: remember facet filter when searching new query
76 84 Given the following categories as facets
77 85 | name |
78   - | Temáticas |
  86 + | Temáticas |
79 87 And the following category
80 88 | name | parent |
81   - | Software Livre | tematicas |
  89 + | Software Livre | tematicas |
82 90 And the following users
83 91 | login | name | category |
84 92 | linus | Linus Torvalds | software-livre |
... ...
features/search_products.feature
1 1 Feature: search products
2 2 As a noosfero user
3 3 I want to search products
4   - In order to find ones that interest me
  4 + In order to find ones that interest me
5 5  
6 6 Background:
7 7 Given the search index is empty
... ... @@ -13,21 +13,28 @@ Feature: search products
13 13 | name |
14 14 | Development |
15 15 And the following products
16   - | owner | category | name | price |
17   - | colivre-ent | development | social networks consultancy | 1.00 |
18   - | colivre-ent | development | wikis consultancy | 2.00 |
19   -
20   - Scenario: show recent products on index (empty query)
  16 + | owner | category | name | price | img |
  17 + | colivre-ent | development | social networks consultancy | 1.00 | fruits |
  18 + | colivre-ent | development | wikis consultancy | 2.00 | shoes |
  19 +
  20 + Scenario: show recent products on index
21 21 When I go to the search products page
22 22 Then I should see "wikis consultancy" within "#search-results"
23 23 And I should see "social networks consultancy" within "#search-results"
  24 + And I should not see content inside "div.pagination"
  25 + And I should not see content inside "#facets-menu"
  26 +
  27 + Scenario: show empty search results
  28 + When I search products for "something unrelated"
  29 + Then I should see "None" within ".search-results-type-empty"
24 30  
25 31 Scenario: simple search for product
26   - When I go to the search products page
27   - And I fill in "query" with "wikis"
28   - And I press "Search"
  32 + When I search products for "wikis"
29 33 Then I should see "wikis consultancy" within "#search-results"
  34 + And I should see "wikis consultancy" within ".only-one-result-box"
  35 + And I should see wikis consultancy's product image
30 36 And I should not see "social networks consultancy"
  37 + And I should not see social networks consultancy's product image
31 38  
32 39 Scenario: see default facets when searching
33 40 When I go to the search products page
... ... @@ -37,7 +44,7 @@ Feature: search products
37 44 Then I should see "City" within "#facets-menu"
38 45 Then I should see "Qualifiers" within "#facets-menu"
39 46  
40   - Scenario: show percentage (100%) of solidary economy inputs in results
  47 + Scenario: show percentage (100%) of solidary economy inputs in results
41 48 Given the following inputs
42 49 | product | category | solidary |
43 50 | wikis consultancy | development | true |
... ... @@ -45,8 +52,8 @@ Feature: search products
45 52 And I fill in "query" with "wikis"
46 53 And I press "Search"
47 54 Then I should see "100%" within "div.search-product-ecosol-percentage-icon-100"
48   -
49   - Scenario: show percentage (50%) of solidary economy inputs in results
  55 +
  56 + Scenario: show percentage (50%) of solidary economy inputs in results
50 57 Given the following inputs
51 58 | product | category | solidary |
52 59 | wikis consultancy | development | true |
... ... @@ -56,7 +63,7 @@ Feature: search products
56 63 And I press "Search"
57 64 Then I should see "50%" within "div.search-product-ecosol-percentage-icon-50"
58 65  
59   - Scenario: show percentage (75%) of solidary economy inputs in results
  66 + Scenario: show percentage (75%) of solidary economy inputs in results
60 67 Given the following inputs
61 68 | product | category | solidary |
62 69 | wikis consultancy | development | true |
... ... @@ -68,7 +75,7 @@ Feature: search products
68 75 And I press "Search"
69 76 Then I should see "75%" within "div.search-product-ecosol-percentage-icon-75"
70 77  
71   - Scenario: show percentage (25%) of solidary economy inputs in results
  78 + Scenario: show percentage (25%) of solidary economy inputs in results
72 79 Given the following inputs
73 80 | product | category | solidary |
74 81 | wikis consultancy | development | true |
... ... @@ -93,7 +100,7 @@ Feature: search products
93 100 Scenario: search products by category
94 101 Given the following product_category
95 102 | name |
96   - | Software Livre |
  103 + | Software Livre |
97 104 And the following product
98 105 | owner | name | category |
99 106 | colivre-ent | Noosfero | software-livre |
... ... @@ -113,7 +120,7 @@ Feature: search products
113 120 | art-pp | Artesanato PP | Pres. Prudente |
114 121 And the following product_category
115 122 | name |
116   - | Solidária |
  123 + | Solidária |
117 124 And the following product
118 125 | owner | name | category |
119 126 | art-pp | Arte em Madeira | solidaria |
... ... @@ -133,7 +140,7 @@ Feature: search products
133 140 | art-pp | Artesanato PP | Pres. Prudente |
134 141 And the following product_category
135 142 | name |
136   - | Solidária |
  143 + | Solidária |
137 144 And the following product
138 145 | owner | name | category |
139 146 | art-pp | Arte em Madeira | solidaria |
... ... @@ -145,7 +152,7 @@ Feature: search products
145 152 Scenario: find products without exact query
146 153 Given the following product_category
147 154 | name |
148   - | Software Livre |
  155 + | Software Livre |
149 156 And the following products
150 157 | owner | name | category |
151 158 | colivre-ent | Noosfero Social Network Platform | software-livre |
... ... @@ -160,7 +167,7 @@ Feature: search products
160 167 | fb | FB inc. |
161 168 And the following categories as facets
162 169 | name |
163   - | Temáticas |
  170 + | Temáticas |
164 171 And the following product_categories
165 172 | name | parent |
166 173 | Software Livre | tematicas |
... ... @@ -175,6 +182,9 @@ Feature: search products
175 182 And I follow "Software Livre" within "#facets-menu"
176 183 Then I should see "Noosfero Network" within "#search-results"
177 184 And I should not see "Facebook Network"
  185 + # facet should also be de-selectable
  186 + When I follow "remove facet" within ".facet-selected"
  187 + Then I should see "Facebook Network"
178 188  
179 189 Scenario: remember facet filter when searching new query
180 190 Given the following enterprises
... ... @@ -183,7 +193,7 @@ Feature: search products
183 193 | other | Other |
184 194 And the following categories as facets
185 195 | name |
186   - | Temáticas |
  196 + | Temáticas |
187 197 And the following product_categories
188 198 | name | parent |
189 199 | Software Livre | tematicas |
... ... @@ -203,3 +213,8 @@ Feature: search products
203 213 And I press "Search"
204 214 Then I should see "Other open" within "#search-results"
205 215 And I should not see "Other closed"
  216 +
  217 + Scenario: don't search when products are disabled in environment
  218 + Given feature "disable_asset_products" is enabled on environment
  219 + When I go to the search products page
  220 + Then I should not see content inside "#search-results"
... ...
features/step_definitions/custom_webrat_steps.rb
... ... @@ -38,3 +38,11 @@ When /^I fill in &quot;([^\&quot;]*)&quot; with &quot;([^\&quot;]*)&quot; within &quot;([^\&quot;]*)&quot;$/ do |field, value
38 38 content.fill_in(field, :with => value)
39 39 end
40 40 end
  41 +
  42 +When /^I should see content inside "([^\"]+)"$/ do |selector|
  43 + response.should have_selector(selector)
  44 +end
  45 +
  46 +When /^I should not see content inside "([^\"]+)"$/ do |selector|
  47 + response.should_not have_selector(selector)
  48 +end
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -32,6 +32,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
32 32 owner = row.delete("owner")
33 33 domain = row.delete("domain")
34 34 category = row.delete("category")
  35 + img_name = row.delete("img")
35 36 organization = klass.create!(row)
36 37 if owner
37 38 organization.add_admin(Profile[owner])
... ... @@ -49,6 +50,10 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
49 50 cat = Category.find_by_slug category
50 51 organization.categories << cat
51 52 end
  53 + if img_name
  54 + img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png'))
  55 + organization.image = img
  56 + end
52 57 organization.save!
53 58 end
54 59 end
... ... @@ -97,14 +102,16 @@ Given /^the following blocks$/ do |table|
97 102 end
98 103 end
99 104  
100   -Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |content, table|
  105 +Given /^the following (articles|events|blogs|folders|forums|galleries|uploaded files|rss feeds)$/ do |content, table|
101 106 klass = {
102 107 'articles' => TextileArticle,
103 108 'events' => Event,
104 109 'blogs' => Blog,
105 110 'folders' => Folder,
106 111 'forums' => Forum,
107   - 'galleries' => Gallery
  112 + 'galleries' => Gallery,
  113 + 'uploaded files' => UploadedFile,
  114 + 'rss feeds' => RssFeed,
108 115 }[content] || raise("Don't know how to build %s" % content)
109 116 table.hashes.map{|item| item.dup}.each do |item|
110 117 owner_identifier = item.delete("owner")
... ... @@ -113,6 +120,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con
113 120 home = item.delete("homepage")
114 121 language = item.delete("lang")
115 122 category = item.delete("category")
  123 + filename = item.delete("filename")
116 124 translation_of_id = nil
117 125 if item["translation_of"]
118 126 if item["translation_of"] != "nil"
... ... @@ -121,25 +129,28 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con
121 129 end
122 130 item.delete("translation_of")
123 131 end
124   - result = klass.new(item.merge(
  132 + item.merge!(
125 133 :profile => owner,
126 134 :language => language,
127   - :translation_of_id => translation_of_id
128   - ))
129   - if parent
130   - result.parent = Article.find_by_name(parent)
131   - end
132   - if category
133   - cat = Category.find_by_slug category
134   - if cat
135   - result.add_category(cat)
  135 + :translation_of_id => translation_of_id)
  136 + if !filename.blank?
  137 + item.merge!(:uploaded_data => fixture_file_upload("/files/#{filename}.png", 'image/png'))
  138 + end
  139 + result = klass.new(item)
  140 + if parent
  141 + result.parent = Article.find_by_name(parent)
  142 + end
  143 + if category
  144 + cat = Category.find_by_slug category
  145 + if cat
  146 + result.add_category(cat)
  147 + end
  148 + end
  149 + result.save!
  150 + if home == 'true'
  151 + owner.home_page = result
  152 + owner.save!
136 153 end
137   - end
138   - result.save!
139   - if home == 'true'
140   - owner.home_page = result
141   - owner.save!
142   - end
143 154 end
144 155 end
145 156  
... ... @@ -208,7 +219,7 @@ Given /^the following inputs?$/ do |table|
208 219 unit = Unit.find_by_singular(data.delete("unit"))
209 220 solidary = data.delete("solidary")
210 221 input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit,
211   - :is_from_solidarity_economy => solidary))
  222 + :is_from_solidarity_economy => solidary))
212 223 input.update_attributes!(:position => data['position'])
213 224 end
214 225 end
... ... @@ -319,9 +330,9 @@ Given /^feature &quot;(.+)&quot; is (enabled|disabled) on environment$/ do |feature, statu
319 330 end
320 331  
321 332 Given /^organization_approval_method is "(.+)" on environment$/ do |approval_method|
322   - e = Environment.default
323   - e.organization_approval_method = approval_method
324   - e.save
  333 + e = Environment.default
  334 + e.organization_approval_method = approval_method
  335 + e.save
325 336 end
326 337  
327 338 Given /^"(.+)" is a member of "(.+)"$/ do |person,profile|
... ... @@ -503,10 +514,10 @@ end
503 514 Given /^that the default environment have (.+) templates?$/ do |option|
504 515 env = Environment.default
505 516 case option
506   - when 'all profile'
507   - env.create_templates
508   - when 'no Inactive Enterprise'
509   - env.inactive_enterprise_template && env.inactive_enterprise_template.destroy
  517 + when 'all profile'
  518 + env.create_templates
  519 + when 'no Inactive Enterprise'
  520 + env.inactive_enterprise_template && env.inactive_enterprise_template.destroy
510 521 end
511 522 end
512 523  
... ... @@ -621,7 +632,7 @@ Given /^the following cities$/ do |table|
621 632 end
622 633 city = City.create!(:name => item[:name], :environment_id => Environment.default.id)
623 634 city.parent = state
624   - city.save!
  635 + city.save!
625 636 end
626 637 end
627 638  
... ... @@ -629,3 +640,60 @@ When /^I edit my profile$/ do
629 640 visit "/myprofile/#{@current_user}"
630 641 click_link "Edit Profile"
631 642 end
  643 +
  644 +Given /^the following tags$/ do |table|
  645 + table.hashes.each do |item|
  646 + article = Article.find_by_name item[:article]
  647 + article.tag_list.add item[:name]
  648 + article.save!
  649 + end
  650 +end
  651 +
  652 +When /^I search ([^\"]*) for "([^\"]*)"$/ do |asset, query|
  653 + When %{I go to the search #{asset} page}
  654 + And %{I fill in "query" with "#{query}"}
  655 + And %{I press "Search"}
  656 +end
  657 +
  658 +Then /^I should see ([^\"]*)'s product image$/ do |product_name|
  659 + p = Product.find_by_name product_name
  660 + path = url_for(p.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => p, :only_path => true))
  661 + response.should have_selector("div[class~=\"zoomable-image\"] a[href=\"http://#{path}\"]")
  662 +end
  663 +
  664 +Then /^I should not see ([^\"]*)'s product image$/ do |product_name|
  665 + p = Product.find_by_name product_name
  666 + path = url_for(p.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => p, :only_path => true))
  667 + response.should_not have_selector("div[class~=\"zoomable-image\"] a[href=\"http://#{path}\"]")
  668 +end
  669 +
  670 +Then /^I should see ([^\"]*)'s profile image$/ do |name|
  671 + response.should have_selector("img[alt=\"#{name}\"]")
  672 +end
  673 +
  674 +Then /^I should not see ([^\"]*)'s profile image$/ do |name|
  675 + response.should_not have_selector("img[alt=\"#{name}\"]")
  676 +end
  677 +
  678 +Then /^I should see ([^\"]*)'s content image$/ do |name|
  679 + response.should have_selector("img[alt=\"#{name}\"]")
  680 +end
  681 +
  682 +Then /^I should not see ([^\"]*)'s content image$/ do |name|
  683 + response.should_not have_selector("img[alt=\"#{name}\"]")
  684 +end
  685 +
  686 +Then /^I should see ([^\"]*)'s community image$/ do |name|
  687 + response.should have_selector("img[alt=\"#{name}\"]")
  688 +end
  689 +
  690 +Then /^I should not see ([^\"]*)'s community image$/ do |name|
  691 + response.should_not have_selector("img[alt=\"#{name}\"]")
  692 +end
  693 +
  694 +Given /^the article "([^\"]*)" is updated by "([^\"]*)"$/ do |article, person|
  695 + a = Article.find_by_name article
  696 + p = Person.find_by_name person
  697 + a.last_changed_by = p
  698 + a.save!
  699 +end
... ...
features/support/paths.rb
... ... @@ -7,7 +7,7 @@ module NavigationHelpers
7 7 #
8 8 def path_to(page_name)
9 9 case page_name
10   -
  10 +
11 11 when /the homepage/
12 12 '/'
13 13  
... ... @@ -15,12 +15,12 @@ module NavigationHelpers
15 15 page_name
16 16  
17 17 when /article "([^"]+)"\s*$/
18   - url_for( Article.find_by_name($1).url )
  18 + url_for(Article.find_by_name($1).url.merge({:only_path => true}))
19 19  
20 20 when /edit "(.+)" by (.+)/
21 21 article_id = Person[$2].articles.find_by_slug($1.to_slug).id
22 22 "/myprofile/#{$2}/cms/edit/#{article_id}"
23   -
  23 +
24 24 when /edit (.*Block) of (.+)/
25 25 owner = Profile[$2]
26 26 klass = $1.constantize
... ... @@ -89,8 +89,8 @@ module NavigationHelpers
89 89 '/myprofile/%s/manage_products/new' % Profile.find_by_name($1).identifier
90 90  
91 91 when /^(.+)'s page of product (.*)$/
92   - enterprise = Profile.find_by_name($1)
93   - product = enterprise.products.find_by_name($2)
  92 + enterprise = Profile.find_by_name($1)
  93 + product = enterprise.products.find_by_name($2)
94 94 '/myprofile/%s/manage_products/show/%s' % [enterprise.identifier, product.id]
95 95  
96 96 when /^(.*)'s products page$/
... ... @@ -99,11 +99,14 @@ module NavigationHelpers
99 99 when /^chat$/
100 100 '/chat'
101 101  
102   - # Add more mappings here.
103   - # Here is a more fancy example:
104   - #
105   - # when /^(.*)'s profile page$/i
106   - # user_profile_path(User.find_by_login($1))
  102 + when /^(.+)'s tag page/
  103 + '/tag/%s' % $1
  104 +
  105 + # Add more mappings here.
  106 + # Here is a more fancy example:
  107 + #
  108 + # when /^(.*)'s profile page$/i
  109 + # user_profile_path(User.find_by_login($1))
107 110  
108 111 else
109 112 raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
... ...
test/fixtures/files/auxi.jpg 0 → 100644

81.2 KB

test/fixtures/files/fruits.png 0 → 100644

180 KB

test/fixtures/files/shoes.png 0 → 100644

92.9 KB

test/fixtures/files/tux.png 0 → 100644

13.9 KB