Skip to content

Commit

Permalink
Admin may set no tax category on product unless tax category is required
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanM committed Mar 17, 2015
1 parent 7af1724 commit cf4ccc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
= f.label :tax_category_id, t(:tax_category)
%span.required *
%br
= f.collection_select(:tax_category_id, Spree::TaxCategory.all, :id, :name, {:include_blank => Spree::TaxCategory.count > 1}, {:class => "select2 fullwidth"})
= f.collection_select(:tax_category_id, Spree::TaxCategory.all, :id, :name, {:include_blank => Spree::Config.products_require_tax_category ? false : 'None'}, {:class => "select2 fullwidth"})
= f.error_message_on :tax_category_id
6 changes: 4 additions & 2 deletions spec/features/admin/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
end

scenario "creating a new product" do
Spree::Config.products_require_tax_category = false

click_link 'Products'
click_link 'New Product'

Expand All @@ -127,7 +129,7 @@
page.should have_selector('#product_supplier_id')
select 'Another Supplier', :from => 'product_supplier_id'
select taxon.name, from: "product_primary_taxon_id"
select tax_category.name, from: "product_tax_category_id"
select 'None', from: "product_tax_category_id"

# Should only have suppliers listed which the user can manage
page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name]
Expand All @@ -138,7 +140,7 @@
flash_message.should == 'Product "A new product !!!" has been successfully created!'
product = Spree::Product.find_by_name('A new product !!!')
product.supplier.should == @supplier2
product.tax_category.should == tax_category
product.tax_category.should be_nil
end

scenario "editing a product" do
Expand Down

0 comments on commit cf4ccc2

Please sign in to comment.