mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Rubocop adjustments
This commit is contained in:
committed by
Filipe
parent
0671e52a29
commit
9a511e9e94
@@ -7,7 +7,7 @@ class OrderCycleShippingMethod < ApplicationRecord
|
||||
validate :shipping_method_belongs_to_order_cycle_distributor
|
||||
validate :shipping_method_available_at_checkout
|
||||
validate :order_cycle_not_simple
|
||||
validates_uniqueness_of :shipping_method, scope: :order_cycle_id
|
||||
validates :shipping_method, uniqueness: { scope: :order_cycle_id }
|
||||
|
||||
before_destroy :check_shipping_method_not_selected_on_any_orders
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OrderAvailableShippingMethods < Struct.new(:order, :customer)
|
||||
class OrderAvailableShippingMethods
|
||||
attr_reader :order, :customer
|
||||
|
||||
delegate :distributor,
|
||||
:order_cycle,
|
||||
to: :order
|
||||
|
||||
def initialize(order, customer = nil)
|
||||
@order, @customer = order, customer
|
||||
end
|
||||
|
||||
def to_a
|
||||
return [] if distributor.blank?
|
||||
|
||||
|
||||
@@ -72,14 +72,12 @@ FactoryBot.define do
|
||||
coordinator { Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise) }
|
||||
|
||||
transient do
|
||||
shipping_methods { [] }
|
||||
suppliers { [] }
|
||||
distributors { [] }
|
||||
variants { [] }
|
||||
end
|
||||
|
||||
after(:create) do |oc, proxy|
|
||||
|
||||
# Incoming Exchanges
|
||||
proxy.suppliers.each.with_index do |supplier, i|
|
||||
ex = create(:exchange, order_cycle: oc,
|
||||
|
||||
@@ -47,7 +47,8 @@ describe OrderCycleShippingMethod do
|
||||
|
||||
expect(order_cycle_shipping_method).to_not be_valid
|
||||
expect(order_cycle_shipping_method.errors.to_a).to include(
|
||||
"Order cycle is simple, all shipping methods are available by default and cannot be customised"
|
||||
"Order cycle is simple, all shipping methods are available by default and cannot be " \
|
||||
"customised"
|
||||
)
|
||||
end
|
||||
|
||||
@@ -108,7 +109,8 @@ describe OrderCycleShippingMethod do
|
||||
|
||||
expect(order_cycle_shipping_method).not_to be_destroyed
|
||||
expect(order_cycle_shipping_method.errors.to_a).to eq [
|
||||
"This shipping method has already been selected on orders in this order cycle and cannot be removed"
|
||||
"This shipping method has already been selected on orders in this order cycle and cannot " \
|
||||
"be removed"
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user