mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Calculator 'None' is the default one for both shipping and payment method
+ update specs as well Update shipping_method.rb
This commit is contained in:
@@ -113,7 +113,7 @@ module Spree
|
||||
end
|
||||
|
||||
def init
|
||||
self.calculator ||= ::Calculator::FlatRate.new(preferred_amount: 0)
|
||||
self.calculator ||= ::Calculator::None.new
|
||||
end
|
||||
|
||||
def has_distributor?(distributor)
|
||||
|
||||
@@ -32,6 +32,8 @@ module Spree
|
||||
validate :at_least_one_shipping_category
|
||||
validates :display_on, inclusion: { in: DISPLAY_ON_OPTIONS.values }, allow_nil: true
|
||||
|
||||
after_initialize :init
|
||||
|
||||
after_save :touch_distributors
|
||||
|
||||
scope :managed_by, lambda { |user|
|
||||
@@ -110,6 +112,10 @@ module Spree
|
||||
where(display_on: [nil, ""])
|
||||
end
|
||||
|
||||
def init
|
||||
self.calculator ||= ::Calculator::None.new
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def no_active_or_upcoming_order_cycle_distributors_with_only_one_shipping_method?
|
||||
|
||||
@@ -247,10 +247,13 @@ describe '
|
||||
end
|
||||
|
||||
describe "Setting transaction fees", js: true do
|
||||
let(:calculator) { build(:calculator) }
|
||||
let!(:payment_method) { create(:payment_method, calculator: calculator) }
|
||||
let!(:payment_method) { create(:payment_method) }
|
||||
before { login_as_admin_and_visit spree.edit_admin_payment_method_path payment_method }
|
||||
|
||||
it "set by default 'None' as calculator" do
|
||||
expect(page).to have_select "calc_type", selected: "None"
|
||||
end
|
||||
|
||||
it "handle the 'None' calculator" do
|
||||
select2_select "None", from: 'calc_type'
|
||||
click_button 'Update'
|
||||
@@ -273,9 +276,11 @@ describe '
|
||||
end
|
||||
|
||||
context "using Flat Rate (per order) calculator" do
|
||||
# flat rate per order is the default calculator; no need select it and update page
|
||||
before { select2_select "Flat Rate (per order)", from: 'calc_type' }
|
||||
|
||||
it "inserts values which persist" do
|
||||
expect(page).to have_content("you must save first before")
|
||||
click_button 'Update'
|
||||
fill_in "Amount", with: 2.2
|
||||
click_button 'Update'
|
||||
expect(page).to have_content("Payment Method has been successfully updated!")
|
||||
|
||||
Reference in New Issue
Block a user