diff --git a/app/views/manage_products/_subcategories.rhtml b/app/views/manage_products/_subcategories.rhtml index 3938987..569cf88 100644 --- a/app/views/manage_products/_subcategories.rhtml +++ b/app/views/manage_products/_subcategories.rhtml @@ -1,4 +1,5 @@

<%= _('Current category:') %>

+<%= hidden_field_tag 'product[product_category_id]', @current_category.id %> <% categories = [@current_category] categories.push(@current_category) while @current_category and @current_category = @current_category.parent diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index 4ed08c8..33ad6c3 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -137,5 +137,15 @@ class ManageProductsControllerTest < Test::Unit::TestCase get 'update_subcategories', :profile => @enterprise.identifier, :id => category1.id assert_no_tag :tag => 'p', :content => 'Select a subcategory:' end + + should "create new product categorized" do + environment = Environment.default + category1 = ProductCategory.create!(:name => 'Category 1', :environment => environment) + category2 = ProductCategory.create!(:name => 'Category 2', :environment => environment, :parent => category1) + assert_difference Product, :count do + post 'new', :profile => @enterprise.identifier, :product => { :name => 'test product', :product_category_id => category2.id } + assert_equal category2, assigns(:product).product_category + end + end end -- libgit2 0.21.2