Commit 789e8e48aefc1156e56222e5c537f685e09f1183

Authored by JoenioCosta
1 parent 14319a14

ActionItem266: oops: fixing tests

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1654 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/views/manage_products/_subcategories.rhtml
1 1 <p><%= _('Current category:') %></p>
  2 +<%= hidden_field_tag 'product[product_category_id]', @current_category.id %>
2 3 <%
3 4 categories = [@current_category]
4 5 categories.push(@current_category) while @current_category and @current_category = @current_category.parent
... ...
test/functional/manage_products_controller_test.rb
... ... @@ -137,5 +137,15 @@ class ManageProductsControllerTest &lt; Test::Unit::TestCase
137 137 get 'update_subcategories', :profile => @enterprise.identifier, :id => category1.id
138 138 assert_no_tag :tag => 'p', :content => 'Select a subcategory:'
139 139 end
  140 +
  141 + should "create new product categorized" do
  142 + environment = Environment.default
  143 + category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment)
  144 + category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1)
  145 + assert_difference Product, :count do
  146 + post 'new', :profile => @enterprise.identifier, :product => { :name => 'test product', :product_category_id => category2.id }
  147 + assert_equal category2, assigns(:product).product_category
  148 + end
  149 + end
140 150  
141 151 end
... ...