From f5bc120fb1bb31caf2138ea4b34afa3eb30eae8c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 21 Dec 2019 22:19:06 +0100 Subject: [PATCH] Remove `without_protection: true` argument from #create calls Needed for using Strong Parameters in Rails 4 --- app/models/spree/payment_decorator.rb | 2 +- ...857_remove_shipping_methods_using_itemwise_calculator.rb | 2 +- db/seeds.rb | 5 +---- lib/open_food_network/variant_and_line_item_naming.rb | 2 +- spec/features/consumer/registration_spec.rb | 6 +++--- spec/models/enterprise_fee_spec.rb | 2 +- spec/models/spree/product_spec.rb | 6 +++--- spec/models/tag_rule/discount_order_spec.rb | 2 +- spec/support/seeds.rb | 6 +++--- 9 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/models/spree/payment_decorator.rb b/app/models/spree/payment_decorator.rb index a3f19c9d3b..ed3c85233c 100644 --- a/app/models/spree/payment_decorator.rb +++ b/app/models/spree/payment_decorator.rb @@ -62,7 +62,7 @@ module Spree payment_method: payment_method, amount: refund_amount.abs * -1, response_code: response.authorization, - state: 'completed' }, without_protection: true) + state: 'completed' }) else gateway_error(response) end diff --git a/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb b/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb index 52351065dd..7ba21757fd 100644 --- a/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb +++ b/db/migrate/20130814010857_remove_shipping_methods_using_itemwise_calculator.rb @@ -10,6 +10,6 @@ class RemoveShippingMethodsUsingItemwiseCalculator < ActiveRecord::Migration end def down - Spree::ShippingMethod.create!({name: 'Delivery', zone: Spree::Zone.last, calculator: OpenFoodNetwork::Calculator::Itemwise.new}, without_protection: true) + Spree::ShippingMethod.create!({name: 'Delivery', zone: Spree::Zone.last, calculator: OpenFoodNetwork::Calculator::Itemwise.new}) end end diff --git a/db/seeds.rb b/db/seeds.rb index 12b3cdd5ce..9afe88de4b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -41,10 +41,7 @@ states.each do |state| puts "State: " + state.to_s unless Spree::State.find_by(name: state['name']) - Spree::State.create!( - { name: state['name'], abbr: state['abbr'], country: country }, - without_protection: true - ) + Spree::State.create!({ name: state['name'], abbr: state['abbr'], country: country }) end end diff --git a/lib/open_food_network/variant_and_line_item_naming.rb b/lib/open_food_network/variant_and_line_item_naming.rb index 596b93beee..fca7f25d0d 100644 --- a/lib/open_food_network/variant_and_line_item_naming.rb +++ b/lib/open_food_network/variant_and_line_item_naming.rb @@ -59,7 +59,7 @@ module OpenFoodNetwork option_type = product.variant_unit_option_type if option_type name = option_value_name - ov = Spree::OptionValue.where(option_type_id: option_type, name: name, presentation: name).first || Spree::OptionValue.create!({ option_type: option_type, name: name, presentation: name }, without_protection: true) + ov = Spree::OptionValue.where(option_type_id: option_type, name: name, presentation: name).first || Spree::OptionValue.create!({ option_type: option_type, name: name, presentation: name }) option_values << ov end end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 1931614d07..a62140f171 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -10,9 +10,9 @@ feature "Registration", js: true do before do Spree::Config.enterprises_require_tos = false - albania = Spree::Country.create!({ name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" }, without_protection: true) - Spree::State.create!({ name: "Berat", abbr: "BRA", country: albania }, without_protection: true) - Spree::Country.create!({ name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" }, without_protection: true) + albania = Spree::Country.create!({ name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" }) + Spree::State.create!({ name: "Berat", abbr: "BRA", country: albania }) + Spree::Country.create!({ name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" }) end after do diff --git a/spec/models/enterprise_fee_spec.rb b/spec/models/enterprise_fee_spec.rb index 4c09ccd62c..a422358bb8 100644 --- a/spec/models/enterprise_fee_spec.rb +++ b/spec/models/enterprise_fee_spec.rb @@ -130,7 +130,7 @@ describe EnterpriseFee do source: order, originator: tax_rate, state: 'closed', - label: 'hello' }, without_protection: true) + label: 'hello' }) expect do EnterpriseFee.clear_all_adjustments_on_order order diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 7810978fc4..cb6bf45f0f 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -450,9 +450,9 @@ module Spree pb = Spree::Property.create! name: 'B', presentation: 'B' pc = Spree::Property.create! name: 'C', presentation: 'C' - product.product_properties.create!({ property_id: pa.id, value: '1', position: 1 }, without_protection: true) - product.product_properties.create!({ property_id: pc.id, value: '3', position: 3 }, without_protection: true) - supplier.producer_properties.create!({ property_id: pb.id, value: '2', position: 2 }, without_protection: true) + product.product_properties.create!({ property_id: pa.id, value: '1', position: 1 }) + product.product_properties.create!({ property_id: pc.id, value: '3', position: 3 }) + supplier.producer_properties.create!({ property_id: pb.id, value: '2', position: 2 }) expect(product.properties_including_inherited).to eq( [{ id: pa.id, name: "A", value: '1' }, diff --git a/spec/models/tag_rule/discount_order_spec.rb b/spec/models/tag_rule/discount_order_spec.rb index d4e30a6d95..2a1260f7e3 100644 --- a/spec/models/tag_rule/discount_order_spec.rb +++ b/spec/models/tag_rule/discount_order_spec.rb @@ -31,7 +31,7 @@ describe TagRule::DiscountOrder, type: :model do pending "determining whether a the rule has already been applied to an order" do let!(:order) { create(:order) } - let!(:adjustment) { order.adjustments.create({ amount: 12.34, source: order, originator: tag_rule, label: 'discount' }, without_protection: true) } + let!(:adjustment) { order.adjustments.create({ amount: 12.34, source: order, originator: tag_rule, label: 'discount' }) } before do tag_rule.context = { subject: order } diff --git a/spec/support/seeds.rb b/spec/support/seeds.rb index 75aff1baf8..26cc7a46e0 100644 --- a/spec/support/seeds.rb +++ b/spec/support/seeds.rb @@ -6,10 +6,10 @@ # You can add more entries here if you need them for your tests. if Spree::Country.where(nil).empty? - Spree::Country.create!({ "name" => "Australia", "iso3" => "AUS", "iso" => "AU", "iso_name" => "AUSTRALIA", "numcode" => "36" }, without_protection: true) + Spree::Country.create!({ "name" => "Australia", "iso3" => "AUS", "iso" => "AU", "iso_name" => "AUSTRALIA", "numcode" => "36" }) country = Spree::Country.find_by(name: 'Australia') - Spree::State.create!({ "name" => "Victoria", "abbr" => "Vic", :country => country }, without_protection: true) - Spree::State.create!({ "name" => "New South Wales", "abbr" => "NSW", :country => country }, without_protection: true) + Spree::State.create!({ "name" => "Victoria", "abbr" => "Vic", :country => country }) + Spree::State.create!({ "name" => "New South Wales", "abbr" => "NSW", :country => country }) end # Since the country seeding differs from other environments, the default