From 66bf69b52c562ae228a81a714b77175398a713e4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 27 Dec 2020 12:26:10 +0000 Subject: [PATCH 01/48] Add included column to spree_adjustments table --- ...01227122327_add_included_to_adjustments.rb | 20 +++++++++++++++++++ db/schema.rb | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20201227122327_add_included_to_adjustments.rb diff --git a/db/migrate/20201227122327_add_included_to_adjustments.rb b/db/migrate/20201227122327_add_included_to_adjustments.rb new file mode 100644 index 0000000000..2aebc93706 --- /dev/null +++ b/db/migrate/20201227122327_add_included_to_adjustments.rb @@ -0,0 +1,20 @@ +class AddIncludedToAdjustments < ActiveRecord::Migration + class Spree::Adjustment < ActiveRecord::Base + belongs_to :originator, polymorphic: true + end + + def up + add_column :spree_adjustments, :included, :boolean, default: false + Spree::Adjustment.reset_column_information + + inclusive_tax_rates = Spree::TaxRate.where(included_in_price: true) + + # Set included boolean to true on all adjustments based on price-inclusive tax rates + Spree::Adjustment.where(originator_type: 'Spree::TaxRate', originator_id: inclusive_tax_rates). + update_all(included: true) + end + + def down + remove_column :spree_adjustments, :included + end +end diff --git a/db/schema.rb b/db/schema.rb index fc360b11e1..a0417bd885 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -385,16 +385,17 @@ ActiveRecord::Schema.define(version: 20210115143738) do t.string "label", limit: 255 t.string "source_type", limit: 255 t.integer "adjustable_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "mandatory" t.integer "originator_id" t.string "originator_type", limit: 255 t.boolean "eligible", default: true t.string "adjustable_type", limit: 255 - t.decimal "included_tax", precision: 10, scale: 2, default: 0.0, null: false + t.decimal "included_tax", precision: 10, scale: 2, default: 0.0, null: false t.string "state", limit: 255 t.integer "order_id" + t.boolean "included", default: false end add_index "spree_adjustments", ["adjustable_id"], name: "index_adjustments_on_order_id", using: :btree From 8be18cd05c473207fc9567faec4efd6819e5910c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 27 Dec 2020 12:32:09 +0000 Subject: [PATCH 02/48] Add #included and #additional scopes to Spree::Adjustment We can now do things like: ``` included_tax = order.adjustments.tax.included.sum(:amount) additional_tax = order.adjustments.tax.additional.sum(:amount) ``` --- app/models/spree/adjustment.rb | 2 ++ spec/models/spree/adjustment_spec.rb | 29 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index 942e7fc149..f5e5fe0707 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -70,6 +70,8 @@ module Spree scope :charge, -> { where('amount >= 0') } scope :credit, -> { where('amount < 0') } scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") } + scope :included, -> { where(included: true) } + scope :additional, -> { where(included: false) } scope :enterprise_fee, -> { where(originator_type: 'EnterpriseFee') } scope :admin, -> { where(source_type: nil, originator_type: nil) } diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index 1f77bd725b..cced77f9e8 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -460,5 +460,34 @@ module Spree context "extends LocalizedNumber" do it_behaves_like "a model using the LocalizedNumber module", [:amount] end + + describe "included and additional scopes" do + let!(:zone) { create(:zone_with_member) } + let(:order) { create(:order) } + let(:included_in_price) { true } + let(:tax_rate) { + create(:tax_rate, included_in_price: included_in_price, + calculator: ::Calculator::FlatRate.new(preferred_amount: 0.1)) + } + let(:included) { true } + let(:adjustment) { + create(:adjustment, adjustable: order, source: order, + originator: tax_rate, included: included) + } + + context "when tax is included in price" do + it "is returned by the #included scope" do + expect(Spree::Adjustment.included).to eq [adjustment] + end + end + + context "when tax is additional to the price" do + let(:included) { false } + + it "is returned by the #additional scope" do + expect(Spree::Adjustment.additional).to eq [adjustment] + end + end + end end end From a328a9bc1b1f902cc09f88201dbe1d89f84d44b4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 27 Dec 2020 12:15:35 +0000 Subject: [PATCH 03/48] Use included boolean in tax adjustments --- app/models/spree/tax_rate.rb | 8 +++++++- config/locales/en.yml | 2 ++ lib/spree/core/calculated_adjustments.rb | 12 +++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/models/spree/tax_rate.rb b/app/models/spree/tax_rate.rb index 064baf8852..50abeeb021 100644 --- a/app/models/spree/tax_rate.rb +++ b/app/models/spree/tax_rate.rb @@ -61,7 +61,7 @@ module Spree def adjust(order) label = create_label if included_in_price - if Zone.default_tax.contains? order.tax_zone + if default_zone_or_zone_match? order order.line_items.each { |line_item| create_adjustment(label, line_item, line_item) } else amount = -1 * calculator.compute(order) @@ -89,6 +89,10 @@ module Spree end end + def default_zone_or_zone_match?(order) + Zone.default_tax.contains?(order.tax_zone) || order.tax_zone == zone + end + # Manually apply a TaxRate to a particular amount. TaxRates normally compute against # LineItems or Orders, so we mock out a line item here to fit the interface # that our calculator (usually DefaultTax) expects. @@ -114,6 +118,8 @@ module Spree label = "" label << (name.presence || tax_category.name) + " " label << (show_rate_in_label? ? "#{amount * 100}%" : "") + label << " (#{I18n.t('models.tax_rate.included_in_price')})" if included_in_price? + label end def with_tax_included_in_price diff --git a/config/locales/en.yml b/config/locales/en.yml index 0354b9c4d2..2dff764d14 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -140,6 +140,8 @@ en: models: order_cycle: cloned_order_cycle_name: "COPY OF %{order_cycle}" + tax_rate: + included_in_price: "Included in price" validators: date_time_string_validator: diff --git a/lib/spree/core/calculated_adjustments.rb b/lib/spree/core/calculated_adjustments.rb index 6388369209..301d821642 100644 --- a/lib/spree/core/calculated_adjustments.rb +++ b/lib/spree/core/calculated_adjustments.rb @@ -43,7 +43,8 @@ module Spree order: order_object_for(target), label: label, mandatory: mandatory, - state: state + state: state, + included: tax_included?(self, target) ) end @@ -78,6 +79,15 @@ module Spree private + # Used for setting the #included boolean on tax adjustments. This will be removed in a + # later step, as the responsibility for creating all adjustments related to tax will be + # moved into the Spree::TaxRate class. + def tax_included?(originator, target) + originator.is_a?(Spree::TaxRate) && + originator.included_in_price && + originator.default_zone_or_zone_match?(order_object_for(target)) + end + def order_object_for(target) # Temporary method for adjustments transition. if target.is_a? Spree::Order From 173e502c98b4288580db9f8f0edcfac2432387a8 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 13 Jan 2021 14:46:22 +0000 Subject: [PATCH 04/48] Rename #included scope to #inclusive This method name (#included) is reserved and used internally by ActiveRecord. After updating Ruby, this has changed from a silent warning to a fatal error. --- app/models/spree/adjustment.rb | 2 +- spec/models/spree/adjustment_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index f5e5fe0707..2d5d572110 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -70,7 +70,7 @@ module Spree scope :charge, -> { where('amount >= 0') } scope :credit, -> { where('amount < 0') } scope :return_authorization, -> { where(source_type: "Spree::ReturnAuthorization") } - scope :included, -> { where(included: true) } + scope :inclusive, -> { where(included: true) } scope :additional, -> { where(included: false) } scope :enterprise_fee, -> { where(originator_type: 'EnterpriseFee') } diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index cced77f9e8..bc3acb38ed 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -461,7 +461,7 @@ module Spree it_behaves_like "a model using the LocalizedNumber module", [:amount] end - describe "included and additional scopes" do + describe "inclusive and additional scopes" do let!(:zone) { create(:zone_with_member) } let(:order) { create(:order) } let(:included_in_price) { true } @@ -477,7 +477,7 @@ module Spree context "when tax is included in price" do it "is returned by the #included scope" do - expect(Spree::Adjustment.included).to eq [adjustment] + expect(Spree::Adjustment.inclusive).to eq [adjustment] end end From ddfcda0c0be7ff81a7437f59b78ddb4c11f25070 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 22 Jan 2021 18:50:03 +0000 Subject: [PATCH 05/48] Adapt imported Paypal code The #additional scope from Spree 2.2 is now present, so we can tidy up this conditional. --- app/controllers/spree/paypal_controller.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/controllers/spree/paypal_controller.rb b/app/controllers/spree/paypal_controller.rb index 81f7433c22..9b14ce409e 100644 --- a/app/controllers/spree/paypal_controller.rb +++ b/app/controllers/spree/paypal_controller.rb @@ -15,9 +15,7 @@ module Spree order = current_order || raise(ActiveRecord::RecordNotFound) items = order.line_items.map(&method(:line_item)) - tax_adjustments = order.adjustments.tax - # TODO: Remove in Spree 2.2 - tax_adjustments = tax_adjustments.additional if tax_adjustments.respond_to?(:additional) + tax_adjustments = order.adjustments.tax.additional shipping_adjustments = order.adjustments.shipping order.adjustments.eligible.each do |adjustment| @@ -175,12 +173,8 @@ module Spree def payment_details(items) item_sum = items.sum { |i| i[:Quantity] * i[:Amount][:value] } - # Would use tax_total here, but it can include "included" taxes as well. - # For instance, tax_total would include the 10% GST in Australian stores. - # A quick sum will get us around that little problem. - # TODO: Remove additional check in 2.2 - tax_adjustments = current_order.adjustments.tax - tax_adjustments = tax_adjustments.additional if tax_adjustments.respond_to?(:additional) + + tax_adjustments = current_order.adjustments.tax.additional tax_adjustments_total = tax_adjustments.sum(:amount) if item_sum.zero? From 4d4c055577de58e7faaca804cf0c38f6163e8d31 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 22 Jan 2021 20:38:13 +0000 Subject: [PATCH 06/48] Loosen Spree::Adjustment#tax scope to include any tax adjustments --- app/models/spree/adjustment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index 2d5d572110..0c87668cfe 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -64,7 +64,7 @@ module Spree end end - scope :tax, -> { where(originator_type: 'Spree::TaxRate', adjustable_type: 'Spree::Order') } + scope :tax, -> { where(originator_type: 'Spree::TaxRate') } scope :price, -> { where(adjustable_type: 'Spree::LineItem') } scope :optional, -> { where(mandatory: false) } scope :charge, -> { where('amount >= 0') } From 7940a42e8cfae53145ace922e017b3b27959a4f2 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 22 Jan 2021 20:39:48 +0000 Subject: [PATCH 07/48] Add Spree::Order#all_adjustments scope, which can be used to get all adjustments on an order, and order's line_items, etc, not just adjustments directly on the order itself. --- app/models/spree/order.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index ceb603e275..23bd5ad98f 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -47,6 +47,7 @@ module Spree dependent: :destroy has_many :line_item_adjustments, through: :line_items, source: :adjustments + has_many :all_adjustments, class_name: 'Spree::Adjustment', dependent: :destroy has_many :shipments, dependent: :destroy do def states From ff54426e30e49bde53c51e4f785d1eaf38d6faf4 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 22 Jan 2021 20:41:13 +0000 Subject: [PATCH 08/48] Expand tests on additional and inclusive taxes. --- spec/models/spree/adjustment_spec.rb | 61 +++++++++++++++++++++------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index bc3acb38ed..c95745e2f2 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -461,31 +461,62 @@ module Spree it_behaves_like "a model using the LocalizedNumber module", [:amount] end - describe "inclusive and additional scopes" do + describe "inclusive and additional taxes" do let!(:zone) { create(:zone_with_member) } - let(:order) { create(:order) } + let!(:tax_category) { create(:tax_category, name: "Tax Test") } + let(:distributor) { create(:distributor_enterprise, charges_sales_tax: true) } + let(:order) { create(:order, distributor: distributor) } let(:included_in_price) { true } let(:tax_rate) { - create(:tax_rate, included_in_price: included_in_price, + create(:tax_rate, included_in_price: included_in_price, zone: zone, calculator: ::Calculator::FlatRate.new(preferred_amount: 0.1)) } - let(:included) { true } - let(:adjustment) { - create(:adjustment, adjustable: order, source: order, - originator: tax_rate, included: included) - } + let(:product) { create(:product, tax_category: tax_category) } + let(:variant) { product.variants.first } - context "when tax is included in price" do - it "is returned by the #included scope" do - expect(Spree::Adjustment.inclusive).to eq [adjustment] + describe "tax adjustment creation" do + before do + tax_category.tax_rates << tax_rate + allow(order).to receive(:tax_zone) { zone } + order.line_items << create(:line_item, variant: variant, quantity: 5) + end + + context "with included taxes" do + it "records the tax as included" do + expect(order.all_adjustments.tax.count).to eq 1 + expect(order.all_adjustments.tax.first.included).to be true + end + end + + context "with additional taxes" do + let(:included_in_price) { false } + + it "records the tax as additional" do + expect(order.all_adjustments.tax.count).to eq 1 + expect(order.all_adjustments.tax.first.included).to be false + end end end - context "when tax is additional to the price" do - let(:included) { false } + describe "inclusive and additional scopes" do + let(:included) { true } + let(:adjustment) { + create(:adjustment, adjustable: order, source: order, + originator: tax_rate, included: included) + } - it "is returned by the #additional scope" do - expect(Spree::Adjustment.additional).to eq [adjustment] + context "when tax is included in price" do + it "is returned by the #included scope" do + expect(Spree::Adjustment.inclusive).to eq [adjustment] + end + end + + context "when tax is additional to the price" do + let(:included) { false } + + it "is returned by the #additional scope" do + expect(Spree::Adjustment.additional).to eq [adjustment] + end end end end From 4ec68dcd85eea1c2d103a7257baea332d8104fca Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 29 Jan 2021 02:37:35 +0000 Subject: [PATCH 09/48] Update migration to include TaxRate model --- db/migrate/20201227122327_add_included_to_adjustments.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/migrate/20201227122327_add_included_to_adjustments.rb b/db/migrate/20201227122327_add_included_to_adjustments.rb index 2aebc93706..2ccbeab2a3 100644 --- a/db/migrate/20201227122327_add_included_to_adjustments.rb +++ b/db/migrate/20201227122327_add_included_to_adjustments.rb @@ -1,4 +1,6 @@ class AddIncludedToAdjustments < ActiveRecord::Migration + class Spree::TaxRate < ActiveRecord::Base; end + class Spree::Adjustment < ActiveRecord::Base belongs_to :originator, polymorphic: true end From 14cee0e45d15e711d877db9954ebfd317cb630ad Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 3 Feb 2021 11:41:23 +0100 Subject: [PATCH 10/48] Add new Feature class to toggle based on a closure This enables toggling features as best fits us in each case. With this new approach we can then toggle :customer_balance to an entire instance, which is what we want in France. --- config/initializers/feature_toggles.rb | 10 +++- lib/open_food_network/feature_toggle.rb | 25 ++++++++-- spec/initializers/feature_toggles_spec.rb | 47 +++++++++++++++++++ .../open_food_network/feature_toggle_spec.rb | 26 ++++++++++ 4 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 spec/initializers/feature_toggles_spec.rb diff --git a/config/initializers/feature_toggles.rb b/config/initializers/feature_toggles.rb index 13d083979c..9c31940462 100644 --- a/config/initializers/feature_toggles.rb +++ b/config/initializers/feature_toggles.rb @@ -1,5 +1,11 @@ require 'open_food_network/feature_toggle' -beta_testers = ENV['BETA_TESTERS']&.split(/[\s,]+/) +beta_testers = ENV['BETA_TESTERS']&.split(/[\s,]+/) || [] -OpenFoodNetwork::FeatureToggle.enable(:customer_balance, beta_testers) +OpenFoodNetwork::FeatureToggle.enable(:customer_balance) do |user| + if beta_testers == ['all'] + true + else + beta_testers.include?(user.email) + end +end diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index 5ee51a82f9..fb62be5553 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -30,11 +30,14 @@ module OpenFoodNetwork new.enabled?(feature_name, user) end - def self.enable(feature_name, user_emails) - return unless user_emails.present? - + def self.enable(feature_name, user_emails = nil, &block) Thread.current[:features] ||= {} - Thread.current[:features][feature_name] = Feature.new(user_emails) + + if user_emails.nil? + Thread.current[:features][feature_name] = BlockFeature.new(block) + else + Thread.current[:features][feature_name] = Feature.new(user_emails) + end end def initialize @@ -86,4 +89,18 @@ module OpenFoodNetwork false end end + + class BlockFeature + def initialize(block) + @block = block + end + + def enabled?(user) + block.call(user) + end + + private + + attr_reader :block + end end diff --git a/spec/initializers/feature_toggles_spec.rb b/spec/initializers/feature_toggles_spec.rb new file mode 100644 index 0000000000..daea8a2f73 --- /dev/null +++ b/spec/initializers/feature_toggles_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe 'config/initializers/feature_toggles.rb' do + let(:user) { build(:user) } + + around do |example| + original = ENV['BETA_TESTERS'] + example.run + ENV['BETA_TESTERS'] = original + end + + context 'when beta_testers is ["all"]' do + before { ENV['BETA_TESTERS'] = 'all' } + + it 'returns true' do + require './config/initializers/feature_toggles' # execute the initializer's code block + + enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) + expect(enabled).to eq(true) + end + end + + context 'when beta_testers is a list of emails' do + context 'and the user is in the list' do + let(:other_user) { build(:user) } + before { ENV['BETA_TESTERS'] = "#{user.email}, #{other_user.email}" } + + it 'enables the feature' do + require './config/initializers/feature_toggles' # execute the initializer's code block + + enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) + expect(enabled).to eq(true) + end + end + + context 'and the user is not in the list' do + before { ENV['BETA_TESTERS'] = '' } + + it 'disables the feature' do + require './config/initializers/feature_toggles' # execute the initializer's code block + + enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) + expect(enabled).to eq(false) + end + end + end +end diff --git a/spec/lib/open_food_network/feature_toggle_spec.rb b/spec/lib/open_food_network/feature_toggle_spec.rb index 73407d671d..f8074410c1 100644 --- a/spec/lib/open_food_network/feature_toggle_spec.rb +++ b/spec/lib/open_food_network/feature_toggle_spec.rb @@ -48,5 +48,31 @@ module OpenFoodNetwork end end end + + context 'when passing in a block' do + let(:user) { build(:user) } + + context 'and the block does not specify arguments' do + before do + FeatureToggle.enable(:foo) { 'return value' } + end + + it "returns the block's return value" do + expect(FeatureToggle.enabled?(:foo, user)).to eq('return value') + end + end + + context 'and the block specifies arguments' do + let(:users) { [user.email] } + + before do + FeatureToggle.enable(:foo) { |user| users.include?(user.email) } + end + + it "returns the block's return value" do + expect(FeatureToggle.enabled?(:foo, user)).to eq(true) + end + end + end end end From d6350c3d0b96f2e5fdafa1a8bfdd6b3c4969d990 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 3 Feb 2021 11:47:27 +0100 Subject: [PATCH 11/48] Remove deprecated Feature class implementation This became dead code now. --- lib/open_food_network/feature_toggle.rb | 35 +++++-------------- .../open_food_network/feature_toggle_spec.rb | 20 ----------- 2 files changed, 8 insertions(+), 47 deletions(-) diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index fb62be5553..f57e740bc4 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -30,14 +30,9 @@ module OpenFoodNetwork new.enabled?(feature_name, user) end - def self.enable(feature_name, user_emails = nil, &block) + def self.enable(feature_name, &block) Thread.current[:features] ||= {} - - if user_emails.nil? - Thread.current[:features][feature_name] = BlockFeature.new(block) - else - Thread.current[:features][feature_name] = Feature.new(user_emails) - end + Thread.current[:features][feature_name] = Feature.new(block) end def initialize @@ -71,26 +66,6 @@ module OpenFoodNetwork end class Feature - def initialize(users = []) - @users = users - end - - def enabled?(user) - users.include?(user.email) - end - - private - - attr_reader :users - end - - class NullFeature - def enabled?(_user) - false - end - end - - class BlockFeature def initialize(block) @block = block end @@ -103,4 +78,10 @@ module OpenFoodNetwork attr_reader :block end + + class NullFeature + def enabled?(_user) + false + end + end end diff --git a/spec/lib/open_food_network/feature_toggle_spec.rb b/spec/lib/open_food_network/feature_toggle_spec.rb index f8074410c1..d9904b0fd6 100644 --- a/spec/lib/open_food_network/feature_toggle_spec.rb +++ b/spec/lib/open_food_network/feature_toggle_spec.rb @@ -32,26 +32,6 @@ module OpenFoodNetwork context 'when specifying users' do let(:user) { build(:user) } - context 'and the feature is enabled for them' do - before { FeatureToggle.enable(:foo, [user.email]) } - - it 'returns true' do - expect(FeatureToggle.enabled?(:foo, user)).to eq(true) - end - end - - context 'and the feature is disabled for them' do - before { FeatureToggle.enable(:foo, []) } - - it 'returns false' do - expect(FeatureToggle.enabled?(:foo, user)).to eq(false) - end - end - end - - context 'when passing in a block' do - let(:user) { build(:user) } - context 'and the block does not specify arguments' do before do FeatureToggle.enable(:foo) { 'return value' } From 502ef8f6f2e73d611d2dd6f4323d1e40b04295b1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 4 Feb 2021 12:52:07 +0100 Subject: [PATCH 12/48] Use as many space as available Each row is sixteen long, use all space (five + eleven = sixteen) --- .../admin/subscriptions/_review.html.haml | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/app/views/admin/subscriptions/_review.html.haml b/app/views/admin/subscriptions/_review.html.haml index 0bcaf2eab2..f7f1cb2c7f 100644 --- a/app/views/admin/subscriptions/_review.html.haml +++ b/app/views/admin/subscriptions/_review.html.haml @@ -3,47 +3,47 @@ .row .eight.columns.alpha .row - .six.columns.alpha + .five.columns.alpha %h3= t('.details') - .two.columns.omega.text-right + .eleven.columns.omega %input#edit-details{ type: "button", value: t(:edit), ng: { click: "setView('details')" } } .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.customer') - .five.columns.omega {{ subscription.customer().email }} + .eleven.columns.omega {{ subscription.customer().email }} .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.schedule') - .five.columns.omega {{ subscription.schedule().name }} + .eleven.columns.omega {{ subscription.schedule().name }} .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.payment_method') - .five.columns.omega {{ subscription.paymentMethod().name }} + .eleven.columns.omega {{ subscription.paymentMethod().name }} .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.shipping_method') - .five.columns.omega {{ subscription.shippingMethod().name }} + .eleven.columns.omega {{ subscription.shippingMethod().name }} .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.begins_at') - .five.columns.omega {{ subscription.begins_at }} + .eleven.columns.omega {{ subscription.begins_at }} .row.margin-bottom-30 - .three.columns.alpha + .five.columns.alpha %strong= t('admin.ends_at') - .five.columns.omega {{ subscription.ends_at || ('ongoing' | t) }} + .eleven.columns.omega {{ subscription.ends_at || ('ongoing' | t) }} .row - .six.columns.alpha + .five.columns.alpha %h3= t('.address') - .two.columns.omega.text-right + .eleven.columns.omega %input#edit-address{ type: "button", value: t(:edit), ng: { click: "setView('address')" } } .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.bill_address') - .five.columns.omega {{ formatAddress(subscription.bill_address) }} + .eleven.columns.omega {{ formatAddress(subscription.bill_address) }} .row - .three.columns.alpha + .five.columns.alpha %strong= t('admin.ship_address') - .five.columns.omega {{ formatAddress(subscription.ship_address) }} + .eleven.columns.omega {{ formatAddress(subscription.ship_address) }} .one.column   @@ -52,7 +52,7 @@ .row .five.columns.alpha %h3= t('.products') - .two.columns.omega.text-right + .eleven.columns.omega %input#edit-products{ type: "button", value: t(:edit), ng: { click: "setView('products')" } } .row .seven.columns.alpha.omega From ef42653feee2a710883b14bad424b234cf7c84f3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 4 Feb 2021 12:53:12 +0100 Subject: [PATCH 13/48] Use all available space Don't need to put the table into a `.seven.columns.alpha.omega` div: use the maximum available space. --- .../admin/subscriptions/_review.html.haml | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/app/views/admin/subscriptions/_review.html.haml b/app/views/admin/subscriptions/_review.html.haml index f7f1cb2c7f..f7b716684a 100644 --- a/app/views/admin/subscriptions/_review.html.haml +++ b/app/views/admin/subscriptions/_review.html.haml @@ -55,44 +55,43 @@ .eleven.columns.omega %input#edit-products{ type: "button", value: t(:edit), ng: { click: "setView('products')" } } .row - .seven.columns.alpha.omega - %table#subscription-line-items.admin-subscription-review-subscription-line-items - %colgroup - %col{:style => "width: 62%;"}/ - %col{:style => "width: 14%;"}/ - %col{:style => "width: 10%;"}/ - %col{:style => "width: 14%;"}/ - %thead - %tr - %th= t(:item_description) - %th.price= t(:price) - %th.quantity= t(:qty) - %th.total - %span= t(:total) - %tbody - %tr.item{ id: "sli_{{$index}}", ng: { repeat: "item in subscription.subscription_line_items | filter:{ _destroy: '!true' }", class: { even: 'even', odd: 'odd' } } } - %td - .description {{ item.description }} - .not-in-open-and-upcoming-order-cycles-warning{ ng: { if: '!item.in_open_and_upcoming_order_cycles' } } - = t(".no_open_or_upcoming_order_cycle") - %td.price.align-center {{ item.price_estimate | localizeCurrency }} - %td.quantity {{ item.quantity }} - %td.total.align-center {{ (item.price_estimate * item.quantity) | localizeCurrency }} - %tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"} - %tr#subtotal-row - %td{:colspan => "3"} - %b - = t(:subtotal) - \: - %td.total.align-center - %span {{ subscription.estimatedSubtotal() | localizeCurrency }} - %tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"} - %tr - %td{:colspan => "3"} - %b - = t(:order_total_price) - \: - %td.total.align-center - %span#order_form_total {{ subscription.estimatedTotal() | localizeCurrency }} - %p.notice - = t "this_is_an_estimate", scope: 'admin.subscriptions.subscription_line_items' + %table#subscription-line-items.admin-subscription-review-subscription-line-items + %colgroup + %col{:style => "width: 62%;"}/ + %col{:style => "width: 14%;"}/ + %col{:style => "width: 10%;"}/ + %col{:style => "width: 14%;"}/ + %thead + %tr + %th= t(:item_description) + %th.price= t(:price) + %th.quantity= t(:qty) + %th.total + %span= t(:total) + %tbody + %tr.item{ id: "sli_{{$index}}", ng: { repeat: "item in subscription.subscription_line_items | filter:{ _destroy: '!true' }", class: { even: 'even', odd: 'odd' } } } + %td + .description {{ item.description }} + .not-in-open-and-upcoming-order-cycles-warning{ ng: { if: '!item.in_open_and_upcoming_order_cycles' } } + = t(".no_open_or_upcoming_order_cycle") + %td.price.align-center {{ item.price_estimate | localizeCurrency }} + %td.quantity {{ item.quantity }} + %td.total.align-center {{ (item.price_estimate * item.quantity) | localizeCurrency }} + %tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"} + %tr#subtotal-row + %td{:colspan => "3"} + %b + = t(:subtotal) + \: + %td.total.align-center + %span {{ subscription.estimatedSubtotal() | localizeCurrency }} + %tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"} + %tr + %td{:colspan => "3"} + %b + = t(:order_total_price) + \: + %td.total.align-center + %span#order_form_total {{ subscription.estimatedTotal() | localizeCurrency }} + %p.notice + = t "this_is_an_estimate", scope: 'admin.subscriptions.subscription_line_items' From 88e22a78c2a9c213c6dce03f351ac39bf792c1fb Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 4 Feb 2021 13:16:03 +0100 Subject: [PATCH 14/48] Execute Ruby file in each test example Kernel#require prevented this from happening thus, the file was only loaded once so tests were passing so far by pure luck. --- spec/initializers/feature_toggles_spec.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spec/initializers/feature_toggles_spec.rb b/spec/initializers/feature_toggles_spec.rb index daea8a2f73..0051c084a4 100644 --- a/spec/initializers/feature_toggles_spec.rb +++ b/spec/initializers/feature_toggles_spec.rb @@ -1,6 +1,12 @@ require 'spec_helper' describe 'config/initializers/feature_toggles.rb' do + # Executes the initializer's code block by reading the Ruby file. Note that `Kernel#require` would + # prevent this from happening twice. + subject(:execute_initializer) do + load Rails.root.join('config/initializers/feature_toggles.rb') + end + let(:user) { build(:user) } around do |example| @@ -13,7 +19,7 @@ describe 'config/initializers/feature_toggles.rb' do before { ENV['BETA_TESTERS'] = 'all' } it 'returns true' do - require './config/initializers/feature_toggles' # execute the initializer's code block + execute_initializer enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) expect(enabled).to eq(true) @@ -26,7 +32,7 @@ describe 'config/initializers/feature_toggles.rb' do before { ENV['BETA_TESTERS'] = "#{user.email}, #{other_user.email}" } it 'enables the feature' do - require './config/initializers/feature_toggles' # execute the initializer's code block + execute_initializer enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) expect(enabled).to eq(true) @@ -37,7 +43,7 @@ describe 'config/initializers/feature_toggles.rb' do before { ENV['BETA_TESTERS'] = '' } it 'disables the feature' do - require './config/initializers/feature_toggles' # execute the initializer's code block + execute_initializer enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) expect(enabled).to eq(false) From 655fe887f9a04864d700472f84227f49896d2ae1 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 4 Feb 2021 13:19:04 +0100 Subject: [PATCH 15/48] Distinguish user not present and list empty This is a bit more thorough. --- spec/initializers/feature_toggles_spec.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/initializers/feature_toggles_spec.rb b/spec/initializers/feature_toggles_spec.rb index 0051c084a4..0433d4508b 100644 --- a/spec/initializers/feature_toggles_spec.rb +++ b/spec/initializers/feature_toggles_spec.rb @@ -27,8 +27,9 @@ describe 'config/initializers/feature_toggles.rb' do end context 'when beta_testers is a list of emails' do + let(:other_user) { build(:user) } + context 'and the user is in the list' do - let(:other_user) { build(:user) } before { ENV['BETA_TESTERS'] = "#{user.email}, #{other_user.email}" } it 'enables the feature' do @@ -40,6 +41,17 @@ describe 'config/initializers/feature_toggles.rb' do end context 'and the user is not in the list' do + before { ENV['BETA_TESTERS'] = "#{other_user.email}" } + + it 'disables the feature' do + execute_initializer + + enabled = OpenFoodNetwork::FeatureToggle.enabled?(:customer_balance, user) + expect(enabled).to eq(false) + end + end + + context 'and the list is empty' do before { ENV['BETA_TESTERS'] = '' } it 'disables the feature' do From 52fc9cee312262c956ab8f96cbed870ff5cb3684 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Sat, 6 Feb 2021 00:14:49 +1100 Subject: [PATCH 18/48] Updating translations for config/locales/en_CA.yml --- config/locales/en_CA.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/en_CA.yml b/config/locales/en_CA.yml index 1e12e3931f..5af9f594e3 100644 --- a/config/locales/en_CA.yml +++ b/config/locales/en_CA.yml @@ -2950,6 +2950,7 @@ en_CA: display_currency: "Display currency" choose_currency: "Choose Currency" mail_method_settings: "Mail Method Settings" + mail_settings_notice_html: "Some of the following settings can't be edited and are listed here just for debugging purposes. Changes can be made by updating the instance's secrets and provisioning them using ofn-install. Reach out to the OFN global team for further details." general: "General" enable_mail_delivery: "Enable Mail Delivery" send_mails_as: "Send Mails As" @@ -3466,6 +3467,8 @@ en_CA: cancel_email_for_shop: greeting: "Dear %{name}," subject: "Cancellation of Order" + intro: "A customer has cancelled ther order #%{number}." + view_cancelled_order: "View cancelled order" confirm_email: subject: "Order Confirmation" invoice_email: From 5eb88f60e44fe2162b28844d62207182f8764b3b Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Sat, 6 Feb 2021 00:23:51 +1100 Subject: [PATCH 19/48] Updating translations for config/locales/fr_CA.yml --- config/locales/fr_CA.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/locales/fr_CA.yml b/config/locales/fr_CA.yml index 3eced7a54c..a7af33b68d 100644 --- a/config/locales/fr_CA.yml +++ b/config/locales/fr_CA.yml @@ -2321,6 +2321,8 @@ fr_CA: payment_processing_failed: "Le paiement n'a pas pu être traité, veuillez vérifier les informations saisies" payment_method_not_supported: "Cette méthode de paiement n'est pas maintenue. Veuillez en sélectionner une autre." payment_updated: "Paiement mis à jour" + cannot_perform_operation: "Le paiement n'a pas pu être mis à jour." + action_required: "Une action est requise" inventory_settings: "Paramètres catalogue boutique" tag_rules: "Règles de tag" shop_preferences: "Préférences boutique" @@ -2599,6 +2601,8 @@ fr_CA: processing: "en traitement" void: "faire un avoir" invalid: "invalide" + quantity_adjusted: "Le stock disponible est insuffisant. La quantité a été mise à jour en fonction du stock restant." + quantity_unchanged: "La quantité n'a pas été modifiée." resend_user_email_confirmation: resend: "Renvoyer" sending: "Renvoyer" @@ -2960,6 +2964,7 @@ fr_CA: display_currency: "Afficher la devise" choose_currency: "Choisir la devise" mail_method_settings: "Paramètre méthode mail" + mail_settings_notice_html: "Certains champs ne peuvent pas être modifiés car ils sont utilisés uniquement pour déboggage. Les modifications peuvent être réalisées par un développeur via ofn-install." general: "Général" enable_mail_delivery: "Permettre distribution des mails" send_mails_as: "Envoyer les mails en tant que" @@ -3476,6 +3481,8 @@ fr_CA: cancel_email_for_shop: greeting: "Bonjour %{name}," subject: "Annulation de Commande" + intro: "Un acheteur a annulé sa commande # %{number}." + view_cancelled_order: "Voir la commande annulée" confirm_email: subject: "Confirmation de commande" invoice_email: @@ -3495,6 +3502,10 @@ fr_CA: subject: "Reprendre" confirmation_instructions: subject: "Veuillez confirmer votre compte" + payment_mailer: + authorize_payment: + subject: "Veuillez autoriser votre paiement à %{distributor} on OFN." + instructions: "Votre paiement de %{amount} to %{distributor} demande une autorisation additionnelle. Veuillez suivre ce lien afin d'autoriser votre paiement:" shipment_mailer: shipped_email: dear_customer: "Cher Acheteur," From 5c96b3e070a42b0ea54679ad61c5f705cded023b Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Sat, 6 Feb 2021 03:50:32 +1100 Subject: [PATCH 20/48] Updating translations for config/locales/en_IE.yml --- config/locales/en_IE.yml | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/config/locales/en_IE.yml b/config/locales/en_IE.yml index fc80e2ce82..10da03f91a 100644 --- a/config/locales/en_IE.yml +++ b/config/locales/en_IE.yml @@ -289,11 +289,16 @@ en_IE: create_and_add_another: "Create and Add Another" create: "Create" cancel: "Cancel" + resume: "Resume" save: "Save" edit: "Edit" update: "Update" delete: "Delete" add: "Add" + cut: "Cut" + paste: "Paste" + destroy: "Destroy" + rename: "Rename" admin: begins_at: Begins At begins_on: Begins On @@ -352,6 +357,7 @@ en_IE: has_n_rules: "has %{num} rules" unsaved_confirm_leave: "There are unsaved changed on this page. Continue without saving?" unsaved_changes: "You have unsaved changes" + available_units: "Available Units" shopfront_settings: embedded_shopfront_settings: "Embedded Shopfront Settings" enable_embedded_shopfronts: "Enable Embedded Shopfronts" @@ -411,6 +417,7 @@ en_IE: search_by_email: "Search by email/code..." guest_label: "Guest checkout" credit_owed: "Credit Owed" + balance_due: "Balance Due" destroy: has_associated_orders: "Delete failed: customer has associated orders with this shop" contents: @@ -599,6 +606,8 @@ en_IE: controls: back_to_my_inventory: Back to my inventory orders: + edit: + order_sure_want_to: Are you sure you want to %{event} this order? invoice_email_sent: 'Invoice email has been sent' order_email_resent: 'Order email has been resent' bulk_management: @@ -647,6 +656,7 @@ en_IE: invoice_text: Add customized text at the end of invoices terms_and_conditions: "Terms and Conditions" remove_terms_and_conditions: "Remove File" + uploaded_on: "uploaded on" contact: name: Name name_placeholder: eg. Amanda Plum @@ -755,6 +765,7 @@ en_IE: is displayed on your shop only when you have no active order cycles (ie. shop is closed). shopfront_category_ordering: "Shopfront Category Ordering" + shopfront_category_ordering_note: "(top to bottom)" open_date: "Open Date" close_date: "Close Date" social: @@ -1164,6 +1175,7 @@ en_IE: cart: "cart" message_html: "You have an order for this order cycle already. Check the %{cart} to see the items you ordered before. You can also cancel items as long as the order cycle is open." terms_and_conditions: + message_html: "I agree to the seller's %{terms_and_conditions_link}." link_text: "Terms and Conditions" failed: "The checkout failed. Please let us know so that we can process your order." shops: @@ -1557,6 +1569,7 @@ en_IE: shopping_groups_part_of: "is part of:" shopping_producers_of_hub: "%{hub}'s producers:" enterprises_next_closing: "Next order closing" + enterprises_currently_open: "Orders are currently open" enterprises_ready_for: "Ready for" enterprises_choose: "Choose when you want your order:" maps_open: "Open" @@ -1578,6 +1591,7 @@ en_IE: hubs_distance: Closest to hubs_distance_filter: "Show me shops near %{location}" shop_changeable_orders_alert_html: + one: Your order with %{shop} / %{order} is open for review. You can make changes until %{oc_close}. few: You have %{count} orders with %{shop} currently open for review. You can make changes until %{oc_close}. many: You have %{count} orders with %{shop} currently open for review. You can make changes until %{oc_close}. other: You have %{count} orders with %{shop} currently open for review. You can make changes until %{oc_close}. @@ -1725,6 +1739,7 @@ en_IE: orders_could_not_cancel: "Sorry, the order could not be cancelled" orders_cannot_remove_the_final_item: "Cannot remove the final item from an order, please cancel the order instead." orders_bought_items_notice: + one: An additional item is already confirmed for this order cycle few: "%{count} additional items already confirmed for this order cycle" many: "%{count} additional items already confirmed for this order cycle" other: "%{count} additional items already confirmed for this order cycle" @@ -2071,6 +2086,7 @@ en_IE: spree_classification_primary_taxon_error: "Taxon %{taxon} is the primary taxon of %{product} and cannot be deleted" spree_order_availability_error: "Distributor or order cycle cannot supply the products in your cart" spree_order_populator_error: "That distributor or order cycle can't supply all the products in your cart. Please choose another." + spree_order_cycle_error: "Please choose an order cycle for this order." spree_order_populator_availability_error: "That product is not available from the chosen distributor or order cycle." spree_distributors_error: "At least one hub must be selected" spree_user_enterprise_limit_error: "^%{email} is not permitted to own any more enterprises (limit is %{enterprise_limit})." @@ -2303,6 +2319,8 @@ en_IE: payment_processing_failed: "Payment could not be processed, please check the details you entered" payment_method_not_supported: "That payment method is unsupported. Please choose another one." payment_updated: "Payment Updated" + cannot_perform_operation: "Could not update the payment" + action_required: "Action required" inventory_settings: "Inventory Settings" tag_rules: "Tag Rules" shop_preferences: "Shop Preferences" @@ -2363,6 +2381,7 @@ en_IE: js: saving: 'Saving...' changes_saved: 'Changes saved.' + authorising: "Authorising..." save_changes_first: Save changes first. all_changes_saved: All changes saved unsaved_changes: You have unsaved changes @@ -2378,6 +2397,7 @@ en_IE: resolve_errors: Please resolve the following errors more_items: "+ %{count} More" default_card_updated: Default Card Updated + default_card_voids_auth: Changing your default card will remove shops' existing authorizations to charge it. You can re-authorize shops after updating the default card. Do you wish to change the default card?" cart: add_to_cart_failed: > There was a problem adding this product to the cart. Perhaps it has become @@ -2407,6 +2427,14 @@ en_IE: By creating rules related to a specific customer tag, you can override the default behaviour (whether it be to show or to hide items) for customers with the specified tag. + terms_and_conditions_info: + title: "Uploading Terms and Conditions" + message_1: "Terms and Conditions are the contract between you, the seller, and the shopper. If you upload a file here shoppers must accept your Terms and Conditions in order to complete checkout. For the shopper this will appear as a checkbox at checkout that must be checked in order to proceed with checkout. We highly recommend you upload Terms and Conditions in alignment with national legislation." + message_2: "Shoppers will only be required to accept Terms and Conditions once. However if you change you Terms and Conditions shoppers will again be required to accept them before they can checkout." + terms_and_conditions_warning: + title: "Uploading Terms and Conditions" + message_1: "All your buyers will have to agree to them once at checkout. If you update the file, all your buyers will have to agree to them again at checkout." + message_2: "For buyers with subscriptions, you need to email them the Terms and Conditions (or the changes to them) for now, nothing will notify them about these new Terms and Conditions." panels: save: SAVE saved: SAVED @@ -2567,6 +2595,8 @@ en_IE: processing: "processing" void: "void" invalid: "invalid" + quantity_adjusted: "Insufficient stock available. Line item updated to maximum available quantity." + quantity_unchanged: "Quantity unchanged from previous amount." resend_user_email_confirmation: resend: "Resend" sending: "Resend..." @@ -2871,6 +2901,8 @@ en_IE: delete: "Delete" cannot_set_shipping_method_without_address: "Cannot set shipping method until customer details are provided." no_tracking_present: "No tracking details provided." + tracking: "Tracking" + tracking_number: "Tracking Number" order_total: "Order Total" customer_details: "Customer Details" customer_search: "Customer Search" @@ -2904,6 +2936,8 @@ en_IE: server: "Server" test_mode: "Test Mode" logourl: "Logourl" + are_you_sure_delete: "Are you sure you want to delete this record?" + confirm_delete: "Confirm Deletion" configurations: "Configurations" general_settings: "General Settings" site_name: "Site Name" @@ -2923,6 +2957,7 @@ en_IE: display_currency: "Display currency" choose_currency: "Choose Currency" mail_method_settings: "Mail Method Settings" + mail_settings_notice_html: "Some of the following settings can't be edited and are listed here just for debugging purposes. Changes can be made by updating the instance's secrets and provisioning them using ofn-install. Reach out to the OFN global team for further details." general: "General" enable_mail_delivery: "Enable Mail Delivery" send_mails_as: "Send Mails As" @@ -3025,6 +3060,7 @@ en_IE: shared: error_messages: errors_prohibited_this_record_from_being_saved: + one: "1 error prohibited this record from being saved:" few: "%{count} errors prohibited this record from being saved:" many: "%{count} errors prohibited this record from being saved:" other: "%{count} errors prohibited this record from being saved:" @@ -3036,6 +3072,7 @@ en_IE: payment_state: "Payment County" errors: messages: + included_price_validation: "cannot be selected unless you have set a Default Tax Zone" blank: "can't be blank" layouts: admin: @@ -3246,6 +3283,13 @@ en_IE: deactivation_warning: "De-activating a payment method can make the payment method disappear from your list. Alternatively, you can hide a payment method from the checkout page by setting the option 'Display' to 'back office only'." providers: provider: "Provider" + check: "Cash/EFT/etc. (payments for which automatic validation is not required)" + pin: "Pin Payments" + paypalexpress: "PayPal Express" + stripeconnect: "Stripe" + stripesca: "Stripe SCA" + bogus: "Bogus" + bogussimple: "BogusSimple" payments: source_forms: stripe: @@ -3430,6 +3474,8 @@ en_IE: cancel_email_for_shop: greeting: "Dear %{name}," subject: "Cancellation of Order" + intro: "A customer has cancelled their order #%{number}." + view_cancelled_order: "View cancelled order" confirm_email: subject: "Order Confirmation" invoice_email: @@ -3448,6 +3494,10 @@ en_IE: subject: "Reset password instructions" confirmation_instructions: subject: "Please confirm your OFN account" + payment_mailer: + authorize_payment: + subject: "Please authorize your payment to %{distributor} on OFN" + instructions: "Your payment of %{amount} to %{distributor} requires additional authentication. Please visit the following URL to authorize your payment:" shipment_mailer: shipped_email: dear_customer: "Dear Customer," @@ -3484,7 +3534,23 @@ en_IE: paused: paused canceled: cancelled paypal: + already_refunded: "This payment has been refunded and no further action can be taken on it." + no_payment_via_admin_backend: "You cannot charge PayPal accounts through the admin backend at this time." + transaction: "PayPal Transaction" + payer_id: "Payer ID" + transaction_id: "Transaction ID" + token: "Token" + refund: "Refund" refund_amount: "Amount" + original_amount: "Original amount: %{amount}" + refund_successful: "PayPal refund successful" + refund_unsuccessful: "PayPal refund unsuccessful" + actions: + refund: "Refund" + flash: + cancel: "Don't want to use PayPal? No problems." + connection_failed: "Could not connect to PayPal." + generic_error: "PayPal failed. %{reasons}" users: form: account_settings: Account Settings @@ -3523,9 +3589,11 @@ en_IE: delete?: Delete? cards: authorised_shops: Authorised Shops + authorised_shops_agreement: This is the list of shops which are permitted to charge your default credit card for any subscriptions (ie. repeating orders) you may have. Your card details will be kept secure and will not be shared with shop owners. You will always be notified when you are charged. By checking the box for a shop, you are agreeing to authorise that shop to send instructions to the financial institution that issued your card to take payments in accordance with the terms of any subscription you create with that shop. saved_cards_popover: This is the list of cards you have opted to save for later use. Your 'default' will be selected automatically when you checkout an order, and can be charged by any shops you have allowed to do so (see right). authorised_shops: shop_name: "Shop Name" + allow_charges?: "Allow Charges to Default Card?" localized_number: invalid_format: has an invalid format. Please enter a number. api: From 8d6468dab1f5ad792e7239ee3056753c78651c92 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 7 Feb 2021 13:39:39 +0000 Subject: [PATCH 21/48] Remove dead code: Shipment#display_total_cost --- app/models/spree/shipment.rb | 4 ---- spec/models/spree/shipment_spec.rb | 7 ------- 2 files changed, 11 deletions(-) diff --git a/app/models/spree/shipment.rb b/app/models/spree/shipment.rb index 67d8e5e935..8afc37aa6a 100644 --- a/app/models/spree/shipment.rb +++ b/app/models/spree/shipment.rb @@ -168,10 +168,6 @@ module Spree cost + item_cost end - def display_total_cost - Spree::Money.new(total_cost, currency: currency) - end - def editable_by?(_user) !shipped? end diff --git a/spec/models/spree/shipment_spec.rb b/spec/models/spree/shipment_spec.rb index f5e846bca6..d60177ac7e 100644 --- a/spec/models/spree/shipment_spec.rb +++ b/spec/models/spree/shipment_spec.rb @@ -50,13 +50,6 @@ describe Spree::Shipment do end end - context "display_total_cost" do - it "retuns a Spree::Money" do - allow(shipment).to receive(:total_cost) { 21.22 } - expect(shipment.display_total_cost).to eq Spree::Money.new(21.22) - end - end - it "#item_cost" do shipment = Spree::Shipment.new( order: build_stubbed(:order_with_totals, line_items: [build_stubbed(:line_item)]) From 14530ddbc5b17abc5cdb34742e8f2fc70b9eba35 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 7 Feb 2021 13:40:31 +0000 Subject: [PATCH 22/48] Remove dead code: Shipment#total_cost --- app/models/spree/shipment.rb | 4 ---- spec/models/spree/shipment_spec.rb | 6 ------ 2 files changed, 10 deletions(-) diff --git a/app/models/spree/shipment.rb b/app/models/spree/shipment.rb index 8afc37aa6a..239430e07e 100644 --- a/app/models/spree/shipment.rb +++ b/app/models/spree/shipment.rb @@ -164,10 +164,6 @@ module Spree Spree::Money.new(item_cost, currency: currency) end - def total_cost - cost + item_cost - end - def editable_by?(_user) !shipped? end diff --git a/spec/models/spree/shipment_spec.rb b/spec/models/spree/shipment_spec.rb index d60177ac7e..9fecb237b9 100644 --- a/spec/models/spree/shipment_spec.rb +++ b/spec/models/spree/shipment_spec.rb @@ -174,12 +174,6 @@ describe Spree::Shipment do end end - it '#total_cost' do - allow(shipment).to receive_messages cost: 5.0 - allow(shipment).to receive_messages item_cost: 50.0 - expect(shipment.total_cost).to eql(55.0) - end - context "#update!" do shared_examples_for "immutable once shipped" do it "should remain in shipped state once shipped" do From f97fd8f8a7853bca5a01f1acad24fa344da61d4a Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 02:01:06 +1100 Subject: [PATCH 23/48] Updating translations for config/locales/de_DE.yml --- config/locales/de_DE.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/de_DE.yml b/config/locales/de_DE.yml index 0adcac5365..69fab87079 100644 --- a/config/locales/de_DE.yml +++ b/config/locales/de_DE.yml @@ -2960,6 +2960,7 @@ de_DE: display_currency: "Währung anzeigen" choose_currency: "Währung auswählen" mail_method_settings: "E-Mail-Methodeneinstellungen" + mail_settings_notice_html: "Einige der folgenden Einstellungen können nicht geändert werden und werden hier nur zu Zwecken der Fehlerbehebung aufgeführt. Änderungen können vorgenommen werden, indem die Einstellungen der deutschen Instanz aktualisiert und mithilfe von ofn-install bereitgestellt werden. Wenden Sie sich an das globale OFN-Team, um weitere Informationen zu erhalten." general: "Allgemeines" enable_mail_delivery: "E-Mail-Versand aktivieren" send_mails_as: "E-Mails senden als" From c49122461cd1deb73732601854e5c1a07bf7bb9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Feb 2021 05:47:09 +0000 Subject: [PATCH 24/48] Bump rswag from 2.3.2 to 2.3.3 Bumps [rswag](https://github.com/rswag/rswag) from 2.3.2 to 2.3.3. - [Release notes](https://github.com/rswag/rswag/releases) - [Changelog](https://github.com/rswag/rswag/blob/master/CHANGELOG.md) - [Commits](https://github.com/rswag/rswag/compare/2.3.2...2.3.3) Signed-off-by: dependabot[bot] --- Gemfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6ca2073502..2f2e7e2509 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -598,17 +598,17 @@ GEM rspec-retry (0.6.2) rspec-core (> 3.3) rspec-support (3.10.1) - rswag (2.3.2) - rswag-api (= 2.3.2) - rswag-specs (= 2.3.2) - rswag-ui (= 2.3.2) - rswag-api (2.3.2) + rswag (2.3.3) + rswag-api (= 2.3.3) + rswag-specs (= 2.3.3) + rswag-ui (= 2.3.3) + rswag-api (2.3.3) railties (>= 3.1, < 7.0) - rswag-specs (2.3.2) + rswag-specs (2.3.3) activesupport (>= 3.1, < 7.0) json-schema (~> 2.2) railties (>= 3.1, < 7.0) - rswag-ui (2.3.2) + rswag-ui (2.3.3) actionpack (>= 3.1, < 7.0) railties (>= 3.1, < 7.0) rubocop (1.9.1) From da71cd0b849b35fef90144660d79befba7488050 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Feb 2021 05:59:25 +0000 Subject: [PATCH 25/48] Bump timecop from 0.9.2 to 0.9.3 Bumps [timecop](https://github.com/travisjeffery/timecop) from 0.9.2 to 0.9.3. - [Release notes](https://github.com/travisjeffery/timecop/releases) - [Changelog](https://github.com/travisjeffery/timecop/blob/master/History.md) - [Commits](https://github.com/travisjeffery/timecop/compare/v0.9.2...v0.9.3) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6ca2073502..f0a63bfd74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -682,7 +682,7 @@ GEM thor (0.20.3) thread_safe (0.3.6) tilt (1.4.1) - timecop (0.9.2) + timecop (0.9.3) tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (4.2.0) From 662c65665c1a7f001acf6007096cf70f4fdc6aee Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 19:27:27 +1100 Subject: [PATCH 26/48] Updating translations for config/locales/fr.yml --- config/locales/fr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d62630fa2d..87b28906da 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -117,6 +117,8 @@ fr: models: order_cycle: cloned_order_cycle_name: "Copie de %{order_cycle}" + tax_rate: + included_in_price: "Inclus dans le prix" validators: date_time_string_validator: not_string_error: "doit être une série" From 96c017939c6ad07761950601aaf4c48bce8587e0 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 19:27:38 +1100 Subject: [PATCH 27/48] Updating translations for config/locales/en_FR.yml --- config/locales/en_FR.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/en_FR.yml b/config/locales/en_FR.yml index 480eb47e27..262b3b380a 100644 --- a/config/locales/en_FR.yml +++ b/config/locales/en_FR.yml @@ -117,6 +117,8 @@ en_FR: models: order_cycle: cloned_order_cycle_name: "COPY OF %{order_cycle}" + tax_rate: + included_in_price: "Included in price" validators: date_time_string_validator: not_string_error: "must be a string" From c638729df2b3e2c6abfc92e5d5f364c30a839318 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 20:19:34 +1100 Subject: [PATCH 28/48] Updating translations for config/locales/ca.yml --- config/locales/ca.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index ed961ce0e5..bf51285cc4 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -117,6 +117,8 @@ ca: models: order_cycle: cloned_order_cycle_name: "CÒPIA DE %{order_cycle}" + tax_rate: + included_in_price: "Inclòs en el preu" validators: date_time_string_validator: not_string_error: "ha de ser una seqüència" From 6a9f6c82efd068df39df59a2641352a36e8f6a09 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 20:19:50 +1100 Subject: [PATCH 29/48] Updating translations for config/locales/es.yml --- config/locales/es.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/es.yml b/config/locales/es.yml index d69a28a08f..3ace997748 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -117,6 +117,8 @@ es: models: order_cycle: cloned_order_cycle_name: "COPIA DE %{order_cycle}" + tax_rate: + included_in_price: "Incluido en el precio" validators: date_time_string_validator: not_string_error: "debe ser una cadena" From fe04295ea564a5e57af9db971f78d6b685e7a94f Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 22:33:05 +1100 Subject: [PATCH 30/48] Updating translations for config/locales/en_GB.yml --- config/locales/en_GB.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/locales/en_GB.yml b/config/locales/en_GB.yml index 0768294f71..1a51d91705 100644 --- a/config/locales/en_GB.yml +++ b/config/locales/en_GB.yml @@ -117,6 +117,8 @@ en_GB: models: order_cycle: cloned_order_cycle_name: "COPY OF %{order_cycle}" + tax_rate: + included_in_price: "Included in price" validators: date_time_string_validator: not_string_error: "must be a string" @@ -2957,6 +2959,7 @@ en_GB: display_currency: "Display currency" choose_currency: "Choose Currency" mail_method_settings: "Mail Method Settings" + mail_settings_notice_html: "Some of the following settings can't be edited and are listed here just for debugging purposes. Changes can be made by updating the instance's secrets and provisioning them using ofn-install. Reach out to the OFN global team for further details." general: "General" enable_mail_delivery: "Enable Mail Delivery" send_mails_as: "Send Mails As" @@ -3473,6 +3476,8 @@ en_GB: cancel_email_for_shop: greeting: "Dear %{name}," subject: "Cancellation of Order" + intro: "A customer has cancelled their order #%{number}." + view_cancelled_order: "View cancelled order" confirm_email: subject: "Order Confirmation" invoice_email: From af7ba5c5355c59207fbeb3255cc5cc23209a76b3 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Mon, 8 Feb 2021 23:32:39 +1100 Subject: [PATCH 31/48] Updating translations for config/locales/ru.yml --- config/locales/ru.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 0f760cd34d..9b1861f9a0 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -118,6 +118,8 @@ ru: models: order_cycle: cloned_order_cycle_name: "КОПИЯ %{order_cycle}" + tax_rate: + included_in_price: "Включено в цену" validators: date_time_string_validator: not_string_error: "должно быть строкой" @@ -3007,6 +3009,7 @@ ru: display_currency: "Показывать валюту" choose_currency: "Выбор валюты" mail_method_settings: "Почтовые Настройки" + mail_settings_notice_html: "Некоторые из следующих параметров нельзя редактировать, и они перечислены здесь только для целей отладки. Изменения можно внести, обновив секреты экземпляра и предоставив их с помощью ofn-install . За подробностями обращайтесь к глобальной команде ОСП." general: "Основные" enable_mail_delivery: "Включить отправку почты" send_mails_as: "Отправлять Почту Как" @@ -3523,6 +3526,8 @@ ru: cancel_email_for_shop: greeting: "Уважаемый %{name}!" subject: "Отмена заказа" + intro: "Покупатель отменил заказ № %{number}." + view_cancelled_order: "Посмотреть отмененный заказ" confirm_email: subject: "Подтверждение заказа" invoice_email: From dcc3d933bc95bf28e1f05e79eddc56b1ddc212b6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 6 Feb 2021 10:52:59 +0000 Subject: [PATCH 32/48] Add retry handling for flaky spec timeouts --- spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 62c67e9417..37fee324a5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -101,6 +101,10 @@ RSpec.configure do |config| # Retry config.verbose_retry = true + # Try twice (retry once) + config.default_retry_count = 2 + # Only retry when Selenium raises Net::ReadTimeout + config.exceptions_to_retry = [Net::ReadTimeout] # Force use of expect (over should) config.expect_with :rspec do |expectations| From 8f59d76eb2704a0b7567bb017e7c12380d8a89d1 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Mon, 8 Feb 2021 08:57:11 -0800 Subject: [PATCH 33/48] remove variants with no product --- db/migrate/20210202052337_migrate_variant_unit_values.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/migrate/20210202052337_migrate_variant_unit_values.rb b/db/migrate/20210202052337_migrate_variant_unit_values.rb index 9c6cf46a2e..56abf49508 100644 --- a/db/migrate/20210202052337_migrate_variant_unit_values.rb +++ b/db/migrate/20210202052337_migrate_variant_unit_values.rb @@ -1,5 +1,8 @@ class MigrateVariantUnitValues < ActiveRecord::Migration def up + Spree::Variant.where(product_id: nil).find_each do |variant| + variant.destroy + end Spree::Variant.where(unit_value: [nil, Float::NAN]).find_each do |variant| variant.unit_value = 1 variant.save From f6d47bc3e47c90535a4d412ada90ec8b1293d90a Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Tue, 9 Feb 2021 07:00:15 +1100 Subject: [PATCH 34/48] Updating translations for config/locales/de_DE.yml --- config/locales/de_DE.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/config/locales/de_DE.yml b/config/locales/de_DE.yml index 69fab87079..8b970201b6 100644 --- a/config/locales/de_DE.yml +++ b/config/locales/de_DE.yml @@ -117,6 +117,8 @@ de_DE: models: order_cycle: cloned_order_cycle_name: "Kopie von %{order_cycle}" + tax_rate: + included_in_price: "im Preis inbegriffen" validators: date_time_string_validator: not_string_error: "muss eine Zeichenfolge sein" @@ -192,7 +194,7 @@ de_DE: explainer: Die automatische Verarbeitung dieser Bestellungen ist aus einem unbekannten Grund fehlgeschlagen. Dies sollte nicht geschehen, bitte kontaktieren Sie uns, wenn Sie dies sehen. home: "OFN" title: "Open Food Network" - welcome_to: "Willkommen bei" + welcome_to: "Willkommen beim" site_meta_description: "Wir wagen den Neustart. Mit Bauern und Züchtern, die bereit sind, ihre Geschichten stolz und wahrhaftig zu erzählen. Mit Händlern, die bereit sind, Menschen fair und ehrlich mit Produkten zu verbinden. Mit Käufern, die glauben, dass ihr Einkaufsverhalten die Welt wirklich verändern kann." search_by_name: Suche nach Ort oder Name des Ladens/Produzents... producers_join: 'Wir laden Produzenten ein, jetzt dem Open Food Network beizutreten. ' @@ -1263,7 +1265,7 @@ de_DE: ticket_column_item: "Artikel" ticket_column_unit_price: "Stückpreis" ticket_column_total_price: "Gesamtpreis" - menu_1_title: "Läden" + menu_1_title: "Einkaufen" menu_1_url: "/shops" menu_2_title: "Karte" menu_2_url: "/map" @@ -1271,12 +1273,12 @@ de_DE: menu_3_url: "/producers" menu_4_title: "Gruppen" menu_4_url: "/groups" - menu_5_title: "Über uns" - menu_5_url: "https://wp.openfoodnetwork.de/" - menu_6_title: "Support" - menu_6_url: "https://wp.openfoodnetwork.de/support/" - menu_7_title: "Mehr erfahren" - menu_7_url: "https://openfoodnetwork.org/au/learn/" + menu_5_title: "Verkaufen" + menu_5_url: "https://openfoodnetwork.de/sell" + menu_6_title: "Über uns" + menu_6_url: "https://wp.openfoodnetwork.de/" + menu_7_title: "Hilfe" + menu_7_url: "https://wp.openfoodnetwork.de/support/" logo: "Logo (640x130)" logo_mobile: "Mobile Logo (75x26)" logo_mobile_svg: "Mobile Logo (SVG)" @@ -1407,7 +1409,7 @@ de_DE: cookies_policy_link_desc: "Wenn Sie mehr erfahren möchten, besuchen Sie unsere" cookies_policy_link: "Hinweise zu Cookies" cookies_accept_button: "Cookies akzeptieren" - home_shop: Jetzt einkaufen + home_shop: Jetzt regional einkaufen brandstory_headline: "Lebensmittel Direktvermarktung" brandstory_intro: "Manchmal ist der beste Weg, das System zu reparieren, einen Neuanfang zu wagen ..." brandstory_part1: "Wir wagen den Neuanfang. Mit Bauern und Züchtern, die bereit sind, ihre Geschichten stolz und wahrhaftig zu erzählen. Mit Händlern, die bereit sind, Menschen fair und ehrlich mit Produkten zu verbinden. Mit Käufern, die glauben, dass ihr Einkaufsverhalten die Welt wirklich verändern kann." From 9a2bf9d333b352492339deed8c72053df9c17c12 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Mon, 8 Feb 2021 13:12:40 -0800 Subject: [PATCH 35/48] use #destroy_all --- db/migrate/20210202052337_migrate_variant_unit_values.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/migrate/20210202052337_migrate_variant_unit_values.rb b/db/migrate/20210202052337_migrate_variant_unit_values.rb index 56abf49508..07d6f6bc1f 100644 --- a/db/migrate/20210202052337_migrate_variant_unit_values.rb +++ b/db/migrate/20210202052337_migrate_variant_unit_values.rb @@ -1,8 +1,6 @@ class MigrateVariantUnitValues < ActiveRecord::Migration def up - Spree::Variant.where(product_id: nil).find_each do |variant| - variant.destroy - end + Spree::Variant.where(product_id: nil).destroy_all Spree::Variant.where(unit_value: [nil, Float::NAN]).find_each do |variant| variant.unit_value = 1 variant.save From bd7bc803cb99336c1ee6d9aadcd0151fc6bef6f9 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 22 Nov 2020 14:56:36 +0000 Subject: [PATCH 36/48] Fix broken syntax in multiple angular files I have no idea how this was not already throwing errors before... --- app/assets/javascripts/darkswarm/darkswarm.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/darkswarm.js.coffee b/app/assets/javascripts/darkswarm/darkswarm.js.coffee index 76ecd388d9..453f05a2c3 100644 --- a/app/assets/javascripts/darkswarm/darkswarm.js.coffee +++ b/app/assets/javascripts/darkswarm/darkswarm.js.coffee @@ -13,7 +13,7 @@ window.Darkswarm = angular.module("Darkswarm", [ 'angularSlideables' ]).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) -> $httpProvider.defaults.headers['common']['X-Requested-With'] = 'XMLHttpRequest' - $httpProvider.defaults.headers.common.Accept = "application/json, text/javascript, */*" + $httpProvider.defaults.headers.common['Accept'] = "application/json, text/javascript, */*" # We manually handle our scrolling $anchorScrollProvider.disableAutoScrolling() From 12a513c54c49289c7cf472c5574ec0497fd9155c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 9 Jan 2021 16:29:10 +0000 Subject: [PATCH 37/48] Apply an upstream fix to Spree::I18n See: https://github.com/spree/spree/commit/fe95f637c988044f3af040a043cdbcff84935295 Fixes error mentioned in the above Spree commit. --- lib/spree/i18n.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spree/i18n.rb b/lib/spree/i18n.rb index 39bd4590cd..a1ab621b0d 100644 --- a/lib/spree/i18n.rb +++ b/lib/spree/i18n.rb @@ -6,7 +6,7 @@ require 'spree/i18n/base' module Spree extend ActionView::Helpers::TranslationHelper - extend ActionView::Helpers::TagHelper if ENV['DEPENDENCIES_NEXT'] + extend ActionView::Helpers::TagHelper class << self # Add spree namespace and delegate to Rails TranslationHelper for some nice From 66c331542c7b913ac0c6d621b2ecd9ce89c42538 Mon Sep 17 00:00:00 2001 From: Transifex-Openfoodnetwork Date: Tue, 9 Feb 2021 18:39:59 +1100 Subject: [PATCH 38/48] Updating translations for config/locales/it.yml --- config/locales/it.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/locales/it.yml b/config/locales/it.yml index 564b355612..dbec9ac539 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -117,6 +117,8 @@ it: models: order_cycle: cloned_order_cycle_name: "COPIA DI %{order_cycle}" + tax_rate: + included_in_price: "Incluso nel prezzo" validators: date_time_string_validator: not_string_error: "deve essere una stringa" @@ -2955,6 +2957,7 @@ it: display_currency: "Visualizza valuta" choose_currency: "Scegli Valuta" mail_method_settings: "Impostazioni del metodo di posta" + mail_settings_notice_html: "Alcune delle seguenti impostazioni non possono essere modificate e sono elencate qui solo per scopi di debug. È possibile apportare modifiche aggiornando i segreti dell'istanza ed utilizzando ofn-install. Contatta il team globale di OFN per maggiori dettagli. " general: "Generale" enable_mail_delivery: "Abilita recapito posta" send_mails_as: "Invia mail come" @@ -3471,6 +3474,8 @@ it: cancel_email_for_shop: greeting: "Caro %{name}," subject: "Cancellazione dell'ordine" + intro: "Un cliente ha cancellato la sua gentile richiesta #%{number}." + view_cancelled_order: "Visualizza richiesta eliminata" confirm_email: subject: "Conferma Ordine" invoice_email: From 50c429f3938bebed9339b0b500d9d2f78ff72452 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 9 Feb 2021 11:27:48 +0100 Subject: [PATCH 39/48] Update db/schema's timestamp after migration --- db/schema.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index aa00312da6..9f6ff5bbd7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema.define(version: 20210203215049) do +ActiveRecord::Schema.define(version: 20210203214304) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 31d3854a74e6148fc6893412788f45693bd7fea5 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 9 Feb 2021 11:48:06 +0100 Subject: [PATCH 40/48] Temporarily skip very flaky specs These are the tests that are failing a lot across all builds, slowing down everything in the pipe. It's better to skip these rather than paying this huge toll. They can be restored once we spike a new CI service. --- spec/features/admin/enterprise_roles_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/enterprise_roles_spec.rb b/spec/features/admin/enterprise_roles_spec.rb index 0e0cbd5237..4720e36334 100644 --- a/spec/features/admin/enterprise_roles_spec.rb +++ b/spec/features/admin/enterprise_roles_spec.rb @@ -117,7 +117,7 @@ feature ' end end - it "allows adding new managers" do + xit "allows adding new managers" do within 'table.managers' do select2_select user3.email, from: 'ignored', search: true @@ -129,7 +129,7 @@ feature ' end end - it "shows changes to enterprise contact or owner" do + xit "shows changes to enterprise contact or owner" do select2_select user2.email, from: 'receives_notifications_dropdown' within('#save-bar') { click_button 'Update' } navigate_to_enterprise_users @@ -146,7 +146,7 @@ feature ' end end - it "can invite unregistered users to be managers" do + xit "can invite unregistered users to be managers" do setup_email find('a.button.help-modal').click expect(page).to have_css '#invite-manager-modal' From d9bd0e8f0e0022cee5408a66f27f98a2239e4e9a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 23 Jan 2021 11:25:29 +0000 Subject: [PATCH 41/48] Use alternate method for setting request.referer in controller specs Apparently stubbing `request.referer` is tricky business in Rails 5... :shrugs: --- .../admin/orders/payments/payments_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb b/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb index 1e1437aee2..a6ed887d61 100644 --- a/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb +++ b/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb @@ -174,7 +174,7 @@ describe Spree::Admin::PaymentsController, type: :controller do let(:params) { { e: 'credit', order_id: order.number, id: payment.id } } before do - allow(request).to receive(:referer) { 'http://foo.com' } + request.env["HTTP_REFERER"] = "http://foo.com" allow(Spree::Payment).to receive(:find).with(payment.id.to_s) { payment } end @@ -210,7 +210,7 @@ describe Spree::Admin::PaymentsController, type: :controller do let(:params) { { e: 'refund', order_id: order.number, id: payment.id } } before do - allow(request).to receive(:referer) { 'http://foo.com' } + request.env["HTTP_REFERER"] = "http://foo.com" allow(Spree::Payment).to receive(:find).with(payment.id.to_s) { payment } end @@ -248,7 +248,7 @@ describe Spree::Admin::PaymentsController, type: :controller do before do allow(PaymentMailer).to receive(:authorize_payment) { mail_mock } - allow(request).to receive(:referer) { 'http://foo.com' } + request.env["HTTP_REFERER"] = "http://foo.com" allow(Spree::Payment).to receive(:find).with(payment.id.to_s) { payment } allow(payment).to receive(:cvv_response_message).and_return("https://www.stripe.com/authorize") end @@ -266,7 +266,7 @@ describe Spree::Admin::PaymentsController, type: :controller do let(:params) { { e: 'unrecognized_event', order_id: order.number, id: payment.id } } before do - allow(request).to receive(:referer) { 'http://foo.com' } + request.env["HTTP_REFERER"] = "http://foo.com" allow(Spree::Payment).to receive(:find).with(payment.id.to_s) { payment } end From 1b947d30fa7140745c227d61e5d0ed6ef4ff7b0c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 24 Jan 2021 15:14:37 +0000 Subject: [PATCH 42/48] Pass ids in params that should be ids --- spec/controllers/admin/enterprises_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index 507f840710..0a4e00b472 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -69,7 +69,7 @@ describe Admin::EnterprisesController, type: :controller do admin_user.enterprises << create(:distributor_enterprise) allow(controller).to receive_messages spree_current_user: admin_user - enterprise_params[:enterprise][:owner_id] = admin_user + enterprise_params[:enterprise][:owner_id] = admin_user.id enterprise_params[:enterprise][:sells] = 'none' spree_put :create, enterprise_params @@ -91,7 +91,7 @@ describe Admin::EnterprisesController, type: :controller do it "doesn't affect the hub status for super admins" do allow(controller).to receive_messages spree_current_user: admin_user - enterprise_params[:enterprise][:owner_id] = admin_user + enterprise_params[:enterprise][:owner_id] = admin_user.id enterprise_params[:enterprise][:sells] = 'any' spree_put :create, enterprise_params @@ -198,7 +198,7 @@ describe Admin::EnterprisesController, type: :controller do enterprise: { tag_rules_attributes: { '0' => { - id: tag_rule, + id: tag_rule.id, type: "TagRule::DiscountOrder", preferred_customer_tags: "some,new,tags", calculator_type: "Calculator::FlatPercentItemTotal", @@ -246,7 +246,7 @@ describe Admin::EnterprisesController, type: :controller do it "allows owner to be changed" do allow(controller).to receive_messages spree_current_user: distributor_owner - update_params = { id: distributor, enterprise: { owner_id: distributor_manager } } + update_params = { id: distributor, enterprise: { owner_id: distributor_manager.id } } spree_post :update, update_params distributor.reload @@ -275,7 +275,7 @@ describe Admin::EnterprisesController, type: :controller do it "allows owner to be changed" do allow(controller).to receive_messages spree_current_user: admin_user - update_params = { id: distributor, enterprise: { owner_id: distributor_manager } } + update_params = { id: distributor, enterprise: { owner_id: distributor_manager.id } } spree_post :update, update_params distributor.reload From 4c4142c56dc288331057dc76f8b54c61a034d123 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 5 Feb 2021 18:06:49 +0000 Subject: [PATCH 43/48] Fix HAML "unbalanced brackets" errors --- .../javascripts/templates/bulk_buy_modal.html.haml | 10 ++-------- .../partials/shop_variant_no_group_buy.html.haml | 8 ++------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/templates/bulk_buy_modal.html.haml b/app/assets/javascripts/templates/bulk_buy_modal.html.haml index 5e26551419..05868dab77 100644 --- a/app/assets/javascripts/templates/bulk_buy_modal.html.haml +++ b/app/assets/javascripts/templates/bulk_buy_modal.html.haml @@ -16,10 +16,7 @@ %button.bulk-buy-add.variant-quantity{type: "button", ng: {click: "add(-1)", disabled: "!canAdd(-1)"}}> -# U+FF0D Fullwidth Hyphen-Minus - - %input.bulk-buy.variant-quantity{ - type: "number", - min: "0", - max: "{{ available() }}", + %input.bulk-buy.variant-quantity{type: "number", min: "0", max: "{{ available() }}", ng: {model: "variant.line_item.quantity", max: "Infinity"}}> %button.bulk-buy-add.variant-quantity{type: "button", ng: {click: "add(1)", disabled: "!canAdd(1)"}} -# U+FF0B Fullwidth Plus Sign @@ -31,10 +28,7 @@ %button.bulk-buy-add.variant-quantity{type: "button", ng: {click: "addMax(-1)", disabled: "!canAddMax(-1)"}}> -# U+FF0D Fullwidth Hyphen-Minus - - %input.bulk-buy.variant-quantity{ - type: "number", - min: "0", - max: "{{ available() }}", + %input.bulk-buy.variant-quantity{type: "number", min: "0", max: "{{ available() }}", ng: {model: "variant.line_item.max_quantity", max: "Infinity"}}> %button.bulk-buy-add.variant-quantity{type: "button", ng: {click: "addMax(1)", disabled: "!canAddMax(1)"}} -# U+FF0B Fullwidth Plus Sign diff --git a/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml b/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml index ad8abdf747..2157f548c7 100644 --- a/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml +++ b/app/assets/javascripts/templates/partials/shop_variant_no_group_buy.html.haml @@ -8,12 +8,8 @@ %button.variant-quantity{type: "button", ng: {click: "add(-1)", disabled: "!canAdd(-1)"}}> -# U+FF0D Fullwidth Hyphen-Minus - - %input.variant-quantity{ - type: "number", - min: "0", - max: "{{ available() }}", - ng: {model: "variant.line_item.quantity", max: "Infinity"} - }> + %input.variant-quantity{ type: "number", min: "0", max: "{{ available() }}", + ng: {model: "variant.line_item.quantity", max: "Infinity"}}> %button.variant-quantity{type: "button", ng: {click: "add(1)", disabled: "!canAdd(1)"}} -# U+FF0B Fullwidth Plus Sign + From 78eb5d23f9357793059c2fcfb782ad00cd517fd2 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 9 Feb 2021 11:56:00 +0000 Subject: [PATCH 44/48] Update TaxRatesController spec BigDecimal was throwing an error here (in Rails 5) unless it received a string, but I think this is actually an issue with the way params were being passed in the relevant spec, as opposed to the controller itself. --- spec/controllers/spree/admin/tax_rates_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/spree/admin/tax_rates_controller_spec.rb b/spec/controllers/spree/admin/tax_rates_controller_spec.rb index 266edc9430..8bef1f2fb1 100644 --- a/spec/controllers/spree/admin/tax_rates_controller_spec.rb +++ b/spec/controllers/spree/admin/tax_rates_controller_spec.rb @@ -20,7 +20,7 @@ module Spree context "when the amount is not changed" do it "updates the record" do expect { - spree_put :update, id: tax_rate.id, tax_rate: { name: "Updated Rate", amount: 0.1 } + spree_put :update, id: tax_rate.id, tax_rate: { name: "Updated Rate", amount: "0.1" } }.to_not change{ Spree::TaxRate.with_deleted.count } expect(response).to redirect_to spree.admin_tax_rates_url @@ -32,7 +32,7 @@ module Spree context "when the amount is changed" do it "duplicates the record and soft-deletes the duplicate" do expect { - spree_put :update, id: tax_rate.id, tax_rate: { name: "Changed Rate", amount: 0.5 } + spree_put :update, id: tax_rate.id, tax_rate: { name: "Changed Rate", amount: "0.5" } }.to change{ Spree::TaxRate.with_deleted.count }.by(1) expect(response).to redirect_to spree.admin_tax_rates_url From d6442bb16f4f247bba4d5da7c7a9d5d805c42945 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 5 Feb 2021 20:07:07 +0000 Subject: [PATCH 45/48] Fix get requests in API controller spec --- .../api/exchange_products_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/controllers/api/exchange_products_controller_spec.rb b/spec/controllers/api/exchange_products_controller_spec.rb index d9aa7ce55c..a0ae941c8a 100644 --- a/spec/controllers/api/exchange_products_controller_spec.rb +++ b/spec/controllers/api/exchange_products_controller_spec.rb @@ -26,7 +26,7 @@ module Api let(:products_relation) { Spree::Product.where("1=0") } it "handles it gracefully" do - get :index, exchange_id: exchange.id + api_get :index, exchange_id: exchange.id expect(json_response["products"].length).to eq 0 end end @@ -36,14 +36,14 @@ module Api describe "when an exchange id param is provided" do it "uses exchange order_cycle, incoming and enterprise to fetch products" do - get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false + api_get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false expect(json_response["products"].first["supplier_name"]).to eq exchange.variants.first.product.supplier.name end end describe "when an exchange id param is not provided" do it "uses params order_cycle, incoming and enterprise to fetch products" do - spree_get :index, order_cycle_id: order_cycle.id, enterprise_id: exchange.sender_id, incoming: true + api_get :index, order_cycle_id: order_cycle.id, enterprise_id: exchange.sender_id, incoming: true expect(json_response["products"].first["supplier_name"]).to eq exchange.variants.first.product.supplier.name end end @@ -59,7 +59,7 @@ module Api describe "when a specific page is requested" do it "returns the requested page with paginated data" do - get :index, exchange_id: exchange.id, page: 1 + api_get :index, exchange_id: exchange.id, page: 1 expect(json_response["products"].size).to eq 1 expect(json_response["pagination"]["results"]).to eq 2 @@ -69,7 +69,7 @@ module Api describe "when no specific page is requested" do it "returns all results without paginating" do - get :index, exchange_id: exchange.id + api_get :index, exchange_id: exchange.id expect(json_response["products"].size).to eq 2 expect(json_response["pagination"]).to be nil From dc74be45b93f5618cbc8d4d8714754813d4e817d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Feb 2021 05:30:17 +0000 Subject: [PATCH 46/48] Bump timecop from 0.9.3 to 0.9.4 Bumps [timecop](https://github.com/travisjeffery/timecop) from 0.9.3 to 0.9.4. - [Release notes](https://github.com/travisjeffery/timecop/releases) - [Changelog](https://github.com/travisjeffery/timecop/blob/master/History.md) - [Commits](https://github.com/travisjeffery/timecop/compare/v0.9.3...v0.9.4) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e0c1b8e65b..7675f23a40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -682,7 +682,7 @@ GEM thor (0.20.3) thread_safe (0.3.6) tilt (1.4.1) - timecop (0.9.3) + timecop (0.9.4) tzinfo (1.2.9) thread_safe (~> 0.1) uglifier (4.2.0) From 7baaa6f0466f8f009703feb3613e28d1393117dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Feb 2021 05:31:53 +0000 Subject: [PATCH 47/48] Bump stripe from 5.29.0 to 5.29.1 Bumps [stripe](https://github.com/stripe/stripe-ruby) from 5.29.0 to 5.29.1. - [Release notes](https://github.com/stripe/stripe-ruby/releases) - [Changelog](https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md) - [Commits](https://github.com/stripe/stripe-ruby/compare/v5.29.0...v5.29.1) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e0c1b8e65b..199d276d97 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -672,7 +672,7 @@ GEM activerecord (>= 4.1) state_machines-activemodel (>= 0.5.0) stringex (2.8.5) - stripe (5.29.0) + stripe (5.29.1) temple (0.8.2) test-prof (0.11.3) test-unit (3.4.0) From 7814e746498649b4b6d0ddc6f0478e4b08d2af34 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Wed, 10 Feb 2021 08:56:35 -0800 Subject: [PATCH 48/48] remove migration --- ...10202052337_migrate_variant_unit_values.rb | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 db/migrate/20210202052337_migrate_variant_unit_values.rb diff --git a/db/migrate/20210202052337_migrate_variant_unit_values.rb b/db/migrate/20210202052337_migrate_variant_unit_values.rb deleted file mode 100644 index 07d6f6bc1f..0000000000 --- a/db/migrate/20210202052337_migrate_variant_unit_values.rb +++ /dev/null @@ -1,28 +0,0 @@ -class MigrateVariantUnitValues < ActiveRecord::Migration - def up - Spree::Variant.where(product_id: nil).destroy_all - Spree::Variant.where(unit_value: [nil, Float::NAN]).find_each do |variant| - variant.unit_value = 1 - variant.save - end - Spree::Variant.where(weight: [nil, Float::NAN]).find_each do |variant| - variant.weight = 0 - variant.save - end - change_column_null :spree_variants, :unit_value, false, 1 - change_column_null :spree_variants, :weight, false, 0.0 - change_column_default :spree_variants, :unit_value, 1 - change_column_default :spree_variants, :weight, 0.0 - execute "ALTER TABLE spree_variants ADD CONSTRAINT check_unit_value_for_nan CHECK (unit_value <> 'NaN')" - execute "ALTER TABLE spree_variants ADD CONSTRAINT check_weight_for_nan CHECK (weight <> 'NaN')" - end - - def down - change_column_null :spree_variants, :unit_value, true - change_column_null :spree_variants, :weight, true - change_column_default :spree_variants, :unit_value, nil - change_column_default :spree_variants, :weight, nil - execute "ALTER TABLE spree_variants DROP CONSTRAINT check_unit_value_for_nan" - execute "ALTER TABLE spree_variants DROP CONSTRAINT check_weight_for_nan" - end -end