From 24bb5d14f27ebfb47519e202dc74653ed9eef27e Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Mon, 24 Nov 2008 14:57:37 -0300 Subject: [PATCH] ActionItem861: removing line price from products if not informed --- app/views/catalog/index.rhtml | 6 ++++-- app/views/catalog/show.rhtml | 8 +++++--- test/functional/catalog_controller_test.rb | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/views/catalog/index.rhtml b/app/views/catalog/index.rhtml index 2311a0a..c7d2bd2 100644 --- a/app/views/catalog/index.rhtml +++ b/app/views/catalog/index.rhtml @@ -9,7 +9,9 @@ <%= link_to_product product %> <% if product.description %> @@ -21,5 +23,5 @@ <% end %> <% end %> - diff --git a/app/views/catalog/show.rhtml b/app/views/catalog/show.rhtml index a5b662c..40c9fa4 100644 --- a/app/views/catalog/show.rhtml +++ b/app/views/catalog/show.rhtml @@ -8,9 +8,11 @@ <%= txt2html @product.description if @product.description %> -

-<%= _('Price: %s') % ( @product.price ? "%.2f" % @product.price : content_tag('em', _('not informed')) ) %> -

+<% if @product.price %> +

+ <%= _('Price: %s') % ( "%.2f" % @product.price) %> +

+<% end %>

<%= _('Category: %s ') % link_to_category(@product.product_category) %> diff --git a/test/functional/catalog_controller_test.rb b/test/functional/catalog_controller_test.rb index 648aeb7..0cbc308 100644 --- a/test/functional/catalog_controller_test.rb +++ b/test/functional/catalog_controller_test.rb @@ -75,4 +75,34 @@ class CatalogControllerTest < Test::Unit::TestCase assert_redirected_to :controller => 'profile', :action => 'index', :profile => ent.identifier end + should 'not show product price when listing products if not informed' do + ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + prod = ent.products.create!(:name => 'Product test') + get :index, :profile => ent.identifier + assert_no_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ + end + + should 'show product price when listing products if informed' do + ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + prod = ent.products.create!(:name => 'Product test', :price => 50.00) + get :index, :profile => ent.identifier + assert_tag :tag => 'li', :attributes => { :class => 'product_price' }, :content => /Price:/ + end + + should 'not show product price when showing product if not informed' do + ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + prod = ent.products.create!(:name => 'Product test') + get :show, :id => prod.id, :profile => ent.identifier + + assert_no_tag :tag => 'p', :attributes => { :class => 'product_price' }, :content => /Price:/ + end + + should 'show product price when showing product if informed' do + ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') + prod = ent.products.create!(:name => 'Product test', :price => 50.00) + get :show, :id => prod.id, :profile => ent.identifier + + assert_tag :tag => 'p', :attributes => { :class => 'product_price' }, :content => /Price:/ + end + end -- libgit2 0.21.2