Commit 0814a5ef8b3264203b9dfc5b0d24a977988b649a

Authored by MoisesMachado
1 parent 31fdbc17

ActionItem28: added some links to manage products and fixed some tests

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@945 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/profile_editor_controller.rb
@@ -10,6 +10,7 @@ class ProfileEditorController < MyProfileController @@ -10,6 +10,7 @@ class ProfileEditorController < MyProfileController
10 def block_types 10 def block_types
11 %w[ 11 %w[
12 FavoriteLinksProfile 12 FavoriteLinksProfile
  13 + ListBlock
13 ] 14 ]
14 end 15 end
15 16
app/models/product.rb
@@ -4,4 +4,5 @@ class Product < ActiveRecord::Base @@ -4,4 +4,5 @@ class Product < ActiveRecord::Base
4 4
5 validates_presence_of :name 5 validates_presence_of :name
6 validates_uniqueness_of :name, :scope => :enterprise_id 6 validates_uniqueness_of :name, :scope => :enterprise_id
  7 + validates_numericality_of :price, :allow_nil => true
7 end 8 end
app/views/manage_products/show.rhtml
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 <p> <%= _('Price: ') %> <%= @product.price %> </p> 3 <p> <%= _('Price: ') %> <%= @product.price %> </p>
4 <p> <%= _('Description: ') %> <%= @product.description %> </p> 4 <p> <%= _('Description: ') %> <%= @product.description %> </p>
5 - 5 +<p> <%= _('Category: ') %> <%= @product.product_category ? @product.product_category.name : _('Uncategorized product') %> </p>
6 6
7 <%= link_to _('edit'), :action => 'edit', :id => @product %> 7 <%= link_to _('edit'), :action => 'edit', :id => @product %>
8 <%= link_to _('destroy'), :action => 'destroy', :id => @product %> 8 <%= link_to _('destroy'), :action => 'destroy', :id => @product %>
app/views/profile_editor/index.rhtml
@@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
12 <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %> 12 <%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') %>
13 13
14 <%= file_manager_button(_('Change Password'), 'icons-app/change-password.png', :controller => 'account', :action => 'change_password') %> 14 <%= file_manager_button(_('Change Password'), 'icons-app/change-password.png', :controller => 'account', :action => 'change_password') %>
  15 +
  16 + <%= file_manager_button(_('Manage Products'), 'icons-app/products.png', :controller => 'manage_products') if @profile.kind_of?(Enterprise) %>
15 17
16 <% end %> 18 <% end %>
17 19
test/functional/role_controller_test.rb
@@ -6,7 +6,6 @@ class RoleController; def rescue_action(e) raise e end; end @@ -6,7 +6,6 @@ class RoleController; def rescue_action(e) raise e end; end
6 6
7 class RoleControllerTest < Test::Unit::TestCase 7 class RoleControllerTest < Test::Unit::TestCase
8 all_fixtures 8 all_fixtures
9 - under_profile :ze  
10 9
11 def setup 10 def setup
12 @controller = RoleController.new 11 @controller = RoleController.new
test/unit/product_test.rb
@@ -4,22 +4,22 @@ class ProductTest &lt; Test::Unit::TestCase @@ -4,22 +4,22 @@ class ProductTest &lt; Test::Unit::TestCase
4 4
5 should 'create product' do 5 should 'create product' do
6 assert_difference Product, :count do 6 assert_difference Product, :count do
7 - p = Product.new(:name => 'test product') 7 + p = Product.new(:name => 'test product1')
8 assert p.save 8 assert p.save
9 end 9 end
10 end 10 end
11 11
12 should 'destroy product' do 12 should 'destroy product' do
13 - p = Product.create(:name => 'test product') 13 + p = Product.create(:name => 'test product2')
14 assert_difference Product, :count, -1 do 14 assert_difference Product, :count, -1 do
15 p.destroy 15 p.destroy
16 end 16 end
17 end 17 end
18 18
19 should 'name be unique' do 19 should 'name be unique' do
20 - Product.create(:name => 'test product') 20 + Product.create(:name => 'test product3')
21 assert_no_difference Product, :count do 21 assert_no_difference Product, :count do
22 - p = Product.new(:name => 'test product') 22 + p = Product.new(:name => 'test product3')
23 assert !p.save 23 assert !p.save
24 end 24 end
25 end 25 end