mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Run rubocop autocorrect
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spree/localized_number'
|
||||
require 'concerns/adjustment_scopes'
|
||||
|
||||
@@ -97,6 +99,7 @@ module Spree
|
||||
# Should return _true_ if originator is absent or doesn't implement _eligible?_
|
||||
def eligible_for_originator?
|
||||
return true if originator.nil?
|
||||
|
||||
!originator.respond_to?(:eligible?) || originator.eligible?(source)
|
||||
end
|
||||
|
||||
@@ -109,13 +112,14 @@ module Spree
|
||||
# are not recalculated.
|
||||
#
|
||||
# It receives +calculable+ as the updated source here so calculations can be
|
||||
# performed on the current values of that source. If we used +source+ it
|
||||
# performed on the current values of that source. If we used +source+ it
|
||||
# could load the old record from db for the association. e.g. when updating
|
||||
# more than on line items at once via accepted_nested_attributes the order
|
||||
# object on the association would be in a old state and therefore the
|
||||
# adjustment calculations would not performed on proper values
|
||||
def update!(calculable = nil)
|
||||
return if immutable?
|
||||
|
||||
# Fix for #3381
|
||||
# If we attempt to call 'source' before the reload, then source is currently
|
||||
# the order object. After calling a reload, the source is the Shipment.
|
||||
@@ -171,8 +175,8 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def update_adjustable
|
||||
adjustable.update! if adjustable.is_a? Order
|
||||
end
|
||||
def update_adjustable
|
||||
adjustable.update! if adjustable.is_a? Order
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class Calculator < ActiveRecord::Base
|
||||
belongs_to :calculable, polymorphic: true
|
||||
@@ -5,7 +7,7 @@ module Spree
|
||||
# This method must be overriden in concrete calculator.
|
||||
#
|
||||
# It should return amount computed based on #calculable and/or optional parameter
|
||||
def compute(something = nil)
|
||||
def compute(_something = nil)
|
||||
raise NotImplementedError, 'please use concrete calculator'
|
||||
end
|
||||
|
||||
@@ -16,8 +18,7 @@ module Spree
|
||||
|
||||
###################################################################
|
||||
|
||||
def self.register(*klasses)
|
||||
end
|
||||
def self.register(*klasses); end
|
||||
|
||||
# Returns all calculators applicable for kind of work
|
||||
def self.calculators
|
||||
@@ -32,7 +33,7 @@ module Spree
|
||||
self.class.description
|
||||
end
|
||||
|
||||
def available?(object)
|
||||
def available?(_object)
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class TaxCategory < ActiveRecord::Base
|
||||
acts_as_paranoid
|
||||
@@ -8,7 +10,7 @@ module Spree
|
||||
before_save :set_default_category
|
||||
|
||||
def set_default_category
|
||||
#set existing default tax category to false if this one has been marked as default
|
||||
# set existing default tax category to false if this one has been marked as default
|
||||
|
||||
if is_default && tax_category = self.class.where(is_default: true).first
|
||||
tax_category.update_column(:is_default, false) unless tax_category == self
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class DefaultTaxZoneValidator < ActiveModel::Validator
|
||||
def validate(record)
|
||||
@@ -35,7 +37,7 @@ module Spree
|
||||
order.adjustments.tax.destroy_all
|
||||
order.line_item_adjustments.where(originator_type: 'Spree::TaxRate').destroy_all
|
||||
|
||||
self.match(order).each do |rate|
|
||||
match(order).each do |rate|
|
||||
rate.adjust(order)
|
||||
end
|
||||
end
|
||||
@@ -104,11 +106,11 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def create_label
|
||||
label = ""
|
||||
label << (name.present? ? name : tax_category.name) + " "
|
||||
label << (show_rate_in_label? ? "#{amount * 100}%" : "")
|
||||
end
|
||||
def create_label
|
||||
label = ""
|
||||
label << (name.presence || tax_category.name) + " "
|
||||
label << (show_rate_in_label? ? "#{amount * 100}%" : "")
|
||||
end
|
||||
|
||||
def with_tax_included_in_price
|
||||
old_included_in_price = included_in_price
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
module Spree
|
||||
describe Adjustment do
|
||||
let(:order) { mock_model(Spree::Order, update!: nil) }
|
||||
let(:adjustment) { Spree::Adjustment.create(:label => "Adjustment", :amount => 5) }
|
||||
let(:adjustment) { Spree::Adjustment.create(label: "Adjustment", amount: 5) }
|
||||
|
||||
describe "scopes" do
|
||||
let!(:arbitrary_adjustment) { create(:adjustment, source: nil, label: "Arbitrary") }
|
||||
@@ -104,9 +104,9 @@ module Spree
|
||||
context "#save" do
|
||||
it "should call order#update!" do
|
||||
adjustment = Spree::Adjustment.new(
|
||||
:adjustable => order,
|
||||
:amount => 10,
|
||||
:label => "Foo"
|
||||
adjustable: order,
|
||||
amount: 10,
|
||||
label: "Foo"
|
||||
)
|
||||
order.should_receive(:update!)
|
||||
adjustment.save
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::TaxCategory do
|
||||
@@ -10,7 +12,7 @@ describe Spree::TaxCategory do
|
||||
end
|
||||
|
||||
it "should undefault the previous default tax category" do
|
||||
new_tax_category.update_attributes({:is_default => true})
|
||||
new_tax_category.update({ is_default: true })
|
||||
new_tax_category.is_default.should be_true
|
||||
|
||||
tax_category.reload
|
||||
|
||||
Reference in New Issue
Block a user