Skip to content

Commit

Permalink
Merge pull request #7132 from Matt-Yorkley/reload-deprecations
Browse files Browse the repository at this point in the history
Replace deprecated use of :reload argument
  • Loading branch information
andrewpbrett committed Mar 16, 2021
2 parents b0f2688 + 2d9d293 commit e8a256e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/models/enterprise_relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def permissions_list=(perms)
end

def has_permission?(name)
permissions(:reload).map(&:name).map(&:to_sym).include? name.to_sym
permissions.reload.map(&:name).map(&:to_sym).include? name.to_sym
end

private
Expand Down
8 changes: 4 additions & 4 deletions app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def contents
# Spree::OrderContents#add is the more modern version in Spree history
# but this add_variant has been customized for OFN FrontOffice.
def add_variant(variant, quantity = 1, max_quantity = nil, currency = nil)
line_items(:reload)
line_items.reload
current_item = find_line_item_by_variant(variant)

# Notify bugsnag if we get line items with a quantity of zero
Expand Down Expand Up @@ -638,7 +638,7 @@ def set_order_cycle!(order_cycle)
end

def remove_variant(variant)
line_items(:reload)
line_items.reload
current_item = find_line_item_by_variant(variant)
current_item.andand.destroy
end
Expand All @@ -664,11 +664,11 @@ def distribution_set?
end

def shipping_tax
shipment_adjustments(:reload).shipping.sum(:included_tax)
shipment_adjustments.reload.shipping.sum(:included_tax)
end

def enterprise_fee_tax
adjustments(:reload).enterprise_fee.sum(:included_tax)
adjustments.reload.enterprise_fee.sum(:included_tax)
end

def total_tax
Expand Down
4 changes: 2 additions & 2 deletions app/models/spree/tax_rate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def adjust(order)
create_adjustment(label, order, order)
end

order.adjustments(:reload)
order.line_items(:reload)
order.adjustments.reload
order.line_items.reload
# TaxRate adjustments (order.adjustments.tax)
# and line item adjustments (tax included on line items) consist of 100% tax
(order.adjustments.tax + order.line_item_adjustments.reload).each do |adjustment|
Expand Down
2 changes: 1 addition & 1 deletion app/models/spree/variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def update_weight_from_unit_value
end

def destruction
exchange_variants(:reload).destroy_all
exchange_variants.reload.destroy_all
yield
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/line_items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
get :bought, format: :json
expect(response.status).to eq 200
json_response = JSON.parse(response.body)
expect(json_response.length).to eq completed_order.line_items(:reload).count
expect(json_response.length).to eq completed_order.line_items.reload.count
expect(json_response[0]['id']).to eq completed_order.line_items.first.id
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

it "validates ownership limit" do
expect(u1.enterprise_limit).to be 5
expect(u1.owned_enterprises(:reload)).to eq [e]
expect(u1.owned_enterprises.reload).to eq [e]
4.times { create(:enterprise, owner: u1) }
e2 = create(:enterprise, owner: u2)
expect {
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/adjustment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module Spree
let!(:order) { create(:order, bill_address: create(:address)) }
let!(:line_item) { create(:line_item, order: order) }
let(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: ::Calculator::FlatRate.new(preferred_amount: 0.1)) }
let(:adjustment) { line_item.adjustments(:reload).first }
let(:adjustment) { line_item.adjustments.reload.first }

before do
order.reload
Expand Down Expand Up @@ -274,7 +274,7 @@ module Spree
let(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator, coordinator_fees: [enterprise_fee], distributors: [coordinator], variants: [variant]) }
let(:line_item) { create(:line_item, variant: variant) }
let(:order) { create(:order, line_items: [line_item], order_cycle: order_cycle, distributor: coordinator) }
let(:adjustment) { order.adjustments(:reload).enterprise_fee.first }
let(:adjustment) { order.adjustments.reload.enterprise_fee.first }

context "when enterprise fees have a fixed tax_category" do
before do
Expand Down
6 changes: 3 additions & 3 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,13 @@

it "removes the variant's line item" do
order.remove_variant v1
expect(order.line_items(:reload).map(&:variant)).to eq([v2])
expect(order.line_items.reload.map(&:variant)).to eq([v2])
end

it "does nothing when there is no matching line item" do
expect do
order.remove_variant v3
end.to change(order.line_items(:reload), :count).by(0)
end.to change(order.line_items.reload, :count).by(0)
end

context "when the item has an associated adjustment" do
Expand All @@ -809,7 +809,7 @@

it "removes the variant's line item" do
order.remove_variant v1
expect(order.line_items(:reload).map(&:variant)).to eq([v2])
expect(order.line_items.reload.map(&:variant)).to eq([v2])
end

it "removes the variant's adjustment" do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spree/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ module Spree
end

it "copies the properties on master variant to the first standard variant" do
expect(product.variants(:reload).length).to eq 1
standard_variant = product.variants(:reload).first
expect(product.variants.reload.length).to eq 1
standard_variant = product.variants.reload.first
expect(standard_variant.price).to eq product.master.price
end

Expand Down
8 changes: 4 additions & 4 deletions spec/models/spree/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
let!(:e2) { create(:enterprise, owner: u1) }

it "provides access to owned enterprises" do
expect(u1.owned_enterprises(:reload)).to include e1, e2
expect(u1.owned_enterprises.reload).to include e1, e2
end

it "enforces the limit on the number of enterprise owned" do
expect(u2.owned_enterprises(:reload)).to eq []
expect(u2.owned_enterprises.reload).to eq []
u2.owned_enterprises << e1
expect { u2.save! }.to_not raise_error
expect do
Expand All @@ -62,8 +62,8 @@
let!(:g3) { create(:enterprise_group, owner: u2) }

it "provides access to owned groups" do
expect(u1.owned_groups(:reload)).to match_array([g1, g2])
expect(u2.owned_groups(:reload)).to match_array([g3])
expect(u1.owned_groups.reload).to match_array([g1, g2])
expect(u2.owned_groups.reload).to match_array([g3])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/services/cart_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
order.add_variant variant, 1, 2

cart_service.populate({ variants: {} }, true)
order.line_items(:reload)
order.line_items.reload
li = order.find_line_item_by_variant(variant)
expect(li).not_to be
end
Expand Down

0 comments on commit e8a256e

Please sign in to comment.