From c635810b8e3d62ea8b39412677bd1257bd91ec83 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 14 Dec 2011 20:28:04 -0200 Subject: [PATCH] Some fixes on redesigned Catalog --- app/views/catalog/_index.rhtml | 1 - app/views/catalog/index.rhtml | 41 +++++++++++++++-------------------------- app/views/content_viewer/_enterprise_homepage.rhtml | 2 +- app/views/layouts/_javascript.rhtml | 3 ++- features/browse_catalogs.feature | 91 ++++++++++++++++++++++++++++++++++++++++--------------------------------------------------- features/browse_enterprises.feature | 8 ++------ features/comment.feature | 70 +++++++++++++++++++++++++++++++++------------------------------------- features/comment_reply.feature | 71 ++++++++++++++++++++++++++++++++++------------------------------------- features/enterprise_homepage.feature | 47 +---------------------------------------------- features/manage_enterprises.feature | 13 ++++++------- features/manage_products.feature | 31 +++++++++++++++---------------- features/profile_domain.feature | 12 ++++++------ features/step_definitions/noosfero_steps.rb | 12 +----------- public/javascripts/catalog.js | 59 +++++++++++++++++++++++++++++++---------------------------- test/functional/catalog_controller_test.rb | 8 -------- test/functional/maps_controller_test.rb | 12 ++++++------ test/unit/enterprise_homepage_test.rb | 41 ----------------------------------------- 17 files changed, 193 insertions(+), 329 deletions(-) delete mode 120000 app/views/catalog/_index.rhtml diff --git a/app/views/catalog/_index.rhtml b/app/views/catalog/_index.rhtml deleted file mode 120000 index 3dd5e55..0000000 --- a/app/views/catalog/_index.rhtml +++ /dev/null @@ -1 +0,0 @@ -index.rhtml \ No newline at end of file diff --git a/app/views/catalog/index.rhtml b/app/views/catalog/index.rhtml index bb5f5f0..a0e7ccb 100644 --- a/app/views/catalog/index.rhtml +++ b/app/views/catalog/index.rhtml @@ -37,26 +37,22 @@ <% if product.description %>
  • <%= _('description') %> -
    -
    -
    <%= txt2html(product.description || '') %>
    -
    +
    +
    <%= txt2html(product.description || '') %>
  • <% end %> <% if product.is_open_price? %>
  • <%= _('price composition') %> -
    -
    -
    - <% product.inputs.each do |i| %> -
    -
    <%= i.product_category.name %>
    - <%= price_span i.price_per_unit * i.amount_used, :class => 'search-product-input-price' %> -
    - <% end %> -
    +
    +
    + <% product.inputs.each do |i| %> +
    +
    <%= i.product_category.name %>
    + <%= price_span i.price_per_unit * i.amount_used, :class => 'search-product-input-price' %> +
    + <% end %>
  • <% end %> @@ -64,13 +60,11 @@ <% if product.any_inputs_details? %>
  • <%= _('inputs and raw materials') %> -
    -
    -
    - <% product.inputs.each do |i| %> -
    <%= "#{i.amount_used} #{i.unit.singular} #{_('of')} #{i.product_category.name}" if i.has_all_price_details? %>
    - <% end %> -
    +
    +
    + <% product.inputs.each do |i| %> +
    <%= "#{i.amount_used} #{i.unit.singular} #{_('of')} #{i.product_category.name}" if i.has_all_price_details? %>
    + <% end %>
  • <% end %> @@ -81,10 +75,6 @@
    <%= render :partial => 'shared/product/qualifiers', :locals => {:product => product} %>
    <% end %> -
  • - <%# profile.enabled? ? link_to_product_category(product.product_category) : (product.product_category ? product.product_category.full_name(' → ') : _('Uncategorized product')) %> -
  • - <% extra_content_list.map do |content| %>
  • <%= content %>
  • <% end %> @@ -98,4 +88,3 @@ <%= pagination_links @products, :params => {:controller => :catalog, :action => :index, :profile => profile.identifier} %> - diff --git a/app/views/content_viewer/_enterprise_homepage.rhtml b/app/views/content_viewer/_enterprise_homepage.rhtml index 5f79be1..154890e 100644 --- a/app/views/content_viewer/_enterprise_homepage.rhtml +++ b/app/views/content_viewer/_enterprise_homepage.rhtml @@ -1,3 +1,3 @@ <%= display_profile_info enterprise_homepage.profile %>
    <%= enterprise_homepage.body %>
    -<%= render :partial => 'catalog/index' unless enterprise_homepage.profile.environment.enabled?('disable_products_for_enterprises') %> +<%= render :file => 'catalog/index' unless enterprise_homepage.profile.environment.enabled?('disable_products_for_enterprises') %> diff --git a/app/views/layouts/_javascript.rhtml b/app/views/layouts/_javascript.rhtml index 63fa7a0..8640c18 100644 --- a/app/views/layouts/_javascript.rhtml +++ b/app/views/layouts/_javascript.rhtml @@ -1,3 +1,4 @@ -<%= javascript_include_tag :defaults, 'jquery-latest.js', 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery.cookie', 'reflection', 'add-and-join', 'jquery.tokeninput', 'report-abuse','colorbox', 'jquery-validation/jquery.validate', :cache => 'cache-general' %> +<%= javascript_include_tag :defaults, 'jquery-latest.js', 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery.cookie', 'reflection', 'add-and-join', 'jquery.tokeninput', 'report-abuse','colorbox', 'jquery-validation/jquery.validate', 'catalog', :cache => 'cache-general' %> + <% language = FastGettext.locale %> <%= javascript_include_tag 'jquery-validation/localization/messages_'+language, 'jquery-validation/localization/methods_'+language %> diff --git a/features/browse_catalogs.feature b/features/browse_catalogs.feature index 924d0af..21c76eb 100644 --- a/features/browse_catalogs.feature +++ b/features/browse_catalogs.feature @@ -14,16 +14,16 @@ Feature: browse catalogs | name | | categ1 | | food | + And I am on /catalog/artebonito Scenario: display titles - Given I am on /catalog/artebonito Then I should see "Associação de Artesanato de Bonito" And I should see "Products/Services" within "#product-list" Scenario: display the simplest possible product - Given the following simple products - | owner | category | - | artebonito | categ1 | + Given the following products + | owner | category | + | artebonito | categ1 | And I am on /catalog/artebonito Then I should see "categ1" within "li.product-link" And I should see "No image" within "li.product-big" @@ -34,8 +34,8 @@ Feature: browse catalogs And I should not see "price composition" Scenario: display a simple product without price - Given the following simple products - | owner | category | name | + Given the following products + | owner | category | name | | artebonito | categ1 | Produto1 | And I am on /catalog/artebonito Then I should see "Produto1" within "li.product-link" @@ -47,8 +47,8 @@ Feature: browse catalogs And I should not see "price composition" Scenario: display a simple product without details - Given the following simple products - | owner | category | name | price | + Given the following products + | owner | category | name | price | | artebonito | categ1 | Produto1 | 50.00 | And I am on /catalog/artebonito Then I should see "Produto1" within "li.product-link" @@ -60,19 +60,17 @@ Feature: browse catalogs And I should not see "qualifiers" And I should not see "price composition" -#FIXME: test different units - Scenario: product name links to product page - Given the following simple products - | owner | category | name | price | + Given the following products + | owner | category | name | price | | artebonito | categ1 | Produto1 | 50.00 | And I am on /catalog/artebonito When I follow "Produto1" within "li.product-link" Then I should be taken to "Produto1" product page Scenario: display product with custom image - Given the following simple products - | owner | category | name | price | img | + Given the following products + | owner | category | name | price | img | | artebonito | categ1 | Agrotox | 12.34 | agrotox | And I am on /catalog/artebonito Then I should see "Agrotox" within "li.product-link" @@ -85,16 +83,16 @@ Feature: browse catalogs And I should not see "price composition" Scenario: image links to product page - Given the following simple products - | owner | category | name | price | img | + Given the following products + | owner | category | name | price | img | | artebonito | categ1 | Agrotox | 12.34 | agrotox | And I am on /catalog/artebonito When I follow "Agrotox" within "#product-image-link" Then I should be taken to "Agrotox" product page Scenario: display product with discount - Given the following simple products - | owner | category | name | price | discount | img | + Given the following products + | owner | category | name | price | discount | img | | artebonito | categ1 | Semterrinha | 99.99 | 12.34 | semterrinha | And I am on /catalog/artebonito Then I should see "Semterrinha" within "li.product-link" @@ -107,23 +105,22 @@ Feature: browse catalogs @selenium Scenario: display description button when needed (but not the description) - Given the following simple products - | owner | category | name | price | description | - | artebonito | categ1 | Produto2 | 12.34 | A small description for a product that doesn't exist. | + Given the following products + | owner | category | name | price | description | + | artebonito | categ1 | Produto2 | 12.34 | A small description for a product that doesn't exist. | And I am on /catalog/artebonito Then I should see "Produto2" within "li.product-link" And I should see "12.34" within "span.product-price" And I should see "description" within "#product-description-button" And the "product-description-button" should be visible -# Doesn't make a lot of sense, but I have to check the text and the visibility separately And I should see "A small description" within "#product-description" And the "product-description" should not be visible @selenium Scenario: display description when button is clicked - Given the following simple products - | owner | category | name | price | description | - | artebonito | categ1 | Produto3 | 12.34 | A small description for a product that doesn't exist. | + Given the following products + | owner | category | name | price | description | + | artebonito | categ1 | Produto3 | 12.34 | A small description for a product that doesn't exist. | And I am on /catalog/artebonito And I reload and wait for the page When I click "product-description-button" @@ -131,8 +128,8 @@ Feature: browse catalogs And the "product-description" should be visible Scenario: display unavailable product - Given the following simple products - | owner | category | name | price | available | + Given the following products + | owner | category | name | price | available | | artebonito | categ1 | Prod3 | 12.34 | false | And I am on /catalog/artebonito Then I should see "Prod3" within "li.not-available" @@ -148,8 +145,8 @@ Feature: browse catalogs And the following certifiers | name | qualifiers | | Colivre | Organic | - And the following simple products - | owner | category | name | price | qualifier | + And the following products + | owner | category | name | price | qualifier | | artebonito | categ1 | Banana | 0.99 | Organic | And I am on /catalog/artebonito Then I should see "Banana" within "li.product-link" @@ -161,9 +158,9 @@ Feature: browse catalogs #FIXME: this will only be available after AI1413 # @selenium # Scenario: display price composition button (but not inputs) -# Given the following simple product -# | owner | category | name | price | -# | artebonito | food | Bananada | 10.00 | +# Given the following product +# | owner | category | name | price | +# | artebonito | food | Bananada | 10.00 | # And the following input # | product | category | price_per_unit | amount_used | # | Bananada | food | 0.99 | 5 | @@ -180,9 +177,9 @@ Feature: browse catalogs #FIXME: this will only be available after AI1413 # @selenium # Scenario: display price composition when button is clicked -# Given the following simple product -# | owner | category | name | price | -# | artebonito | food | Bananada | 10.00 | +# Given the following product +# | owner | category | name | price | +# | artebonito | food | Bananada | 10.00 | # And the following input # | product | category | price_per_unit | amount_used | # | Bananada | food | 0.99 | 5 | @@ -195,14 +192,14 @@ Feature: browse catalogs @selenium Scenario: display inputs and raw materials button - Given the following simple product - | owner | category | name | price | - | artebonito | food | Vitamina | 17.99 | + Given the following product + | owner | category | name | price | + | artebonito | food | Vitamina | 17.99 | And the following unit | name | plural | | Liter | Liters | And the following input - | product | category | price_per_unit | amount_used | unit | + | product | category | price_per_unit | amount_used | unit | | Vitamina | food | 1.45 | 7 | Liter | And I am on /catalog/artebonito And I reload and wait for the page @@ -215,25 +212,17 @@ Feature: browse catalogs @selenium Scenario: display inputs and raw materials description - Given the following simple product - | owner | category | name | price | - | artebonito | food | Vitamina | 17.99 | + Given the following product + | owner | category | name | price | + | artebonito | food | Vitamina | 17.99 | And the following unit | name | plural | | Liter | Liters | And the following input - | product | category | price_per_unit | amount_used | unit | + | product | category | price_per_unit | amount_used | unit | | Vitamina | food | 1.45 | 7 | Liter | And I am on /catalog/artebonito And I reload and wait for the page When I click "#inputs-button" Then the "#inputs-description" should be visible And I should see "7.0 Liter of food" within "#inputs-description" - -#FIXME: pagination tests are on manage_products featuRe -#FIXME: check unit and functional tests for possible wrong-placed 'features -#FIXME: test unavailable product with more details -#FIXME: test more than one qualifier -#FIXME: put And I am on /catalog/artebonito on the Background -#FIXME: test more than one input and different units -#FIXME: test the product order diff --git a/features/browse_enterprises.feature b/features/browse_enterprises.feature index 5fe5e60..c0fb19e 100644 --- a/features/browse_enterprises.feature +++ b/features/browse_enterprises.feature @@ -14,15 +14,14 @@ Scenario: show all enterprises | identifier | name | | shop2 | Fruits Shop | Given I am on /assets/enterprises - Then I should see "Enterprises" + Then I should see "Enterprises" And I should see "Shoes Shop" And I should see "Fruits Shop" Scenario: show profile links button Given I am on /assets/enterprises Then I should see "Profile links" within "a.enterprise-trigger" -# And I should not see "Products" - And I should not see "Members" + And I should not see "Members" And I should not see "Agenda" @selenium @@ -37,8 +36,5 @@ Scenario: show profile links when clicked Scenario: go to catalog when click on products link Given I am on /assets/enterprises When I follow "Profile links" -# And I follow "Products" within "ul.menu-submenu-list" -# FIXME: 'Products' is a common link, may end up following the wrong one And I follow "Products" and wait Then I should be exactly on /catalog/shop1 - diff --git a/features/comment.feature b/features/comment.feature index 1c989f6..41b5991 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -24,16 +24,15 @@ Feature: comment When I press "Post comment" Then I should not see "Hey ho, let's go" -# This fails because of the captcha -# @selenium -# Scenario: post a comment while not authenticated -# Given I am on /booking/article-to-comment -# And I fill in "Name" with "Joey Ramone" -# And I fill in "e-mail" with "joey@ramones.com" -# And I fill in "Title" with "Hey ho, let's go!" -# And I fill in "Enter your comment" with "Hey ho, let's go!" -# When I press "Post comment" -# Then I should see "Hey ho, let's go" + @selenium + Scenario: post a comment while not authenticated + Given I am on /booking/article-to-comment + And I fill in "Name" with "Joey Ramone" + And I fill in "e-mail" with "joey@ramones.com" + And I fill in "Title" with "Hey ho, let's go!" + And I fill in "Enter your comment" with "Hey ho, let's go!" + When I press "Post comment" + Then I should see "Hey ho, let's go" @selenium Scenario: post comment while authenticated @@ -56,26 +55,24 @@ Feature: comment When I press "Post comment" Then I should be exactly on /booking/rails.png?view=true -#FIXME: only one error comes up at a time, not both -# @selenium -# Scenario: show error messages when make a blank comment -# Given I am logged in as "booking" -# And I am on /booking/article-to-comment -# When I press "Post comment" -# Then I should see "Title can't be blank" -# And I should see "Body can't be blank" + @selenium + Scenario: show error messages when make a blank comment + Given I am logged in as "booking" + And I am on /booking/article-to-comment + When I press "Post comment" + Then I should see "Title can't be blank" + And I should see "Body can't be blank" -#FIXME: fails because of the captcha -# @selenium -# Scenario: disable post comment button -# Given I am on /booking/article-to-comment -# And I fill in "Name" with "Joey Ramone" -# And I fill in "e-mail" with "joey@ramones.com" -# And I fill in "Title" with "Hey ho, let's go!" -# And I fill in "Enter your comment" with "Hey ho, let's go!" -# When I press "Post comment" -# Then the "value.Post comment" button should not be enabled -# And I should see "Hey ho, let's go" + @selenium + Scenario: disable post comment button + Given I am on /booking/article-to-comment + And I fill in "Name" with "Joey Ramone" + And I fill in "e-mail" with "joey@ramones.com" + And I fill in "Title" with "Hey ho, let's go!" + And I fill in "Enter your comment" with "Hey ho, let's go!" + When I press "Post comment" + Then the "value.Post comment" button should not be enabled + And I should see "Hey ho, let's go" @selenium Scenario: render comment form and go to bottom @@ -85,11 +82,10 @@ Feature: comment And I should be exactly on /booking/article-with-comment And I should be moved to anchor "comment_form" -#FIXME: fails because of the captcha -# @selenium -# Scenario: keep comments field filled while trying to do a comment -# Given I am on /booking/article-with-comment -# And I fill in "Name" with "Joey Ramone" -# When I press "Post comment" -# Then the "Name" field should contain "Joey Ramone" -# And I should see "errors prohibited" + @selenium + Scenario: keep comments field filled while trying to do a comment + Given I am on /booking/article-with-comment + And I fill in "Name" with "Joey Ramone" + When I press "Post comment" + Then the "Name" field should contain "Joey Ramone" + And I should see "errors prohibited" diff --git a/features/comment_reply.feature b/features/comment_reply.feature index 1d92254..f812543 100644 --- a/features/comment_reply.feature +++ b/features/comment_reply.feature @@ -25,15 +25,14 @@ Feature: comment Then I should not see "Enter your comment" within "div.comment-balloon" And I should see "Reply" within "div.comment-balloon" -#FIXME: fails because only one error message comes up at a time -# @selenium -# Scenario: show error messages when make a blank comment reply -# Given I am logged in as "booking" -# And I go to /booking/article-to-comment -# And I follow "Reply" within ".comment-balloon" -# When I press "Post comment" within ".comment-balloon" -# Then I should see "Title can't be blank" within "div.comment_reply" -# And I should see "Body can't be blank" within "div.comment_reply" + @selenium + Scenario: show error messages when make a blank comment reply + Given I am logged in as "booking" + And I go to /booking/article-to-comment + And I follow "Reply" within ".comment-balloon" + When I press "Post comment" within ".comment-balloon" + Then I should see "Title can't be blank" within "div.comment_reply" + And I should see "Body can't be blank" within "div.comment_reply" @selenium Scenario: not show any reply form by default @@ -63,32 +62,30 @@ Feature: comment Then there should be 1 "comment_form" within "comment_reply" And I should see "Enter your comment" within "div.comment_reply.opened" -#FIXME: fails because of the captcha -# @selenium -# Scenario: reply a comment -# Given I go to /booking/another-article -# And I follow "Reply" within ".comment-balloon" -# And I fill in "Name" within "comment-balloon" with "Joey" -# And I fill in "e-mail" within "comment-balloon" with "joey@ramones.com" -# And I fill in "Title" within "comment-balloon" with "Hey ho, let's go!" -# And I fill in "Enter your comment" within "comment-balloon" with "Hey ho, let's go!" -# When I press "Post comment" within ".comment-balloon" -# Then I should see "Hey ho, let's go" within "ul.comment-replies" -# And there should be 1 "comment-replies" within "article-comment" + @selenium + Scenario: reply a comment + Given I go to /booking/another-article + And I follow "Reply" within ".comment-balloon" + And I fill in "Name" within "comment-balloon" with "Joey" + And I fill in "e-mail" within "comment-balloon" with "joey@ramones.com" + And I fill in "Title" within "comment-balloon" with "Hey ho, let's go!" + And I fill in "Enter your comment" within "comment-balloon" with "Hey ho, let's go!" + When I press "Post comment" within ".comment-balloon" + Then I should see "Hey ho, let's go" within "ul.comment-replies" + And there should be 1 "comment-replies" within "article-comment" -#FIXME: fails because of the captcha -# @selenium -# Scenario: redirect to right place after reply a picture comment -# Given the following files -# | owner | file | mime | -# | booking | rails.png | image/png | -# And the following comment -# | article | author | title | body | -# | rails.png | booking | root comment | this comment is not a reply | -# Given I am logged in as "booking" -# And I go to /booking/rails.png?view=true -# And I follow "Reply" within ".comment-balloon" -# And I fill in "Title" within "comment-balloon" with "Hey ho, let's go!" -# And I fill in "Enter your comment" within "comment-balloon" with "Hey ho, let's go!" -# When I press "Post comment" within ".comment-balloon" -# Then I should be exactly on /booking/rails.png?view=true + @selenium + Scenario: redirect to right place after reply a picture comment + Given the following files + | owner | file | mime | + | booking | rails.png | image/png | + And the following comment + | article | author | title | body | + | rails.png | booking | root comment | this comment is not a reply | + Given I am logged in as "booking" + And I go to /booking/rails.png?view=true + And I follow "Reply" within ".comment-balloon" + And I fill in "Title" within "comment-balloon" with "Hey ho, let's go!" + And I fill in "Enter your comment" within "comment-balloon" with "Hey ho, let's go!" + When I press "Post comment" within ".comment-balloon" + Then I should be exactly on /booking/rails.png?view=true diff --git a/features/enterprise_homepage.feature b/features/enterprise_homepage.feature index 169a599..4bcf9c2 100644 --- a/features/enterprise_homepage.feature +++ b/features/enterprise_homepage.feature @@ -20,63 +20,18 @@ Feature: enterprise homepage | soap | And the following product | name | category | owner | - | Natural Handmade | soap | mayhem | + | Natural Handmade | soap | mayhem | -# should 'display profile info' do -# e = Enterprise.create!(:name => 'my test enterprise', :identifier => 'mytestenterprise', :contact_email => 'ent@noosfero.foo.bar', :contact_phone => '5555 5555') -# a = EnterpriseHomepage.new(:name => 'article homepage') -# e.articles << a -# result = a.to_html -# assert_match /ent@noosfero.foo.bar/, result -# assert_match /5555 5555/, result -# end - Scenario: display profile info When I go to /mayhem/homepage Then I should see "queen@workerbees.org" And I should see "(288) 555-0153" -# should 'display products list' do -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise') -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_match /Product test/, result -# end - Scenario: display products list When I go to /mayhem/homepage Then I should see "Natural Handmade" -# should 'not display products list if environment do not let' do -# e = Environment.default -# e.enable('disable_products_for_enterprises') -# e.save! -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise', :environment_id => e.id) -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_no_match /Product test/, result -# end - -# FIXME: not working -# Scenario: not display products list if environment do not let -# Given feature "disable_products_for_enterprises" is enabled on environment -# When I go to /mayhem/homepage -# Then I should not see "Natural Handmade" - -# should 'display link to product' do -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise') -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_match /\/test_enterprise\/manage_products\/show\/#{prod.id}/, result -# end - Scenario: display link to product When I go to /mayhem/homepage And I follow "Natural Handmade" diff --git a/features/manage_enterprises.feature b/features/manage_enterprises.feature index 954c2ee..070fd46 100644 --- a/features/manage_enterprises.feature +++ b/features/manage_enterprises.feature @@ -11,13 +11,12 @@ Feature: manage enterprises | identifier | name | owner | | tangerine-dream | Tangerine Dream | joaosilva | -#FIXME: falha pois o clique em "My enterprises" não faz o popup aparecer -# @selenium -# Scenario: seeing my enterprises on menu -# Given I am logged in as "joaosilva" -# Then I should see "My enterprises" link -# When I follow "My enterprises" and wait -# Then I should see "Tangerine Dream" linking to "/myprofile/tangerine-dream" + @selenium + Scenario: seeing my enterprises on menu + Given I am logged in as "joaosilva" + Then I should see "My enterprises" link + When I follow "My enterprises" and wait + Then I should see "Tangerine Dream" linking to "/myprofile/tangerine-dream" @selenium Scenario: not show enterprises on menu to a user without enterprises diff --git a/features/manage_products.feature b/features/manage_products.feature index debc11a..a09d234 100644 --- a/features/manage_products.feature +++ b/features/manage_products.feature @@ -392,22 +392,21 @@ Feature: manage products # And I should see "An used red bicycle" # And I should be on Rede Moinho's page of product Bike -# FIXME Not working -- 'cancel' is not clicked for some reason -# @selenium -# Scenario: cancel edition of a product description -# Given the following product_category -# | name | -# | Bicycle | -# And the following products -# | owner | category | name | description | -# | redemoinho | bicycle | Bike | A new red bicycle | -# And I am logged in as "joaosilva" -# When I go to Rede Moinho's page of product Bike -# Then I should see "A new red bicycle" -# And I follow "Edit description" -# When I follow "Cancel" -# Then I should see "A new red bicycle" -# And I should be on Rede Moinho's page of product Bike + @selenium + Scenario: cancel edition of a product description + Given the following product_category + | name | + | Bicycle | + And the following products + | owner | category | name | description | + | redemoinho | bicycle | Bike | A new red bicycle | + And I am logged in as "joaosilva" + When I go to Rede Moinho's page of product Bike + Then I should see "A new red bicycle" + And I follow "Edit description" + When I follow "Cancel" + Then I should see "A new red bicycle" + And I should be on Rede Moinho's page of product Bike @selenium Scenario: Edit product category and save without select any category diff --git a/features/profile_domain.feature b/features/profile_domain.feature index e3d3dba..9e44752 100644 --- a/features/profile_domain.feature +++ b/features/profile_domain.feature @@ -1,4 +1,5 @@ Feature: domain for profile + As a user I want access a profile by its own domain @@ -65,9 +66,8 @@ Feature: domain for profile And I follow "Go to the home page" Then the page title should be "Colivre.net" -# FIXME: the administration link doesn't appear -# @selenium -# Scenario: Compose link to administration with environment domain -# Given I am logged in as "joaosilva" -# When I visit "/" and wait -# Then I should see "Administration" linking to "http://127.0.0.1/admin" + @selenium + Scenario: Compose link to administration with environment domain + Given I am logged in as "joaosilva" + When I visit "/" and wait + Then I should see "Administration" linking to "http://127.0.0.1/admin" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index a4b5d0c..0a075f7 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -150,16 +150,6 @@ Given /^the following products?$/ do |table| data = item.dup owner = Enterprise[data.delete("owner")] category = Category.find_by_slug(data.delete("category").to_slug) - img = Image.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) - product = Product.create!(data.merge(:enterprise => owner, :product_category => category, :image_id => img.id)) - end -end - -Given /^the following simple products?$/ do |table| - table.hashes.each do |item| - data = item.dup - owner = Enterprise[data.delete("owner")] - category = Category.find_by_slug(data.delete("category").to_slug) data.merge!(:enterprise => owner, :product_category => category) if data[:img] img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+data.delete("img")+'.png', 'image/png')) @@ -167,7 +157,7 @@ Given /^the following simple products?$/ do |table| end if data[:qualifier] qualifier = Qualifier.find_by_name(data.delete("qualifier")) - data.merge!(:qualifiers => [qualifier]) + data.merge!(:qualifiers => [qualifier]) end product = Product.create!(data) end diff --git a/public/javascripts/catalog.js b/public/javascripts/catalog.js index 88d246a..dcc1395 100644 --- a/public/javascripts/catalog.js +++ b/public/javascripts/catalog.js @@ -1,48 +1,51 @@ -function open() { - if (this.clicked) return; - jQuery(this).addClass('open'); -} - -function close() { - if (this.clicked) return; - jQuery(this).removeClass('open'); -} +(function($) { -function click(e) { - jQuery(e).toggleClass('open', e.clicked); - jQuery(e).children('div').toggle(e.clicked).css({left: jQuery(e).position().left-180, top: jQuery(e).position().top-10}); -} - -function hover() { - jQuery(this).toggleClass('hover'); -} - -jQuery('#product-list .product .expand-box').hover(hover, hover).click(function () { +$('#product-list .product .expand-box').hover(hover, hover).live('click', function () { this.clicked = !this.clicked; click(this); - jQuery.each(jQuery(this).siblings('.expand-box'), function(index, value) { value.clicked = false; click(value); }); + $.each($(this).siblings('.expand-box'), function(index, value) { value.clicked = false; click(value); }); return false; }); -jQuery(document).click(function() { - jQuery.each(jQuery('#product-list .product .expand-box'), function(index, value) { value.clicked = false; click(value); }); +$(document).live('click', function() { + $.each($('#product-list .product .expand-box'), function(index, value) { value.clicked = false; click(value); }); }); var rows = {}; -jQuery('#product-list .product').each(function (index, element) { - obj = rows[jQuery(element).offset().top] || {}; +$('#product-list .product').each(function (index, element) { + obj = rows[$(element).offset().top] || {}; obj.heights = obj.heights || []; obj.elements = obj.elements || []; - obj.heights.push(jQuery(element).height()); + obj.heights.push($(element).height()); obj.elements.push(element); - rows[jQuery(element).offset().top] = obj; + rows[$(element).offset().top] = obj; }); -jQuery.each(rows, function(top, obj) { +$.each(rows, function(top, obj) { maxWidth = Array.max(obj.heights); - jQuery(obj.elements).height(maxWidth); + $(obj.elements).height(maxWidth); }); +})(jQuery); + +function open() { + if (this.clicked) return; + jQuery(this).addClass('open'); +} + +function close() { + if (this.clicked) return; + jQuery(this).removeClass('open'); +} + +function click(e) { + jQuery(e).toggleClass('open', e.clicked); + jQuery(e).children('div').toggle(e.clicked).css({left: jQuery(e).position().left-180, top: jQuery(e).position().top-10}); +} + +function hover() { + jQuery(this).toggleClass('hover'); +} diff --git a/test/functional/catalog_controller_test.rb b/test/functional/catalog_controller_test.rb index ae17309..b2c6c5e 100644 --- a/test/functional/catalog_controller_test.rb +++ b/test/functional/catalog_controller_test.rb @@ -72,14 +72,6 @@ class CatalogControllerTest < Test::Unit::TestCase assert_tag :tag => 'span', :attributes => { :class => 'product-price with-discount' }, :content => /50.00/ end -# should 'link to assets products with product category in the link to product category on index' do -# pc = ProductCategory.create!(:name => 'some product', :environment => enterprise.environment) -# prod = enterprise.products.create!(:name => 'Product test', :price => 50.00, :product_category => pc) -# -# get :index, :profile => enterprise.identifier -# assert_tag :tag => 'a', :attributes => {:href => /assets\/products\?product_category=#{pc.id}/} -# end - should 'add an zero width space every 4 caracters of comment urls' do url = 'www.an.url.to.be.splited.com' prod = @enterprise.products.create!(:name => 'Product test', :price => 50.00, :product_category => @product_category, :description => url) diff --git a/test/functional/maps_controller_test.rb b/test/functional/maps_controller_test.rb index 691e541..ba771cd 100644 --- a/test/functional/maps_controller_test.rb +++ b/test/functional/maps_controller_test.rb @@ -22,12 +22,12 @@ class MapsControllerTest < Test::Unit::TestCase assert_equal 'new address', Profile['test_profile'].address end -# should 'back when update address fail' do -# Profile.any_instance.stubs(:update_attributes!).returns(false) -# post :edit_location, :profile => profile.identifier, :profile_data => { 'address' => 'new address' } -# assert_nil profile.address -# assert_template 'edit_location' -# end + should 'back when update address fail' do + Profile.any_instance.stubs(:update_attributes!).returns(false) + post :edit_location, :profile => profile.identifier, :profile_data => { 'address' => 'new address' } + assert_nil profile.address + assert_template 'edit_location' + end should 'show page to edit location' do get :edit_location, :profile => profile.identifier diff --git a/test/unit/enterprise_homepage_test.rb b/test/unit/enterprise_homepage_test.rb index c4801e4..a360842 100644 --- a/test/unit/enterprise_homepage_test.rb +++ b/test/unit/enterprise_homepage_test.rb @@ -16,47 +16,6 @@ class EnterpriseHomepageTest < Test::Unit::TestCase assert_kind_of String, EnterpriseHomepage.description end -# These tests are being moved into features, since they're view tests - -# should 'display profile info' do -# e = Enterprise.create!(:name => 'my test enterprise', :identifier => 'mytestenterprise', :contact_email => 'ent@noosfero.foo.bar', :contact_phone => '5555 5555') -# a = EnterpriseHomepage.new(:name => 'article homepage') -# e.articles << a -# result = a.to_html -# assert_match /ent@noosfero.foo.bar/, result -# assert_match /5555 5555/, result -# end - -# should 'display products list' do -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise') -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_match /Product test/, result -# end - -# should 'not display products list if environment do not let' do -# e = Environment.default -# e.enable('disable_products_for_enterprises') -# e.save! -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise', :environment_id => e.id) -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_no_match /Product test/, result -# end - -# should 'display link to product' do -# ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'Test enteprise') -# prod = ent.products.create!(:name => 'Product test', :product_category => @product_category) -# a = EnterpriseHomepage.new(:name => 'article homepage') -# ent.articles << a -# result = a.to_html -# assert_match /\/test_enterprise\/manage_products\/show\/#{prod.id}/, result -# end - should 'return a valid body' do e = EnterpriseHomepage.new(:name => 'sample enterprise homepage') assert_not_nil e.to_html -- libgit2 0.21.2