mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove print ticket links
This commit is contained in:
@@ -839,7 +839,6 @@ Rails/OutputSafety:
|
||||
- 'lib/reporting/queries/query_builder.rb'
|
||||
- 'lib/reporting/queries/query_interface.rb'
|
||||
- 'lib/spree/money.rb'
|
||||
- 'spec/system/admin/order_print_ticket_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
|
||||
@@ -27,7 +27,7 @@ module Spree
|
||||
private
|
||||
|
||||
def complete_order_links
|
||||
[resend_confirmation_link] + invoice_links + ticket_links
|
||||
[resend_confirmation_link] + invoice_links
|
||||
end
|
||||
|
||||
def invoice_links
|
||||
@@ -52,12 +52,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
def ticket_links
|
||||
return [] unless Spree::Config[:enable_receipt_printing?]
|
||||
|
||||
[print_ticket_link, select_ticket_printer_link]
|
||||
end
|
||||
|
||||
def edit_order_link
|
||||
{ name: t(:edit_order),
|
||||
url: spree.edit_admin_order_path(@order),
|
||||
@@ -100,20 +94,6 @@ module Spree
|
||||
confirm: t(:must_have_valid_business_number, enterprise_name: @order.distributor.name) }
|
||||
end
|
||||
|
||||
def print_ticket_link
|
||||
{ name: t(:print_ticket),
|
||||
url: print_ticket_admin_order_path(@order),
|
||||
icon: 'icon-print',
|
||||
target: "_blank" }
|
||||
end
|
||||
|
||||
def select_ticket_printer_link
|
||||
{ name: t(:select_ticket_printer),
|
||||
url: "#{print_ticket_admin_order_path(@order)}#select-printer",
|
||||
icon: 'icon-print',
|
||||
target: "_blank" }
|
||||
end
|
||||
|
||||
def ship_order_link
|
||||
{ name: t(:ship_order),
|
||||
url: spree.fire_admin_order_path(@order, e: 'ship'),
|
||||
|
||||
@@ -9,10 +9,8 @@ describe Spree::Admin::OrdersHelper, type: :helper do
|
||||
|
||||
around do |example|
|
||||
original_invoices_setting = Spree::Config[:enable_invoices?]
|
||||
original_tickets_setting = Spree::Config[:enable_receipt_printing?]
|
||||
example.run
|
||||
Spree::Config[:enable_invoices?] = original_invoices_setting
|
||||
Spree::Config[:enable_receipt_printing?] = original_tickets_setting
|
||||
end
|
||||
|
||||
before do
|
||||
@@ -21,7 +19,6 @@ describe Spree::Admin::OrdersHelper, type: :helper do
|
||||
allow(order).to receive(:can_cancel?) { false }
|
||||
allow(order).to receive(:resumed?) { false }
|
||||
Spree::Config[:enable_invoices?] = false
|
||||
Spree::Config[:enable_receipt_printing?] = false
|
||||
end
|
||||
|
||||
it "returns only edit order link when all conditions are set to false" do
|
||||
@@ -82,20 +79,6 @@ describe Spree::Admin::OrdersHelper, type: :helper do
|
||||
expect(links[3][:name]).to eq "Print Invoice"
|
||||
end
|
||||
end
|
||||
|
||||
context "with tickets enabled" do
|
||||
before do
|
||||
Spree::Config[:enable_receipt_printing?] = true
|
||||
end
|
||||
|
||||
it "adds print and select ticket links" do
|
||||
links = helper.order_links(order)
|
||||
|
||||
expect(links.size).to eq 4
|
||||
expect(links[2][:name]).to eq "Print Ticket"
|
||||
expect(links[3][:name]).to eq "Select printer for tickets"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "resumed order" do
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_helper"
|
||||
|
||||
describe '
|
||||
As an administrator
|
||||
I want to print a ticket for an order
|
||||
' do
|
||||
include CheckoutHelper
|
||||
include AuthenticationHelper
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include WebHelper
|
||||
|
||||
context "as an enterprise manager" do
|
||||
let!(:shipping_method) { create(:shipping_method, distributors: [distributor]) }
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
let!(:order) do
|
||||
create(:order_with_taxes, distributor: distributor, ship_address: create(:address),
|
||||
product_price: 110, tax_rate_amount: 0.1,
|
||||
tax_rate_name: "Tax 1").tap do |order|
|
||||
order.create_tax_charge!
|
||||
order.update_shipping_fees!
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
@enterprise_user = create(:user)
|
||||
@enterprise_user.enterprise_roles.build(enterprise: distributor).save
|
||||
|
||||
login_as @enterprise_user
|
||||
|
||||
Spree::Config[:enable_receipt_printing?] = true
|
||||
end
|
||||
|
||||
describe "viewing the edit page" do
|
||||
it "can print an order's ticket" do
|
||||
visit spree.edit_admin_order_path(order)
|
||||
|
||||
find("#links-dropdown .ofn-drop-down").click
|
||||
|
||||
ticket_window = window_opened_by do
|
||||
within('#links-dropdown') do
|
||||
click_link('Print Ticket')
|
||||
end
|
||||
end
|
||||
|
||||
within_window ticket_window do
|
||||
accept_alert do
|
||||
# The JS code needs time to load but there's no visual indicator
|
||||
# we can wait for.
|
||||
print_data = nil
|
||||
wait_until do
|
||||
print_data = page.evaluate_script('printData')
|
||||
rescue Ferrum::JavaScriptError
|
||||
false
|
||||
end
|
||||
|
||||
elements_in_print_data = [
|
||||
order.distributor.name,
|
||||
order.distributor.address.address_part1,
|
||||
order.distributor.address.address_part2,
|
||||
order.distributor.contact.email, order.number,
|
||||
line_items_in_print_data,
|
||||
adjustments_in_print_data,
|
||||
order.display_total.format(with_currency: false),
|
||||
taxes_in_print_data,
|
||||
display_checkout_total_less_tax(order).format(with_currency: false)
|
||||
]
|
||||
expect(print_data.join).to include(*elements_in_print_data.flatten)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def line_items_in_print_data
|
||||
order.line_items.map { |line_item|
|
||||
[line_item.quantity.to_s,
|
||||
line_item.product.name,
|
||||
line_item.single_display_amount_with_adjustments.format(symbol: false,
|
||||
with_currency: false),
|
||||
line_item.display_amount_with_adjustments.format(symbol: false, with_currency: false)]
|
||||
}
|
||||
end
|
||||
|
||||
def adjustments_in_print_data
|
||||
checkout_adjustments_for(order, exclude: [:line_item]).
|
||||
reject { |a| a.amount.zero? }.
|
||||
map do |adjustment|
|
||||
[raw(adjustment.label),
|
||||
display_adjustment_amount(adjustment).format(symbol: false, with_currency: false)]
|
||||
end
|
||||
end
|
||||
|
||||
def taxes_in_print_data
|
||||
[["10.0%", "$11.00"]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user