mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove dependency on model method in feature test
This commit is contained in:
@@ -296,11 +296,22 @@ FactoryGirl.define do
|
||||
end
|
||||
|
||||
factory :order_with_taxes, parent: :completed_order_with_totals do
|
||||
after(:create) do |order|
|
||||
order.distributor.update_attribute(:charges_sales_tax, true)
|
||||
ignore do
|
||||
product_price 0
|
||||
tax_rate_amount 0
|
||||
tax_rate_name ""
|
||||
end
|
||||
|
||||
distributor { create(:distributor_enterprise) }
|
||||
order_cycle { create(:simple_order_cycle) }
|
||||
|
||||
after(:create) do |order, proxy|
|
||||
order.distributor.update_attribute(:charges_sales_tax, true)
|
||||
Spree::Zone.global.update_attribute(:default_tax, true)
|
||||
order.line_items.first.product = FactoryGirl.create(:taxed_product, zone: Spree::Zone.global, price: 110.0, tax_rate_amount: 0.1)
|
||||
|
||||
p = FactoryGirl.create(:taxed_product, zone: Spree::Zone.global, price: proxy.product_price, tax_rate_amount: proxy.tax_rate_amount, tax_rate_name: proxy.tax_rate_name, distributors: [order.distributor])
|
||||
FactoryGirl.create(:line_item, order: order, product: p, price: p.price)
|
||||
order.reload
|
||||
end
|
||||
end
|
||||
|
||||
@@ -356,6 +367,7 @@ FactoryGirl.define do
|
||||
factory :taxed_product, :parent => :product do
|
||||
ignore do
|
||||
tax_rate_amount 0
|
||||
tax_rate_name ""
|
||||
zone nil
|
||||
end
|
||||
|
||||
@@ -363,7 +375,7 @@ FactoryGirl.define do
|
||||
|
||||
after(:create) do |product, proxy|
|
||||
raise "taxed_product factory requires a zone" unless proxy.zone
|
||||
create(:tax_rate, amount: proxy.tax_rate_amount, tax_category: product.tax_category, included_in_price: true, calculator: Spree::Calculator::DefaultTax.new, zone: proxy.zone)
|
||||
create(:tax_rate, amount: proxy.tax_rate_amount, tax_category: product.tax_category, included_in_price: true, calculator: Spree::Calculator::DefaultTax.new, zone: proxy.zone, name: proxy.tax_rate_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -215,7 +215,11 @@ feature %q{
|
||||
Spree::Config[:enable_receipt_printing?] = true
|
||||
|
||||
distributor1.update_attribute(:abn, '12345678')
|
||||
@order = create(:order_with_taxes, distributor: distributor1)
|
||||
@order = create(:order_with_taxes,
|
||||
distributor: distributor1,
|
||||
product_price: 110,
|
||||
tax_rate_amount: 0.1,
|
||||
tax_rate_name: "Tax 1")
|
||||
Spree::TaxRate.adjust(@order)
|
||||
|
||||
visit spree.admin_order_path(@order)
|
||||
@@ -256,10 +260,8 @@ feature %q{
|
||||
|
||||
scenario "shows the order taxes" do
|
||||
within('table.index tbody#price-adjustments') do
|
||||
@order.price_adjustment_totals.each do |label, total|
|
||||
expect(page).to have_selector "td", match: :first, text: label
|
||||
expect(page).to have_selector "td.total", text: total
|
||||
end
|
||||
expect(page).to have_selector "td", match: :first, text: "Tax 1"
|
||||
expect(page).to have_selector "td.total", text: Spree::Money.new(10)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user