mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Autocorrect rubocop Layout/BlockEndNewline cop
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --exclude-limit 1400`
|
||||
# on 2018-01-20 12:46:57 +0100 using RuboCop version 0.49.1.
|
||||
# on 2018-02-01 09:48:08 +0100 using RuboCop version 0.49.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@@ -84,26 +84,6 @@ Layout/AlignParameters:
|
||||
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
|
||||
- 'spec/support/request/authentication_workflow.rb'
|
||||
|
||||
# Offense count: 41
|
||||
# Cop supports --auto-correct.
|
||||
Layout/BlockEndNewline:
|
||||
Exclude:
|
||||
- 'app/models/order_cycle.rb'
|
||||
- 'app/models/spree/calculator/default_tax_decorator.rb'
|
||||
- 'app/models/spree/product_decorator.rb'
|
||||
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/features/admin/variant_overrides_spec.rb'
|
||||
- 'spec/helpers/enterprises_helper_spec.rb'
|
||||
- 'spec/jobs/update_billable_periods_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
|
||||
- 'spec/models/order_cycle_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/serializers/enterprise_serializer_spec.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth.
|
||||
@@ -138,7 +118,7 @@ Layout/ElseAlignment:
|
||||
- 'app/serializers/api/admin/order_cycle_serializer.rb'
|
||||
- 'lib/open_food_network/sales_tax_report.rb'
|
||||
|
||||
# Offense count: 209
|
||||
# Offense count: 210
|
||||
# Cop supports --auto-correct.
|
||||
Layout/EmptyLines:
|
||||
Exclude:
|
||||
@@ -228,6 +208,7 @@ Layout/EmptyLines:
|
||||
- 'spec/controllers/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/factories.rb'
|
||||
@@ -531,7 +512,7 @@ Layout/IndentationConsistency:
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
|
||||
# Offense count: 19
|
||||
# Offense count: 18
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Width, IgnoredPatterns.
|
||||
Layout/IndentationWidth:
|
||||
@@ -544,7 +525,6 @@ Layout/IndentationWidth:
|
||||
- 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb'
|
||||
- 'app/serializers/api/admin/order_cycle_serializer.rb'
|
||||
- 'lib/discourse/single_sign_on.rb'
|
||||
- 'serializer.rb'
|
||||
- 'spec/features/consumer/shopping/variant_overrides_spec.rb'
|
||||
- 'spec/helpers/admin/business_model_configuration_helper_spec.rb'
|
||||
- 'spec/helpers/groups_helper_spec.rb'
|
||||
@@ -819,7 +799,7 @@ Layout/SpaceBeforeComma:
|
||||
- 'spec/features/admin/bulk_order_management_spec.rb'
|
||||
- 'spec/features/admin/bulk_product_update_spec.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowForAlignment.
|
||||
Layout/SpaceBeforeFirstArg:
|
||||
@@ -827,6 +807,7 @@ Layout/SpaceBeforeFirstArg:
|
||||
- 'spec/factories.rb'
|
||||
- 'spec/features/admin/bulk_product_update_spec.rb'
|
||||
- 'spec/features/admin/product_import_spec.rb'
|
||||
- 'spec/features/consumer/multilingual_spec.rb'
|
||||
- 'spec/models/enterprise_fee_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
@@ -923,7 +904,7 @@ Layout/SpaceInsideBrackets:
|
||||
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
|
||||
- 'spec/performance/orders_controller_spec.rb'
|
||||
|
||||
# Offense count: 782
|
||||
# Offense count: 778
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
|
||||
# SupportedStyles: space, no_space, compact
|
||||
@@ -979,7 +960,6 @@ Layout/SpaceInsideHashLiteralBraces:
|
||||
- 'spec/controllers/admin/business_model_configuration_controller_spec.rb'
|
||||
- 'spec/controllers/admin/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/admin/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/api/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/api/statuses_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
@@ -989,7 +969,6 @@ Layout/SpaceInsideHashLiteralBraces:
|
||||
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/reports_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/variants_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
@@ -1061,12 +1040,14 @@ Layout/Tab:
|
||||
- 'spec/lib/spree/product_filters_spec.rb'
|
||||
- 'spec/models/spree/line_item_spec.rb'
|
||||
|
||||
# Offense count: 28
|
||||
# Offense count: 67
|
||||
# Cop supports --auto-correct.
|
||||
Layout/TrailingWhitespace:
|
||||
Exclude:
|
||||
- 'app/models/distributor_shipping_method.rb'
|
||||
- 'app/models/spree/calculator/default_tax_decorator.rb'
|
||||
- 'app/models/spree/money_decorator.rb'
|
||||
- 'app/models/spree/product_decorator.rb'
|
||||
- 'app/serializers/api/image_serializer.rb'
|
||||
- 'app/serializers/api/shipping_method_serializer.rb'
|
||||
- 'app/views/json/_current_order.rabl'
|
||||
@@ -1074,10 +1055,21 @@ Layout/TrailingWhitespace:
|
||||
- 'app/views/json/_producer.rabl'
|
||||
- 'app/views/json/partials/_producer.rabl'
|
||||
- 'lib/tasks/dev.rake'
|
||||
- 'spec/controllers/admin/column_preferences_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/features/admin/enterprise_user_spec.rb'
|
||||
- 'spec/features/admin/variant_overrides_spec.rb'
|
||||
- 'spec/helpers/enterprises_helper_spec.rb'
|
||||
- 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb'
|
||||
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
- 'spec/lib/open_food_network/permissions_spec.rb'
|
||||
- 'spec/lib/open_food_network/user_balance_calculator_spec.rb'
|
||||
- 'spec/models/order_cycle_spec.rb'
|
||||
- 'spec/models/spree/product_spec.rb'
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/serializers/admin/enterprise_serializer_spec.rb'
|
||||
- 'spec/serializers/enterprise_serializer_spec.rb'
|
||||
- 'spec/support/request/menu_helper.rb'
|
||||
- 'spec/views/json/producers.json.rabl_spec.rb'
|
||||
|
||||
@@ -1308,7 +1300,7 @@ Lint/Void:
|
||||
- 'spec/serializers/enterprise_serializer_spec.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
|
||||
# Offense count: 793
|
||||
# Offense count: 794
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
Metrics/BlockLength:
|
||||
Max: 672
|
||||
@@ -1403,15 +1395,6 @@ Rails/FilePath:
|
||||
- 'spec/models/spree/variant_spec.rb'
|
||||
- 'spec/spec_helper.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/FindBy:
|
||||
Exclude:
|
||||
- 'app/models/product_importer.rb'
|
||||
- 'app/models/variant_override.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Include.
|
||||
@@ -1569,7 +1552,7 @@ Style/BarePercentLiterals:
|
||||
- 'spec/features/admin/variants_spec.rb'
|
||||
- 'spec/support/request/web_helper.rb'
|
||||
|
||||
# Offense count: 208
|
||||
# Offense count: 207
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: braces, no_braces, context_dependent
|
||||
@@ -1650,7 +1633,7 @@ Style/CaseEquality:
|
||||
- 'app/helpers/angular_form_helper.rb'
|
||||
- 'spec/models/spree/payment_spec.rb'
|
||||
|
||||
# Offense count: 88
|
||||
# Offense count: 87
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: nested, compact
|
||||
Style/ClassAndModuleChildren:
|
||||
@@ -1731,7 +1714,6 @@ Style/ClassAndModuleChildren:
|
||||
- 'lib/open_food_network/reports/report.rb'
|
||||
- 'lib/open_food_network/reports/row.rb'
|
||||
- 'lib/open_food_network/reports/rule.rb'
|
||||
- 'serializer.rb'
|
||||
- 'spec/controllers/spree/admin/base_controller_spec.rb'
|
||||
- 'spec/lib/open_food_network/reports/report_spec.rb'
|
||||
- 'spec/lib/open_food_network/reports/row_spec.rb'
|
||||
@@ -1881,7 +1863,7 @@ Style/GuardClause:
|
||||
- 'spec/support/request/distribution_helper.rb'
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
|
||||
# Offense count: 1233
|
||||
# Offense count: 1219
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
@@ -1988,7 +1970,6 @@ Style/HashSyntax:
|
||||
- 'spec/archive/features/consumer/checkout_spec.rb'
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/stripe_connect_settings_controller_spec.rb'
|
||||
- 'spec/controllers/api/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/api/order_cycles_controller_spec.rb'
|
||||
- 'spec/controllers/base_controller_spec.rb'
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
@@ -1996,7 +1977,6 @@ Style/HashSyntax:
|
||||
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/payment_methods_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/api/variants_controller_spec.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
@@ -2139,14 +2119,13 @@ Style/NestedParenthesizedCalls:
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Offense count: 4
|
||||
Style/NestedTernaryOperator:
|
||||
Exclude:
|
||||
- 'app/serializers/api/admin/product_serializer.rb'
|
||||
- 'app/serializers/api/admin/variant_serializer.rb'
|
||||
- 'app/views/spree/api/products/bulk_show.v1.rabl'
|
||||
- 'app/views/spree/api/variants/bulk_show.v1.rabl'
|
||||
- 'serializer.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
@@ -2440,14 +2419,13 @@ Style/SymbolProc:
|
||||
- 'spec/lib/open_food_network/group_buy_report_spec.rb'
|
||||
- 'spec/lib/open_food_network/order_grouper_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
|
||||
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
||||
Style/TernaryParentheses:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/enterprises_controller.rb'
|
||||
- 'app/controllers/api/enterprises_controller.rb'
|
||||
- 'app/controllers/spree/admin/payment_methods_controller_decorator.rb'
|
||||
- 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb'
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ class OrderCycle < ActiveRecord::Base
|
||||
joins(:exchanges).
|
||||
merge(Exchange.outgoing).
|
||||
merge(Exchange.with_product(product)).
|
||||
select('DISTINCT order_cycles.*') }
|
||||
select('DISTINCT order_cycles.*')
|
||||
}
|
||||
|
||||
scope :with_distributor, lambda { |distributor|
|
||||
joins(:exchanges).merge(Exchange.outgoing).merge(Exchange.to_enterprise(distributor))
|
||||
|
||||
@@ -20,7 +20,8 @@ Spree::Calculator::DefaultTax.class_eval do
|
||||
per_item_fees_total = order.line_items.sum do |line_item|
|
||||
calculator.send(:per_item_enterprise_fee_applicators_for, line_item.variant)
|
||||
.select { |applicator| (!applicator.enterprise_fee.inherits_tax_category && applicator.enterprise_fee.tax_category == rate.tax_category) ||
|
||||
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category) }
|
||||
(applicator.enterprise_fee.inherits_tax_category && line_item.product.tax_category == rate.tax_category)
|
||||
}
|
||||
.sum { |applicator| applicator.enterprise_fee.compute_amount(line_item) }
|
||||
end
|
||||
|
||||
|
||||
@@ -97,12 +97,14 @@ Spree::Product.class_eval do
|
||||
# Find products that are distributed by the given order cycle
|
||||
scope :in_order_cycle, lambda { |order_cycle| with_order_cycles_inner.
|
||||
merge(Exchange.outgoing).
|
||||
where('order_cycles.id = ?', order_cycle) }
|
||||
where('order_cycles.id = ?', order_cycle)
|
||||
}
|
||||
|
||||
scope :in_an_active_order_cycle, lambda { with_order_cycles_inner.
|
||||
merge(OrderCycle.active).
|
||||
merge(Exchange.outgoing).
|
||||
where('order_cycles.id IS NOT NULL') }
|
||||
where('order_cycles.id IS NOT NULL')
|
||||
}
|
||||
|
||||
scope :by_producer, joins(:supplier).order('enterprises.name')
|
||||
scope :by_name, order('name')
|
||||
|
||||
@@ -16,7 +16,8 @@ describe Admin::ColumnPreferencesController, type: :controller do
|
||||
{ id: column_preference.id, user_id: user1.id, action_name: "enterprises_index", column_name: 'name', visible: false },
|
||||
{ id: nil, user_id: user1.id, action_name: "enterprises_index", column_name: 'producer', visible: true },
|
||||
{ id: nil, user_id: user1.id, action_name: "enterprises_index", column_name: 'status', visible: true }
|
||||
] }
|
||||
]
|
||||
}
|
||||
|
||||
context "where I don't own the preferences submitted" do
|
||||
before do
|
||||
|
||||
@@ -143,11 +143,13 @@ describe ShopController, type: :controller do
|
||||
let!(:tag_rule) { create(:filter_products_tag_rule,
|
||||
enterprise: distributor,
|
||||
preferred_customer_tags: "member",
|
||||
preferred_variant_tags: "members-only") }
|
||||
preferred_variant_tags: "members-only")
|
||||
}
|
||||
let!(:default_tag_rule) { create(:filter_products_tag_rule,
|
||||
enterprise: distributor,
|
||||
is_default: true,
|
||||
preferred_variant_tags: "members-only") }
|
||||
preferred_variant_tags: "members-only")
|
||||
}
|
||||
let(:product1) { { "id" => 1, "name" => 'product 1', "variants" => [{ "id" => 4, "tag_list" => ["members-only"] }] } }
|
||||
let(:product2) { { "id" => 2, "name" => 'product 2', "variants" => [{ "id" => 5, "tag_list" => ["members-only"] }, {"id" => 9, "tag_list" => ["something"]}] } }
|
||||
let(:product3) { { "id" => 3, "name" => 'product 3', "variants" => [{ "id" => 6, "tag_list" => ["something-else"] }] } }
|
||||
|
||||
@@ -16,9 +16,11 @@ feature %q{
|
||||
let!(:producer_related) { create(:supplier_enterprise) }
|
||||
let!(:producer_unrelated) { create(:supplier_enterprise) }
|
||||
let!(:er1) { create(:enterprise_relationship, parent: producer, child: hub,
|
||||
permissions_list: [:create_variant_overrides]) }
|
||||
permissions_list: [:create_variant_overrides])
|
||||
}
|
||||
let!(:er2) { create(:enterprise_relationship, parent: producer_related, child: hub,
|
||||
permissions_list: [:create_variant_overrides]) }
|
||||
permissions_list: [:create_variant_overrides])
|
||||
}
|
||||
|
||||
context "as an enterprise user" do
|
||||
let(:user) { create_enterprise_user enterprises: [hub, producer_managed] }
|
||||
@@ -26,7 +28,8 @@ feature %q{
|
||||
|
||||
describe "selecting a hub" do
|
||||
let!(:er1) { create(:enterprise_relationship, parent: hub2, child: producer_managed,
|
||||
permissions_list: [:add_to_order_cycle]) } # This er should not confer ability to create VOs for hub2
|
||||
permissions_list: [:add_to_order_cycle])
|
||||
} # This er should not confer ability to create VOs for hub2
|
||||
|
||||
it "displays a list of hub choices (ie. only those managed by the user)" do
|
||||
visit spree.admin_path
|
||||
|
||||
@@ -35,11 +35,13 @@ describe EnterprisesHelper, type: :helper do
|
||||
let!(:tag_rule) { create(:filter_shipping_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
preferred_customer_tags: "local",
|
||||
preferred_shipping_method_tags: "local-delivery") }
|
||||
preferred_shipping_method_tags: "local-delivery")
|
||||
}
|
||||
let!(:default_tag_rule) { create(:filter_shipping_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
is_default: true,
|
||||
preferred_shipping_method_tags: "local-delivery") }
|
||||
preferred_shipping_method_tags: "local-delivery")
|
||||
}
|
||||
let!(:tagged_sm) { sm1 }
|
||||
let!(:untagged_sm) { sm2 }
|
||||
|
||||
@@ -142,11 +144,13 @@ describe EnterprisesHelper, type: :helper do
|
||||
let!(:tag_rule) { create(:filter_payment_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
preferred_customer_tags: "trusted",
|
||||
preferred_payment_method_tags: "trusted") }
|
||||
preferred_payment_method_tags: "trusted")
|
||||
}
|
||||
let!(:default_tag_rule) { create(:filter_payment_methods_tag_rule,
|
||||
enterprise: distributor,
|
||||
is_default: true,
|
||||
preferred_payment_method_tags: "trusted") }
|
||||
preferred_payment_method_tags: "trusted")
|
||||
}
|
||||
let(:tagged_pm) { pm1 }
|
||||
let(:untagged_pm) { pm2 }
|
||||
|
||||
|
||||
@@ -413,7 +413,8 @@ describe UpdateBillablePeriods do
|
||||
double(:order, total: 10),
|
||||
double(:order, total: 20),
|
||||
double(:order, total: 30)
|
||||
]}
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
context "when the account invoice is already_complete" do
|
||||
|
||||
@@ -19,9 +19,11 @@ module OpenFoodNetwork
|
||||
|
||||
describe "supplier fees" do
|
||||
let!(:exchange1) { create(:exchange, order_cycle: order_cycle, sender: supplier1, receiver: coordinator, incoming: true,
|
||||
enterprise_fees: [enterprise_fee1], variants: [product1.master]) }
|
||||
enterprise_fees: [enterprise_fee1], variants: [product1.master])
|
||||
}
|
||||
let!(:exchange2) { create(:exchange, order_cycle: order_cycle, sender: supplier2, receiver: coordinator, incoming: true,
|
||||
enterprise_fees: [enterprise_fee2], variants: [product2.master]) }
|
||||
enterprise_fees: [enterprise_fee2], variants: [product2.master])
|
||||
}
|
||||
|
||||
it "calculates via regular computation" do
|
||||
EnterpriseFeeCalculator.new(distributor, order_cycle).fees_for(product1.master).should == 20
|
||||
@@ -36,7 +38,8 @@ module OpenFoodNetwork
|
||||
|
||||
describe "coordinator fees" do
|
||||
let!(:exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false,
|
||||
enterprise_fees: [], variants: [product1.master]) }
|
||||
enterprise_fees: [], variants: [product1.master])
|
||||
}
|
||||
|
||||
before do
|
||||
order_cycle.coordinator_fees = [enterprise_fee1, enterprise_fee2, enterprise_fee3]
|
||||
@@ -53,7 +56,8 @@ module OpenFoodNetwork
|
||||
|
||||
describe "distributor fees" do
|
||||
let!(:exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false,
|
||||
enterprise_fees: [enterprise_fee1, enterprise_fee2, enterprise_fee3], variants: [product1.master]) }
|
||||
enterprise_fees: [enterprise_fee1, enterprise_fee2, enterprise_fee3], variants: [product1.master])
|
||||
}
|
||||
|
||||
it "sums via regular computation" do
|
||||
EnterpriseFeeCalculator.new(distributor, order_cycle).fees_for(product1.master).should == 23
|
||||
@@ -68,7 +72,8 @@ module OpenFoodNetwork
|
||||
describe "summing percentage fees for the variant" do
|
||||
let!(:enterprise_fee1) { create(:enterprise_fee, amount: 20, fee_type: "admin", calculator: ::Calculator::FlatPercentPerItem.new(preferred_flat_percent: 20)) }
|
||||
let!(:exchange) { create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false,
|
||||
enterprise_fees: [enterprise_fee1], variants: [product1.master]) }
|
||||
enterprise_fees: [enterprise_fee1], variants: [product1.master])
|
||||
}
|
||||
|
||||
it "sums via regular computation" do
|
||||
EnterpriseFeeCalculator.new(distributor, order_cycle).fees_for(product1.master).should == 2.00
|
||||
@@ -89,7 +94,8 @@ module OpenFoodNetwork
|
||||
let!(:exchange) { create(:exchange, order_cycle: order_cycle,
|
||||
sender: coordinator, receiver: distributor, incoming: false,
|
||||
enterprise_fees: [ef_admin, ef_sales, ef_packing, ef_transport, ef_fundraising],
|
||||
variants: [product1.master]) }
|
||||
variants: [product1.master])
|
||||
}
|
||||
|
||||
describe "regular computation" do
|
||||
it "returns a breakdown of fees" do
|
||||
|
||||
@@ -107,7 +107,8 @@ module OpenFoodNetwork
|
||||
let!(:hub) { create(:distributor_enterprise) }
|
||||
let!(:producer) { create(:supplier_enterprise) }
|
||||
let!(:er) { create(:enterprise_relationship, parent: producer, child: hub,
|
||||
permissions_list: [:create_variant_overrides]) }
|
||||
permissions_list: [:create_variant_overrides])
|
||||
}
|
||||
|
||||
before do
|
||||
permissions.stub(:managed_enterprises) { Enterprise.where(id: hub.id) }
|
||||
@@ -139,7 +140,8 @@ module OpenFoodNetwork
|
||||
describe "hubs connected to the user by relationships only" do
|
||||
let!(:producer_managed) { create(:supplier_enterprise) }
|
||||
let!(:er_oc) { create(:enterprise_relationship, parent: hub, child: producer_managed,
|
||||
permissions_list: [:add_to_order_cycle, :create_variant_overrides]) }
|
||||
permissions_list: [:add_to_order_cycle, :create_variant_overrides])
|
||||
}
|
||||
|
||||
before do
|
||||
permissions.stub(:managed_enterprises) { Enterprise.where(id: producer_managed.id) }
|
||||
|
||||
@@ -11,14 +11,18 @@ module OpenFoodNetwork
|
||||
|
||||
let!(:o1) { create(:order_with_totals_and_distribution,
|
||||
user: user1, distributor: hub1,
|
||||
completed_at: 1.day.ago) } #total=10
|
||||
completed_at: 1.day.ago)
|
||||
} #total=10
|
||||
let!(:o2) { create(:order_with_totals_and_distribution,
|
||||
user: user1, distributor: hub1,
|
||||
completed_at: 1.day.ago) } #total=10
|
||||
completed_at: 1.day.ago)
|
||||
} #total=10
|
||||
let!(:p1) { create(:payment, order: o1, amount: 15.00,
|
||||
state: "completed") }
|
||||
state: "completed")
|
||||
}
|
||||
let!(:p2) { create(:payment, order: o2, amount: 2.00,
|
||||
state: "completed") }
|
||||
state: "completed")
|
||||
}
|
||||
|
||||
it "finds the correct balance for this email and enterprise" do
|
||||
UserBalanceCalculator.new(o1.email, hub1).balance.should == -3
|
||||
@@ -28,9 +32,11 @@ module OpenFoodNetwork
|
||||
let!(:hub2) { create(:distributor_enterprise) }
|
||||
let!(:o3) { create(:order_with_totals_and_distribution,
|
||||
user: user1, distributor: hub2,
|
||||
completed_at: 1.day.ago) } #total=10
|
||||
completed_at: 1.day.ago)
|
||||
} #total=10
|
||||
let!(:p3) { create(:payment, order: o3, amount: 15.00,
|
||||
state: "completed") }
|
||||
state: "completed")
|
||||
}
|
||||
|
||||
it "does not find the balance for other enterprises" do
|
||||
UserBalanceCalculator.new(o3.email, hub2).balance.should == 5
|
||||
@@ -41,9 +47,11 @@ module OpenFoodNetwork
|
||||
let!(:user2) { create(:user) }
|
||||
let!(:o4) { create(:order_with_totals_and_distribution,
|
||||
user: user2, distributor: hub1,
|
||||
completed_at: 1.day.ago) } #total=10
|
||||
completed_at: 1.day.ago)
|
||||
} #total=10
|
||||
let!(:p3) { create(:payment, order: o4, amount: 20.00,
|
||||
state: "completed") }
|
||||
state: "completed")
|
||||
}
|
||||
|
||||
it "does not find the balance for other users" do
|
||||
UserBalanceCalculator.new(o4.email, hub1).balance.should == 10
|
||||
@@ -53,9 +61,11 @@ module OpenFoodNetwork
|
||||
context "with canceled orders" do
|
||||
let!(:o4) { create(:order_with_totals_and_distribution,
|
||||
user: user1, distributor: hub1,
|
||||
completed_at: 1.day.ago, state: "canceled") } #total=10
|
||||
completed_at: 1.day.ago, state: "canceled")
|
||||
} #total=10
|
||||
let!(:p4) { create(:payment, order: o4, amount: 20.00,
|
||||
state: "completed") }
|
||||
state: "completed")
|
||||
}
|
||||
|
||||
it "does not include canceled orders in the balance" do
|
||||
UserBalanceCalculator.new(o4.email, hub1).balance.should == -3
|
||||
|
||||
@@ -196,11 +196,14 @@ describe OrderCycle do
|
||||
let(:d1) { create(:enterprise) }
|
||||
let(:d2) { create(:enterprise) }
|
||||
let!(:e0) { create(:exchange, incoming: true,
|
||||
order_cycle: oc, sender: create(:enterprise), receiver: oc.coordinator) }
|
||||
order_cycle: oc, sender: create(:enterprise), receiver: oc.coordinator)
|
||||
}
|
||||
let!(:e1) { create(:exchange, incoming: false,
|
||||
order_cycle: oc, sender: oc.coordinator, receiver: d1) }
|
||||
order_cycle: oc, sender: oc.coordinator, receiver: d1)
|
||||
}
|
||||
let!(:e2) { create(:exchange, incoming: false,
|
||||
order_cycle: oc, sender: oc.coordinator, receiver: d2) }
|
||||
order_cycle: oc, sender: oc.coordinator, receiver: d2)
|
||||
}
|
||||
let!(:p0) { create(:simple_product) }
|
||||
let!(:p1) { create(:simple_product) }
|
||||
let!(:p1_v_deleted) { create(:variant, product: p1, deleted_at: Time.zone.now) }
|
||||
|
||||
@@ -512,7 +512,8 @@ module Spree
|
||||
let!(:p) { create(:simple_product,
|
||||
variant_unit: 'weight',
|
||||
variant_unit_scale: 1,
|
||||
variant_unit_name: nil) }
|
||||
variant_unit_name: nil)
|
||||
}
|
||||
|
||||
let!(:ot_volume) { create(:option_type, name: 'unit_volume', presentation: 'Volume') }
|
||||
|
||||
|
||||
@@ -91,11 +91,14 @@ module Spree
|
||||
let(:v_external) { create(:variant, product: p_external) }
|
||||
|
||||
let!(:ex_in) { create(:exchange, order_cycle: oc, sender: s, receiver: oc.coordinator,
|
||||
incoming: true, variants: [v1, v2]) }
|
||||
incoming: true, variants: [v1, v2])
|
||||
}
|
||||
let!(:ex_out1) { create(:exchange, order_cycle: oc, sender: oc.coordinator, receiver: d1,
|
||||
incoming: false, variants: [v1]) }
|
||||
incoming: false, variants: [v1])
|
||||
}
|
||||
let!(:ex_out2) { create(:exchange, order_cycle: oc, sender: oc.coordinator, receiver: d2,
|
||||
incoming: false, variants: [v2]) }
|
||||
incoming: false, variants: [v2])
|
||||
}
|
||||
|
||||
it "returns variants in the order cycle and distributor" do
|
||||
p1.variants.for_distribution(oc, d1).should == [v1]
|
||||
|
||||
@@ -10,7 +10,8 @@ describe Api::EnterpriseSerializer do
|
||||
current_distributed_taxons: {enterprise.id => [123]},
|
||||
supplied_taxons: {enterprise.id => [456]},
|
||||
shipping_method_services: {},
|
||||
relatives: {enterprise.id => {producers: [123], distributors: [456]}}) }
|
||||
relatives: {enterprise.id => {producers: [123], distributors: [456]}})
|
||||
}
|
||||
|
||||
it "serializes an enterprise" do
|
||||
serializer.to_json.should match enterprise.name
|
||||
|
||||
Reference in New Issue
Block a user