From 0ffb25193b3d72fd5842ea7b5b8cd6c1b8812816 Mon Sep 17 00:00:00 2001 From: Rafael Martins Date: Sat, 5 May 2012 19:52:09 -0300 Subject: [PATCH] Updated features and views for searchable models --- app/helpers/search_helper.rb | 2 +- app/views/map_balloon/profile.rhtml | 2 +- app/views/search/_article_description.rhtml | 4 +++- app/views/search/_event.rhtml | 42 +++++++++++++++++++++--------------------- app/views/search/_product.rhtml | 2 +- app/views/search/_profile.rhtml | 73 +++++++++++++++++++++++++++++++++++-------------------------------------- app/views/search/products.rhtml | 38 ++++++++++++++++++++++---------------- features/search.feature | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- features/search_communities.feature | 29 ++++++++++++++++++++--------- features/search_contents.feature | 291 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- features/search_enterprises.feature | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- features/search_people.feature | 22 +++++++++++++++------- features/search_products.feature | 55 +++++++++++++++++++++++++++++++++++-------------------- features/step_definitions/custom_webrat_steps.rb | 8 ++++++++ features/step_definitions/noosfero_steps.rb | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- features/support/paths.rb | 23 +++++++++++++---------- test/fixtures/files/auxi.jpg | Bin 0 -> 83111 bytes test/fixtures/files/fruits.png | Bin 0 -> 183846 bytes test/fixtures/files/shoes.png | Bin 0 -> 95133 bytes test/fixtures/files/tux.png | Bin 0 -> 14222 bytes 20 files changed, 637 insertions(+), 195 deletions(-) create mode 100644 test/fixtures/files/auxi.jpg create mode 100644 test/fixtures/files/fruits.png create mode 100644 test/fixtures/files/shoes.png create mode 100644 test/fixtures/files/tux.png diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 29573fb..1ce7df2 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -157,7 +157,7 @@ module SearchHelper ret.map do |label, name, url| content_tag('div', content_tag('span', label, :class => 'facet-selected-label') + content_tag('span', name, :class => 'facet-selected-name') + - link_to('', url, :class => 'facet-selected-remove'), :class => 'facet-selected') + link_to('', url, :class => 'facet-selected-remove', :title => 'remove facet'), :class => 'facet-selected') end.join end diff --git a/app/views/map_balloon/profile.rhtml b/app/views/map_balloon/profile.rhtml index 97be683..0dff4d4 100644 --- a/app/views/map_balloon/profile.rhtml +++ b/app/views/map_balloon/profile.rhtml @@ -16,7 +16,7 @@ <% unless @profile.address.nil? %> <%= _('Address: ') + @profile.address %>
<% end %> - <% unless @profile.products.empty? %> + <% if @profile.respond_to?(:products) and !@profile.products.blank? %> <%= _('Products/Services: ') + @profile.products.map{|i| link_to(i.name, :controller => 'manage_products', :profile => @profile.identifier, :action => 'show', :id => i.id)}.join(', ') %>
<% end %> <% if @profile.respond_to?(:distance) and !@profile.distance.nil? %> diff --git a/app/views/search/_article_description.rhtml b/app/views/search/_article_description.rhtml index 9df30c8..cec29d1 100644 --- a/app/views/search/_article_description.rhtml +++ b/app/views/search/_article_description.rhtml @@ -5,7 +5,9 @@ <% if !article.body.blank? %> <% description = strip_tags(article.body.to_s) %> - <% description = excerpt(description, description.first(3), 200).gsub!(/\s{2,}/, ' ') %> + <% description.gsub!(/\s{2,}/, ' ') %> + <% description = excerpt(description, description.first(3), 200) %> + <%= description %> <% else %> <%= _('None') %> diff --git a/app/views/search/_event.rhtml b/app/views/search/_event.rhtml index a95dfb1..eacbf2e 100644 --- a/app/views/search/_event.rhtml +++ b/app/views/search/_event.rhtml @@ -1,25 +1,25 @@
  • - <%= link_to(event.title, event.url, :class => "search-result-title") %> -
    - <%= render :partial => 'image', :object => event %> -
    - - <% if event.start_date %> - - - - - <% end %> - <% if event.end_date %> - - - - - <% end %> +<%= link_to(event.title, event.url, :class => "search-result-title") %> +
    + <%= render :partial => 'image', :object => event %> +
    +
    <%= _('Start date') %><%= event.start_date %>
    <%= _('End date') %><%= event.end_date %>
    + <% if event.start_date %> + + + + + <% end %> + <% if event.end_date %> + + + + + <% end %> - <%= render :partial => 'article_common', :object => event %> -
    <%= _('Start date') %><%= event.start_date %>
    <%= _('End date') %><%= event.end_date %>
    - <%= render :partial => 'article_last_change', :object => event %> + <%= render :partial => 'article_common', :object => event %> + +<%= render :partial => 'article_last_change', :object => event %> -
    +
  • diff --git a/app/views/search/_product.rhtml b/app/views/search/_product.rhtml index 25b4f91..142b511 100644 --- a/app/views/search/_product.rhtml +++ b/app/views/search/_product.rhtml @@ -30,7 +30,7 @@ <% title = product.inputs.map{ |i| '
    ' + '
    ' + i.product_category.name + '
    ' + - price_span(i.price_per_unit*i.amount_used, :class => 'search-product-input-price') + + price_span(i.cost, :class => 'search-product-input-price') + '
    ' }.join('') %> <% title += product.price_details.map{ |p| '
    ' + diff --git a/app/views/search/_profile.rhtml b/app/views/search/_profile.rhtml index 26f4720..4ac34da 100644 --- a/app/views/search/_profile.rhtml +++ b/app/views/search/_profile.rhtml @@ -1,46 +1,43 @@
  • - <% if @empty_query or @results.size > 1 or !profile.enterprise? %> - <%= profile_image_link profile, :portrait, 'div' %> - <% else %> -
    -
    - <%= profile_image_link profile, :portrait, 'div' %> +<% if @empty_query or @results.size > 1 or !profile.enterprise? %> + <%= profile_image_link profile, :portrait, 'div' %> +<% else %> +
    +
    + <%= profile_image_link profile, :portrait, 'div' %> +
    +
    + <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %> +
    + <% if profile.description %> + <% body_stripped = strip_tags(profile.description) %> + <% elsif profile.home_page and profile.home_page.body %> + <% body_stripped = strip_tags(profile.home_page.body) %> + <% end %> + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
    -
    - <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %> -
    - <% if profile.description %> - <% body_stripped = strip_tags(profile.description) %> - <% elsif profile.home_page and profile.home_page.body %> - <% body_stripped = strip_tags(profile.home_page.body) %> - <% end %> - <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> -
    -
    - <%= _("City") %> - <% if profile.region %> - <%= city_with_state(profile.region) %> - <% end %> -
    - <% if !profile.description.blank? %> -
    <%= profile.description %>

    +
    + <%= _("City") %> + <% if profile.region %> + <%= city_with_state(profile.region) %> <% end %> +
    -
    - <% profile.top_level_categorization.each do |parent, children| %> - <% if parent.name != "Territórios" %> -
    - <%= parent.name %> - - <%= children.collect(&:name).join(', ') %> - -
    - <% end %> +
    + <% profile.top_level_categorization.each do |parent, children| %> + <% if parent.name != "Territórios" %> +
    + <%= parent.name %> + + <%= children.collect(&:name).join(', ') %> + +
    <% end %> -
    + <% end %>
    - -
    - <% end %> + +
    +
    +<% end %>
  • diff --git a/app/views/search/products.rhtml b/app/views/search/products.rhtml index 6babe53..ddec0b3 100644 --- a/app/views/search/products.rhtml +++ b/app/views/search/products.rhtml @@ -1,22 +1,28 @@ -<%= search_page_title( @titles[:products], @category ) %> +<% if @environment.settings[:disable_asset_products_enabled] %> + Product search disabled +<% else %> -
    - <% if !@empty_query %> - <% button_bar do %> - <%= display_map_list_button %> + <%= search_page_title( @titles[:products], @category ) %> + +
    + <% if !@empty_query %> + <% button_bar do %> + <%= display_map_list_button %> + <% end %> + <%= facets_menu(:products, @facets) %> <% end %> - <%= facets_menu(:products, @facets) %> - <% end %> -
    +
    + +
    + <%= render :partial => 'search_form', :locals => { :hint => _('Type the product, service, city or qualifier desired') } %> + <%= render :partial => 'results_header' %> -
    - <%= render :partial => 'search_form', :locals => { :hint => _('Type the product, service, city or qualifier desired') } %> - <%= render :partial => 'results_header' %> + <%= display_results(true) %> + <% if !@one_page and params[:display] != 'map' %> + <%= pagination_links @results[:products] %> + <% end %> +
    - <%= display_results(true) %> - <% if !@one_page and params[:display] != 'map' %> - <%= pagination_links @results[:products] %> - <% end %> -
    +<% end %>
    diff --git a/features/search.feature b/features/search.feature index 3a32b60..43af82d 100644 --- a/features/search.feature +++ b/features/search.feature @@ -7,12 +7,22 @@ Feature: search Given the search index is empty And feature "disable_asset_products" is disabled on environment - Scenario: search with empty results + Scenario: show empty results in all enabled assets Given I go to the search page And I fill in "query" with "Anything" And I press "Search" - Then I should see "None" within ".multiple-results-boxes" - And I should see "None" within ".search-results-empty" + Then I should see "People" within ".search-results-people" + And I should see "None" within ".search-results-people" + And I should see "Communities" within ".search-results-communities" + And I should see "None" within ".search-results-communities" + And I should see "Enterprises" within ".search-results-enterprises" + And I should see "None" within ".search-results-enterprises" + And I should see "Contents" within ".search-results-articles" + And I should see "None" within ".search-results-articles" + And I should see "Products" within ".search-results-products" + And I should see "None" within ".search-results-products" + And I should see "Events" within ".search-results-events" + And I should see "None" within ".search-results-events" Scenario: simple search for person Given the following users @@ -22,18 +32,42 @@ Feature: search When I go to the search page And I fill in "query" with "Silva" And I press "Search" - Then I should see "Joao Silva" within "div.search-results-people" + Then I should see "Joao Silva" within ".common-profile-list-block" And I should not see "Jose Araujo" + Scenario: show link to see all results + Given the following users + | login | name | + | joaosilva | Joao Silva | + And the following articles + | owner | name | + | joaosilva | article #1 | + | joaosilva | article #2 | + | joaosilva | article #3 | + | joaosilva | article #4 | + | joaosilva | article #5 | + | joaosilva | article #6 | + | joaosilva | article #7 | + | joaosilva | article #8 | + | joaosilva | article #9 | + When I go to the search page + And I fill in "query" with "article" + And I press "Search" + Then I should see "article #8" within ".search-results-articles" + And I should not see "article #9" within ".search-results-articles" + And I should see "see all (9)" + When I follow "see all (9)" + Then I should be on the search articles page + Scenario: simple search for community Given the following communities - | identifier | name | - | boring-community | Boring community | - | fancy-community | Fancy community | + | identifier | name | img | + | boring-community | Boring community | semterrinha | + | fancy-community | Fancy community | agrotox | And I go to the search page And I fill in "query" with "fancy" And I press "Search" - Then I should see "Fancy community" within "div.search-results-communities" + Then I should see "Fancy community" within ".common-profile-list-block" And I should not see "Boring community" Scenario: simple search for enterprise @@ -44,7 +78,7 @@ Feature: search And I go to the search page And I fill in "query" with "shoes" And I press "Search" - Then I should see "Shoes shop" within "div.search-results-enterprises" + Then I should see "Shoes shop" within ".common-profile-list-block" And I should not see "Fruits shop" Scenario: simple search for content @@ -94,11 +128,11 @@ Feature: search Scenario: search different types of entities with the same query Given the following enterprises - | identifier | name | + | identifier | name | | colivre_dev | Colivre - Noosfero dev. | And the following communities | identifier | name | - | noosfero-users | Noosfero users | + | noosfero-users | Noosfero users | And the following product_categories | name | | Development | diff --git a/features/search_communities.feature b/features/search_communities.feature index 2c45cdd..5af6944 100644 --- a/features/search_communities.feature +++ b/features/search_communities.feature @@ -1,35 +1,43 @@ Feature: search communities As a noosfero user I want to search communities - In order to find ones that interest me + In order to find ones that interest me Background: Given the search index is empty And the following category | name | - | social network | + | social network | And the following community - | identifier | name | category | - | noosfero | Noosfero Community | social-network | + | identifier | name | category | img | + | noosfero | Noosfero Community | social-network | noosfero-network | - Scenario: show recent communities on index (empty query) + Scenario: show recent communities on index Given the following community - | identifier | name | category | - | linux | Linux Community | social-network | + | identifier | name | category | img | + | linux | Linux Community | social-network | tux | When I go to the search communities page Then I should see "Noosfero Community" within "#search-results" + And I should see Noosfero Community's community image And I should see "Linux Community" within "#search-results" + And I should see Linux Community's community image + + Scenario: show empty search results + When I search communities for "something unrelated" + Then I should see "None" within ".search-results-type-empty" Scenario: simple search for community When I go to the search communities page And I fill in "query" with "noosfero" And I press "Search" Then I should see "Noosfero Community" within "#search-results" + And I should see "Noosfero Community" within ".only-one-result-box" + And I should see Noosfero Community's community image Scenario: search communities by category Given the following category | name | - | Software Livre | + | Software Livre | And the following community | identifier | name | category | | noos-comm | Noosfero Community | software-livre | @@ -44,7 +52,7 @@ Feature: search communities | Temáticas | And the following category | name | parent | - | Software Livre | tematicas | + | Software Livre | tematicas | And the following community | identifier | name | category | | linux | Linux Community | software-livre | @@ -80,6 +88,9 @@ Feature: search communities And I follow "Software Livre" within "#facets-menu" Then I should see "Noosfero Developers" within "#search-results" And I should not see "Facebook Developers" + # facet should also be de-selectable + When I follow "remove facet" within ".facet-selected" + Then I should see "Facebook Developers" Scenario: remember facet filter when searching new query Given the following categories as facets diff --git a/features/search_contents.feature b/features/search_contents.feature index 7470e72..e2cc385 100644 --- a/features/search_contents.feature +++ b/features/search_contents.feature @@ -1,7 +1,7 @@ Feature: search contents As a noosfero user I want to search contents - In order to find ones that interest me + In order to find ones that interest me Background: Given the search index is empty @@ -9,44 +9,293 @@ Feature: search contents | login | name | | joaosilva | Joao Silva | And the following articles - | owner | name | body | + | owner | name | body | | joaosilva | bees and butterflies | this is an article about bees and butterflies | | joaosilva | whales and dolphins | this is an article about whales and dolphins | + And the following categories as facets + | name | + | Temáticas | - Scenario: show recent contents on index (empty query) - When I go to the search contents page + Scenario: show recent content on index + When I go to the search articles page Then I should see "bees and butterflies" within "#search-results" And I should see "whales and dolphins" within "#search-results" - Scenario: simple search for content - When I go to the search contents page + Scenario: simple search for text articles + When I search contents for "whales" + Then I should see "whales and dolphins" within ".search-text-article-item" + And I should see "whales and dolphins" within ".only-one-result-box" + And I should not see "bees and butterflies" + And I should see content inside ".icon-content-textile-article" + When I follow "whales and dolphins" + Then I should be on article "whales and dolphins" + + Scenario: simple search for event + Given the following communities + | identifier | name | + | nice-people | Nice people | + And the following events + | owner | name | start_date | end_date | + | nice-people | Group meeting | 2009-01-01 | 2009-01-02 | + | nice-people | John Doe's birthday | 2009-09-01 | 2009-09-02 | + When I search contents for "birthday" + Then I should see "John Doe's birthday" within ".search-event-item" + And I should see "Start date" + And I should see "2009-09-01" + And I should see "End date" + And I should see "2009-09-02" + And I should not see "Group meeting" + When I follow "John Doe's birthday" + Then I should be on article "John Doe's birthday" + + Scenario: simple search for folder + Given the following folders + | owner | name | + | joaosilva | Music Folder | + | joaosilva | Videos Folder | + When I search contents for "Music" + Then I should see "Music Folder" within ".search-folder-item" + And I should see "None" within ".search-folder-items" + And I should not see "Videos Folder" + When I follow "Music Folder" + Then I should be on article "Music Folder" + + Scenario: simple search for forum + Given the following forums + | owner | name | + | joaosilva | Games Forum | + | joaosilva | Movies Folder | + When I search contents for "Games" + Then I should see "Games Forum" within ".search-forum-item" + And I should see "None" within ".search-forum-items" + And I should not see "Movies Folder" + When I follow "Games Forum" + Then I should be on article "Games Forum" + + Scenario: simple search for gallery + Given the following galleries + | owner | name | + | joaosilva | Landscape Photos | + | joaosilva | People Photos | + When I search contents for "Landscape" + Then I should see "Landscape Photos" within ".search-gallery" + And I should not see "People Photos" + When I follow "Landscape Photos" + + Scenario: simple search for uploaded file + Given the following uploaded files + | owner | name | filename | + | joaosilva | Uploaded Executable | rails | + | joaosilva | Uploaded Spreadsheet | rails | + When I search contents for "Executable" + Then I should see "Uploaded Executable" within ".search-uploaded-file-item" + And I should not see "Uploaded Spreadsheet" + When I follow "Uploaded Executable" + Then I should be on content "Uploaded Executable" + + Scenario: show event search results without end date + Given the following communities + | identifier | name | + | nice-people | Nice people | + And the following events + | owner | name | + | nice-people | John Doe's birthday | + When I search contents for "birthday" + Then I should see "John Doe's birthday" within ".search-event-item" + And I should not see "End date" + + Scenario: show and link last items on folder search results + Given the following folders + | owner | name | + | joaosilva | Music Folder | + And the following articles + | owner | name | parent | + | joaosilva | Steven Wilson | Music Folder | + | joaosilva | Porcupine Tree | Music Folder | + | joaosilva | Blackfield | Music Folder | + When I search contents for "Music" + Then I should see "Last items" within ".search-folder-items" + And I should see "Blackfield" + And I should see "Porcupine Tree" + And I should see "Steven Wilson" + When I follow "Porcupine Tree" + Then I should be on article "Porcupine Tree" + + Scenario: show and link last topics on forum search results + Given the following forums + | owner | name | + | joaosilva | Games Forum | + And the following articles + | owner | name | parent | + | joaosilva | The Old Republic | Games Forum | + | joaosilva | Mass Effect 3 | Games Forum | + | joaosilva | The Witcher 2 | Games Forum | + | joaosilva | Syndicate | Games Forum | + And the following rss feeds + | joaosilva | Diablo 3 News Feed | Games Forum | + When I search contents for "Games" + Then I should see "Last topics" within ".search-forum-items" + And I should see "Syndicate" + And I should see "The Witcher 2" + And I should see "Mass Effect 3" + And I should not see "The Old Republic" + And I should not see "Diablo 3" + When I follow "The Witcher 2" + Then I should be on article "The Witcher 2" + + Scenario: link to parent in uploaded file search results + Given the following folders + | owner | name | + | joaosilva | Folder for Uploaded Files | + Given the following uploaded files + | owner | name | parent | filename | + | joaosilva | Uploaded Executable 2 | Folder for Uploaded Files | rails | + When I search contents for "Executable" + Then I should see "Folder for Uploaded Files" within ".search-uploaded-file-parent" + When I follow "Folder for Uploaded Files" + Then I should be on content "Folder for Uploaded Files" + + Scenario: link to author on search results + When I go to the search articles page And I fill in "query" with "whales" And I press "Search" - Then I should see "whales and dolphins" within "#search-results" - And I should not see "bees and butterflies" + Then I should see "Author" within ".search-article-author" + Then I should see "Joao Silva" within ".search-article-author-name" + When I follow "Joao Silva" + Then I should be on Joao Silva's profile + + Scenario: show clean description excerpt on search results + Given the following articles + | owner | name | body | + | joaosilva | Herreninsel | The island Herreninsel, 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. | + When I go to the search articles page + And I fill in "query" with "island" + And I press "Search" + Then I should see "Description" within ".search-article-description" + And I should see "The island Herreninsel, with" within ".search-article-description" + And I should see "and Kraut..." within ".search-article-description" + + Scenario: show empty description on search results + Given the following articles + | owner | name | body | + | joaosilva | Herreninsel | | + When I go to the search articles page + And I fill in "query" with "Herreninsel" + And I press "Search" + Then I should see "None" within ".search-article-description" - Scenario: search contents by category + Scenario: link to tags on search results + Given the following tags + | article | name | + | bees and butterflies | Hymenoptera | + | bees and butterflies | Lepidoptera | + When I go to the search articles page + And I fill in "query" with "bees" + And I press "Search" + Then I should see "Tags" within ".search-article-tags" + And I should see "Hymenoptera" within ".search-article-tags" + And I should see "Lepidoptera" within ".search-article-tags" + When I follow "Hymenoptera" + Then I should be on Hymenoptera's tag page + + Scenario: show empty tags in search results + When I go to the search articles page + And I fill in "query" with "dolphins" + And I press "Search" + Then I should see "None" within ".search-article-tags" + + Scenario: link to categories on search results + Given the following category + | name | + | Soviet ice hockey players | + And the following articles + | owner | name | body | category | + | joaosilva | Sergei Sorokin | Retired ice hockey player | Soviet ice hockey players | + When I go to the search articles page + And I fill in "query" with "hockey" + And I press "Search" + Then I should see "Categories" within ".search-article-categories" + And I should see "Soviet ice hockey players" within ".search-article-categories" + When I follow "Soviet ice hockey players" + Then I should be on Joao Silva's profile + + Scenario: show empty categories on search results + When I go to the search articles page + And I fill in "query" with "whales" + And I press "Search" + Then I should see "whales and dolphins" + And I should see "None" within ".search-article-categories-container" + + Scenario: show date of last update from original author + When I search contents for "whales" + Then I should see "Last update:" within ".search-article-author-changes" + + Scenario: show date of last update from another author + Given the following users + | login | name | + | sglaspell | Susan Glaspell | + And the article "whales and dolphins" is updated by "Susan Glaspell" + When I search contents for "whales" + Then show me the page + Then I should see "by Susan Glaspell at" within ".search-article-author-changes" + + Scenario: search articles by category Given the following category | name | - | Software Livre | + | Software Livre | And the following articles | owner | name | body | category | | joaosilva | using noosfero | noosfero is a great CMS | software-livre | When I go to the search articles page - And I fill in "query" with "software livre" + And I fill in "query" with "Software" And I press "Search" Then I should see "using noosfero" within "#search-results" And I should not see "bees and butterflies" And I should not see "whales and dolphins" + Scenario: show basic info on blog search results + Given the following blogs + | owner | name | + | joaosilva | JSilva blog | + When I search contents for "JSilva" + Then I should see "JSilva blog" within ".search-result-title" + And I should see content inside ".icon-content-blog" + + Scenario: show and link last posts on blog search results + Given the following blogs + | owner | name | + | joaosilva | JSilva blog | + And the following articles + | owner | parent | name | + | joaosilva | JSilva blog | post #1 | + | joaosilva | JSilva blog | post #2 | + | joaosilva | JSilva blog | post #4 | + And the following rss feeds + | joaosilva | JSilva blog | post #3 | + When I search contents for "JSilva" + Then I should see "Last posts" within ".search-blog-items" + And I should see "post #1" + And I should see "post #2" + And I should not see "post #3" + And I should see "post #4" + When I follow "post #1" + Then I should be on article "post #1" + + Scenario: show empty last posts on blog search results + Given the following blogs + | owner | name | + | joaosilva | JSilva blog | + When I search contents for "JSilva" + Then I should see "None" within ".search-blog-items" + Scenario: see default facets when searching When I go to the search articles page And I fill in "query" with "bees" And I press "Search" Then I should see "Type" within "#facets-menu" - Then I should see "Published date" within "#facets-menu" - Then I should see "Profile" within "#facets-menu" - Then I should see "Categories" within "#facets-menu" + And I should see "Published date" within "#facets-menu" + And I should see "Profile" within "#facets-menu" + And I should see "Categories" within "#facets-menu" Scenario: find enterprises without exact query When I go to the search articles page @@ -55,10 +304,7 @@ Feature: search contents Then I should see "bees and butterflies" within "#search-results" Scenario: filter contents by facet - Given the following categories as facets - | name | - | Temáticas | - And the following categories + Given the following categories | name | parent | | Software Livre | tematicas | | Big Brother | tematicas | @@ -69,15 +315,16 @@ Feature: search contents When I go to the search articles page And I fill in "query" with "this is an article" And I press "Search" + Then show me the page And I follow "Software Livre" within "#facets-menu" Then I should see "noosfero and debian" within "#search-results" And I should not see "facebook and 1984" + # facet should also be de-selectable + When I follow "remove facet" within ".facet-selected" + Then I should see "facebook and 1984" Scenario: remember facet filter when searching new query - Given the following categories as facets - | name | - | Temáticas | - And the following category + Given the following category | name | parent | | Software Livre | tematicas | And the following articles diff --git a/features/search_enterprises.feature b/features/search_enterprises.feature index 2714c37..2273ae8 100644 --- a/features/search_enterprises.feature +++ b/features/search_enterprises.feature @@ -1,29 +1,55 @@ Feature: search enterprises As a noosfero user I want to search enterprises - In order to find ones that interest me + In order to find ones that interest me Background: Given the search index is empty And the following enterprises - | identifier | name | - | shop1 | Shoes shop | - | shop2 | Fruits shop | + | identifier | name | img | + | shop1 | Shoes shop | shoes | + | shop2 | Fruits shop | fruits | And the following categories as facets | name | - | Temáticas | + | Temáticas | - Scenario: show recent enterprises on index (empty query) + Scenario: show recent enterprises on index When I go to the search enterprises page Then I should see "Shoes shop" within "#search-results" + And I should see Shoes shop's profile image And I should see "Fruits shop" within "#search-results" + And I should see Fruits shop's profile image + + Scenario: show empty search results + When I search enterprises for "something unrelated" + Then I should see "None" within ".search-results-type-empty" Scenario: simple search for enterprise When I go to the search enterprises page And I fill in "query" with "shoes" And I press "Search" - Then I should see "Shoes shop" + Then I should see "Shoes shop" within ".only-one-result-box" + And I should see Shoes shop's profile image And I should not see "Fruits shop" + And I should not see Fruits shop's profile image + + Scenario: link to enterprise homepage on search results + Given I search enterprises for "shoes" + When I follow "Shoes shop" + Then I should be on "Shoes shop" homepage + + Scenario: show clean enterprise description on search results + Given the following articles + | owner | name | body | + | shop1 | Shoes home | This is the homepage 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. | + And the following enterprises + | identifier | name | description | + | shop3 | 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 "shoes" + Then I should see "This is the homepage of" within ".search-enterprise-description" + And I should see "probably talk..." within ".search-enterprise-description" + And I should see "This clothes shop" within ".search-enterprise-description" + And I should see "are a re..." within ".search-enterprise-description" Scenario: see default facets when searching When I go to the search enterprises page @@ -49,7 +75,8 @@ Feature: search enterprises And I press "Search" Then I should see "Pres. Prudente" within "#facet-menu-f_region" And I should see ", SP" within "#facet-menu-f_region" - And I should see "Pres. Prudente, SP" within "#search-results" + And I should see "City" within ".search-enterprise-region-label" + And I should see "Pres. Prudente, SP" within ".search-enterprise-region-name" Scenario: find enterprise by region Given the following cities @@ -62,11 +89,11 @@ Feature: search enterprises And I fill in "query" with "Prudente" And I press "Search" Then I should see "Artesanato PP" within "#search-results" - + Scenario: find enterprise by category Given the following categories | name | - | Software Livre | + | Software Livre | And the following enterprises | identifier | name | category | | noosfero | Noosfero | software-livre | @@ -74,6 +101,19 @@ Feature: search enterprises And I fill in "query" with "software" And I press "Search" Then I should see "Noosfero" within "#search-results" + And I should see "Software Livre" within ".search-enterprise-category" + + Scenario: show category hierarchy on search results + Given the following categories + | name | parent | + | Software Livre | | + | Rails | software-livre | + And the following enterprises + | identifier | name | category | + | noosfero | Noosfero | Rails | + When I search enterprises for "Rails" + Then I should see "Software Livre" within ".search-enterprise-category" + And I should see "Rails" within ".search-enterprise-category" Scenario: find enterprises without exact query Given the following enterprises @@ -98,6 +138,9 @@ Feature: search enterprises And I follow "Software Livre" within "#facets-menu" Then I should see "Noosfero Developers" within "#search-results" And I should not see "Facebook Developers" + # facet should also be de-selectable + When I follow "remove facet" within ".facet-selected" + Then I should see "Facebook Developers" Scenario: remember facet filter when searching new query Given the following category diff --git a/features/search_people.feature b/features/search_people.feature index 0b5653a..4e525d0 100644 --- a/features/search_people.feature +++ b/features/search_people.feature @@ -1,7 +1,7 @@ Feature: search people As a noosfero user I want to search people - In order to find ones that interest me + In order to find ones that interest me Background: Given the search index is empty @@ -20,12 +20,17 @@ Feature: search people And I fill in "query" with "Silva" And I press "Search" Then I should see "Joao Silva" within "#search-results" + And I should see "Joao Silva" within ".only-one-result-box" And I should not see "Jose Araujo" + Scenario: show empty search results + When I search people for "something unrelated" + Then I should see "None" within ".search-results-type-empty" + Scenario: see category facets when searching Given the following categories as facets | name | - | Temáticas | + | Temáticas | When I go to the search people page And I fill in "query" with "joao" And I press "Search" @@ -34,7 +39,7 @@ Feature: search people Scenario: search people by category Given the following category | name | - | Software Livre | + | Software Livre | And the following users | login | name | category | | linus | Linus Torvalds | software-livre | @@ -57,10 +62,10 @@ Feature: search people Scenario: filter people by facet Given the following categories as facets | name | - | Temáticas | + | Temáticas | And the following category | name | parent | - | Software Livre | tematicas | + | Software Livre | tematicas | And the following users | login | name | category | | linus | Linus Torvalds | software-livre | @@ -71,14 +76,17 @@ Feature: search people And I follow "Software Livre" within "#facets-menu" Then I should see "Linus Torvalds" within "#search-results" And I should not see "Other Linus" + # facet should also be de-selectable + When I follow "remove facet" within ".facet-selected" + Then I should see "Other Linus" Scenario: remember facet filter when searching new query Given the following categories as facets | name | - | Temáticas | + | Temáticas | And the following category | name | parent | - | Software Livre | tematicas | + | Software Livre | tematicas | And the following users | login | name | category | | linus | Linus Torvalds | software-livre | diff --git a/features/search_products.feature b/features/search_products.feature index afeb19c..e7aa631 100644 --- a/features/search_products.feature +++ b/features/search_products.feature @@ -1,7 +1,7 @@ Feature: search products As a noosfero user I want to search products - In order to find ones that interest me + In order to find ones that interest me Background: Given the search index is empty @@ -13,21 +13,28 @@ Feature: search products | name | | Development | And the following products - | owner | category | name | price | - | colivre-ent | development | social networks consultancy | 1.00 | - | colivre-ent | development | wikis consultancy | 2.00 | - - Scenario: show recent products on index (empty query) + | owner | category | name | price | img | + | colivre-ent | development | social networks consultancy | 1.00 | fruits | + | colivre-ent | development | wikis consultancy | 2.00 | shoes | + + Scenario: show recent products on index When I go to the search products page Then I should see "wikis consultancy" within "#search-results" And I should see "social networks consultancy" within "#search-results" + And I should not see content inside "div.pagination" + And I should not see content inside "#facets-menu" + + Scenario: show empty search results + When I search products for "something unrelated" + Then I should see "None" within ".search-results-type-empty" Scenario: simple search for product - When I go to the search products page - And I fill in "query" with "wikis" - And I press "Search" + When I search products for "wikis" Then I should see "wikis consultancy" within "#search-results" + And I should see "wikis consultancy" within ".only-one-result-box" + And I should see wikis consultancy's product image And I should not see "social networks consultancy" + And I should not see social networks consultancy's product image Scenario: see default facets when searching When I go to the search products page @@ -37,7 +44,7 @@ Feature: search products Then I should see "City" within "#facets-menu" Then I should see "Qualifiers" within "#facets-menu" - Scenario: show percentage (100%) of solidary economy inputs in results + Scenario: show percentage (100%) of solidary economy inputs in results Given the following inputs | product | category | solidary | | wikis consultancy | development | true | @@ -45,8 +52,8 @@ Feature: search products And I fill in "query" with "wikis" And I press "Search" Then I should see "100%" within "div.search-product-ecosol-percentage-icon-100" - - Scenario: show percentage (50%) of solidary economy inputs in results + + Scenario: show percentage (50%) of solidary economy inputs in results Given the following inputs | product | category | solidary | | wikis consultancy | development | true | @@ -56,7 +63,7 @@ Feature: search products And I press "Search" Then I should see "50%" within "div.search-product-ecosol-percentage-icon-50" - Scenario: show percentage (75%) of solidary economy inputs in results + Scenario: show percentage (75%) of solidary economy inputs in results Given the following inputs | product | category | solidary | | wikis consultancy | development | true | @@ -68,7 +75,7 @@ Feature: search products And I press "Search" Then I should see "75%" within "div.search-product-ecosol-percentage-icon-75" - Scenario: show percentage (25%) of solidary economy inputs in results + Scenario: show percentage (25%) of solidary economy inputs in results Given the following inputs | product | category | solidary | | wikis consultancy | development | true | @@ -93,7 +100,7 @@ Feature: search products Scenario: search products by category Given the following product_category | name | - | Software Livre | + | Software Livre | And the following product | owner | name | category | | colivre-ent | Noosfero | software-livre | @@ -113,7 +120,7 @@ Feature: search products | art-pp | Artesanato PP | Pres. Prudente | And the following product_category | name | - | Solidária | + | Solidária | And the following product | owner | name | category | | art-pp | Arte em Madeira | solidaria | @@ -133,7 +140,7 @@ Feature: search products | art-pp | Artesanato PP | Pres. Prudente | And the following product_category | name | - | Solidária | + | Solidária | And the following product | owner | name | category | | art-pp | Arte em Madeira | solidaria | @@ -145,7 +152,7 @@ Feature: search products Scenario: find products without exact query Given the following product_category | name | - | Software Livre | + | Software Livre | And the following products | owner | name | category | | colivre-ent | Noosfero Social Network Platform | software-livre | @@ -160,7 +167,7 @@ Feature: search products | fb | FB inc. | And the following categories as facets | name | - | Temáticas | + | Temáticas | And the following product_categories | name | parent | | Software Livre | tematicas | @@ -175,6 +182,9 @@ Feature: search products And I follow "Software Livre" within "#facets-menu" Then I should see "Noosfero Network" within "#search-results" And I should not see "Facebook Network" + # facet should also be de-selectable + When I follow "remove facet" within ".facet-selected" + Then I should see "Facebook Network" Scenario: remember facet filter when searching new query Given the following enterprises @@ -183,7 +193,7 @@ Feature: search products | other | Other | And the following categories as facets | name | - | Temáticas | + | Temáticas | And the following product_categories | name | parent | | Software Livre | tematicas | @@ -203,3 +213,8 @@ Feature: search products And I press "Search" Then I should see "Other open" within "#search-results" And I should not see "Other closed" + + Scenario: don't search when products are disabled in environment + Given feature "disable_asset_products" is enabled on environment + When I go to the search products page + Then I should not see content inside "#search-results" diff --git a/features/step_definitions/custom_webrat_steps.rb b/features/step_definitions/custom_webrat_steps.rb index 48d8e7f..ae5b846 100644 --- a/features/step_definitions/custom_webrat_steps.rb +++ b/features/step_definitions/custom_webrat_steps.rb @@ -38,3 +38,11 @@ When /^I fill in "([^\"]*)" with "([^\"]*)" within "([^\"]*)"$/ do |field, value content.fill_in(field, :with => value) end end + +When /^I should see content inside "([^\"]+)"$/ do |selector| + response.should have_selector(selector) +end + +When /^I should not see content inside "([^\"]+)"$/ do |selector| + response.should_not have_selector(selector) +end diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index ab23876..0a4384a 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -32,6 +32,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | owner = row.delete("owner") domain = row.delete("domain") category = row.delete("category") + img_name = row.delete("img") organization = klass.create!(row) if owner organization.add_admin(Profile[owner]) @@ -49,6 +50,10 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | cat = Category.find_by_slug category organization.categories << cat end + if img_name + img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png')) + organization.image = img + end organization.save! end end @@ -97,14 +102,16 @@ Given /^the following blocks$/ do |table| end end -Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |content, table| +Given /^the following (articles|events|blogs|folders|forums|galleries|uploaded files|rss feeds)$/ do |content, table| klass = { 'articles' => TextileArticle, 'events' => Event, 'blogs' => Blog, 'folders' => Folder, 'forums' => Forum, - 'galleries' => Gallery + 'galleries' => Gallery, + 'uploaded files' => UploadedFile, + 'rss feeds' => RssFeed, }[content] || raise("Don't know how to build %s" % content) table.hashes.map{|item| item.dup}.each do |item| owner_identifier = item.delete("owner") @@ -113,6 +120,7 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con home = item.delete("homepage") language = item.delete("lang") category = item.delete("category") + filename = item.delete("filename") translation_of_id = nil if item["translation_of"] if item["translation_of"] != "nil" @@ -121,25 +129,28 @@ Given /^the following (articles|events|blogs|folders|forums|galleries)$/ do |con end item.delete("translation_of") end - result = klass.new(item.merge( + item.merge!( :profile => owner, :language => language, - :translation_of_id => translation_of_id - )) - if parent - result.parent = Article.find_by_name(parent) - end - if category - cat = Category.find_by_slug category - if cat - result.add_category(cat) + :translation_of_id => translation_of_id) + if !filename.blank? + item.merge!(:uploaded_data => fixture_file_upload("/files/#{filename}.png", 'image/png')) + end + result = klass.new(item) + if parent + result.parent = Article.find_by_name(parent) + end + if category + cat = Category.find_by_slug category + if cat + result.add_category(cat) + end + end + result.save! + if home == 'true' + owner.home_page = result + owner.save! end - end - result.save! - if home == 'true' - owner.home_page = result - owner.save! - end end end @@ -208,7 +219,7 @@ Given /^the following inputs?$/ do |table| unit = Unit.find_by_singular(data.delete("unit")) solidary = data.delete("solidary") input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit, - :is_from_solidarity_economy => solidary)) + :is_from_solidarity_economy => solidary)) input.update_attributes!(:position => data['position']) end end @@ -319,9 +330,9 @@ Given /^feature "(.+)" is (enabled|disabled) on environment$/ do |feature, statu end Given /^organization_approval_method is "(.+)" on environment$/ do |approval_method| - e = Environment.default - e.organization_approval_method = approval_method - e.save + e = Environment.default + e.organization_approval_method = approval_method + e.save end Given /^"(.+)" is a member of "(.+)"$/ do |person,profile| @@ -503,10 +514,10 @@ end Given /^that the default environment have (.+) templates?$/ do |option| env = Environment.default case option - when 'all profile' - env.create_templates - when 'no Inactive Enterprise' - env.inactive_enterprise_template && env.inactive_enterprise_template.destroy + when 'all profile' + env.create_templates + when 'no Inactive Enterprise' + env.inactive_enterprise_template && env.inactive_enterprise_template.destroy end end @@ -621,7 +632,7 @@ Given /^the following cities$/ do |table| end city = City.create!(:name => item[:name], :environment_id => Environment.default.id) city.parent = state - city.save! + city.save! end end @@ -629,3 +640,60 @@ When /^I edit my profile$/ do visit "/myprofile/#{@current_user}" click_link "Edit Profile" end + +Given /^the following tags$/ do |table| + table.hashes.each do |item| + article = Article.find_by_name item[:article] + article.tag_list.add item[:name] + article.save! + end +end + +When /^I search ([^\"]*) for "([^\"]*)"$/ do |asset, query| + When %{I go to the search #{asset} page} + And %{I fill in "query" with "#{query}"} + And %{I press "Search"} +end + +Then /^I should see ([^\"]*)'s product image$/ do |product_name| + p = Product.find_by_name product_name + path = url_for(p.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => p, :only_path => true)) + response.should have_selector("div[class~=\"zoomable-image\"] a[href=\"http://#{path}\"]") +end + +Then /^I should not see ([^\"]*)'s product image$/ do |product_name| + p = Product.find_by_name product_name + path = url_for(p.enterprise.public_profile_url.merge(:controller => 'manage_products', :action => 'show', :id => p, :only_path => true)) + response.should_not have_selector("div[class~=\"zoomable-image\"] a[href=\"http://#{path}\"]") +end + +Then /^I should see ([^\"]*)'s profile image$/ do |name| + response.should have_selector("img[alt=\"#{name}\"]") +end + +Then /^I should not see ([^\"]*)'s profile image$/ do |name| + response.should_not have_selector("img[alt=\"#{name}\"]") +end + +Then /^I should see ([^\"]*)'s content image$/ do |name| + response.should have_selector("img[alt=\"#{name}\"]") +end + +Then /^I should not see ([^\"]*)'s content image$/ do |name| + response.should_not have_selector("img[alt=\"#{name}\"]") +end + +Then /^I should see ([^\"]*)'s community image$/ do |name| + response.should have_selector("img[alt=\"#{name}\"]") +end + +Then /^I should not see ([^\"]*)'s community image$/ do |name| + response.should_not have_selector("img[alt=\"#{name}\"]") +end + +Given /^the article "([^\"]*)" is updated by "([^\"]*)"$/ do |article, person| + a = Article.find_by_name article + p = Person.find_by_name person + a.last_changed_by = p + a.save! +end diff --git a/features/support/paths.rb b/features/support/paths.rb index 4b5db2a..4244a7b 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -7,7 +7,7 @@ module NavigationHelpers # def path_to(page_name) case page_name - + when /the homepage/ '/' @@ -15,12 +15,12 @@ module NavigationHelpers page_name when /article "([^"]+)"\s*$/ - url_for( Article.find_by_name($1).url ) + url_for(Article.find_by_name($1).url.merge({:only_path => true})) when /edit "(.+)" by (.+)/ article_id = Person[$2].articles.find_by_slug($1.to_slug).id "/myprofile/#{$2}/cms/edit/#{article_id}" - + when /edit (.*Block) of (.+)/ owner = Profile[$2] klass = $1.constantize @@ -89,8 +89,8 @@ module NavigationHelpers '/myprofile/%s/manage_products/new' % Profile.find_by_name($1).identifier when /^(.+)'s page of product (.*)$/ - enterprise = Profile.find_by_name($1) - product = enterprise.products.find_by_name($2) + enterprise = Profile.find_by_name($1) + product = enterprise.products.find_by_name($2) '/myprofile/%s/manage_products/show/%s' % [enterprise.identifier, product.id] when /^(.*)'s products page$/ @@ -99,11 +99,14 @@ module NavigationHelpers when /^chat$/ '/chat' - # Add more mappings here. - # Here is a more fancy example: - # - # when /^(.*)'s profile page$/i - # user_profile_path(User.find_by_login($1)) + when /^(.+)'s tag page/ + '/tag/%s' % $1 + + # Add more mappings here. + # Here is a more fancy example: + # + # when /^(.*)'s profile page$/i + # user_profile_path(User.find_by_login($1)) else raise "Can't find mapping from \"#{page_name}\" to a path.\n" + diff --git a/test/fixtures/files/auxi.jpg b/test/fixtures/files/auxi.jpg new file mode 100644 index 0000000..3d4ba9d Binary files /dev/null and b/test/fixtures/files/auxi.jpg differ diff --git a/test/fixtures/files/fruits.png b/test/fixtures/files/fruits.png new file mode 100644 index 0000000..aa78d00 Binary files /dev/null and b/test/fixtures/files/fruits.png differ diff --git a/test/fixtures/files/shoes.png b/test/fixtures/files/shoes.png new file mode 100644 index 0000000..9b24acf Binary files /dev/null and b/test/fixtures/files/shoes.png differ diff --git a/test/fixtures/files/tux.png b/test/fixtures/files/tux.png new file mode 100644 index 0000000..10931a9 Binary files /dev/null and b/test/fixtures/files/tux.png differ -- libgit2 0.21.2