mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add sorting to query for producer mailer
This commit is contained in:
@@ -36,6 +36,7 @@ class ProducerMailer < Spree::BaseMailer
|
||||
where('order_cycles.id = ?', order_cycle).
|
||||
merge(Spree::Product.in_supplier(producer)).
|
||||
merge(Spree::Order.by_state('complete'))
|
||||
|
||||
end
|
||||
|
||||
def total_from_line_items(line_items)
|
||||
|
||||
@@ -16,11 +16,11 @@ describe ProducerMailer do
|
||||
let(:s3) { create(:supplier_enterprise) }
|
||||
let(:d1) { create(:distributor_enterprise, charges_sales_tax: true) }
|
||||
let(:d2) { create(:distributor_enterprise) }
|
||||
let(:p1) { create(:product, price: 12.34, supplier: s1, tax_category: tax_category) }
|
||||
let(:p2) { create(:product, price: 23.45, supplier: s2) }
|
||||
let(:p3) { create(:product, price: 34.56, supplier: s1) }
|
||||
let(:p4) { create(:product, price: 45.67, supplier: s1) }
|
||||
let(:p5) { create(:product, price: 56.78, supplier: s1) }
|
||||
let(:p1) { create(:product, name: "Zebra", price: 12.34, supplier: s1, tax_category: tax_category) }
|
||||
let(:p2) { create(:product, name: "Aardvark", price: 23.45, supplier: s2) }
|
||||
let(:p3) { create(:product, name: "Banana", price: 34.56, supplier: s1) }
|
||||
let(:p4) { create(:product, name: "Coffee", price: 45.67, supplier: s1) }
|
||||
let(:p5) { create(:product, name: "Daffodil", price: 56.78, supplier: s1) }
|
||||
let(:order_cycle) { create(:simple_order_cycle) }
|
||||
let!(:incoming_exchange) { order_cycle.exchanges.create! sender: s1, receiver: d1, incoming: true, receival_instructions: 'Outside shed.' }
|
||||
|
||||
@@ -71,7 +71,8 @@ describe ProducerMailer do
|
||||
expect(mail.cc).to eq [order_cycle.coordinator.contact.email]
|
||||
end
|
||||
|
||||
it "contains an aggregated list of produce" do
|
||||
it "contains an aggregated list of produce in alphabetical order" do
|
||||
mail.body.encoded.should match(/Coffee.+\n.+Zebra/)
|
||||
body_lines_including(mail, p1.name).each do |line|
|
||||
line.should include 'QTY: 3'
|
||||
line.should include '@ $10.00 = $30.00'
|
||||
@@ -80,6 +81,7 @@ describe ProducerMailer do
|
||||
.should have_selector("td", text: "$30.00")
|
||||
end
|
||||
|
||||
|
||||
it "displays tax totals for each product" do
|
||||
# Tax for p1 line items
|
||||
body_as_html(mail).find("table.order-summary tr", text: p1.name)
|
||||
|
||||
Reference in New Issue
Block a user