diff --git a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb
index 22819c43e7..7682ce9aa7 100644
--- a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb
+++ b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb
@@ -48,7 +48,9 @@ describe Admin::StripeConnectSettingsController, type: :controller do
context "and the request to retrieve Stripe account info fails" do
before do
stub_request(:get, "https://api.stripe.com/v1/account").
- to_return(status: 401, body: "{\"error\": {\"message\": \"Invalid API Key provided: sk_test_****xxxx\"}}")
+ to_return(status: 401,
+ body: "{\"error\": {\"message\": \"Invalid API Key provided: " \
+ "sk_test_****xxxx\"}}")
end
it "sets the account status to :auth_fail_error" do
diff --git a/spec/controllers/admin/subscription_line_items_controller_spec.rb b/spec/controllers/admin/subscription_line_items_controller_spec.rb
index 897c8f858e..95fdbcdf0e 100644
--- a/spec/controllers/admin/subscription_line_items_controller_spec.rb
+++ b/spec/controllers/admin/subscription_line_items_controller_spec.rb
@@ -60,7 +60,8 @@ describe Admin::SubscriptionLineItemsController, type: :controller do
it "returns an error" do
spree_post :build, params
json_response = JSON.parse(response.body)
- expect(json_response['errors']).to eq ["#{shop.name} is not permitted to sell the selected product"]
+ expect(json_response['errors'])
+ .to eq ["#{shop.name} is not permitted to sell the selected product"]
end
end
@@ -97,7 +98,8 @@ describe Admin::SubscriptionLineItemsController, type: :controller do
before { params.merge!(schedule_id: schedule.id) }
context "where no relevant variant override exists" do
- it "returns a serialized subscription line item with a price estimate, based on the variant" do
+ it "returns a serialized subscription line item with a price estimate, " \
+ "based on the variant" do
spree_post :build, params
json_response = JSON.parse(response.body)
@@ -112,7 +114,8 @@ describe Admin::SubscriptionLineItemsController, type: :controller do
create(:variant_override, hub_id: shop.id, variant_id: variant.id, price: 12.00)
}
- it "returns a serialized subscription line item with a price estimate, based on the override" do
+ it "returns a serialized subscription line item with a price estimate, " \
+ "based on the override" do
spree_post :build, params
json_response = JSON.parse(response.body)
diff --git a/spec/controllers/admin/subscriptions_controller_spec.rb b/spec/controllers/admin/subscriptions_controller_spec.rb
index 1445afbc33..9ebc890bad 100644
--- a/spec/controllers/admin/subscriptions_controller_spec.rb
+++ b/spec/controllers/admin/subscriptions_controller_spec.rb
@@ -199,7 +199,9 @@ describe Admin::SubscriptionsController, type: :controller do
it 'returns an error' do
expect{ spree_post :create, params }.to_not change{ Subscription.count }
json_response = JSON.parse(response.body)
- expect(json_response['errors']['subscription_line_items']).to eq ["#{variant.product.name} - #{variant.full_name} is not available from the selected schedule"]
+ expect(json_response['errors']['subscription_line_items'])
+ .to eq ["#{variant.product.name} - #{variant.full_name} " \
+ "is not available from the selected schedule"]
end
end
@@ -384,11 +386,12 @@ describe Admin::SubscriptionsController, type: :controller do
context 'where the specified variants are not available from the shop' do
it 'returns an error' do
- expect{ spree_post :update, params }.to_not change{
- subscription.subscription_line_items.count
- }
+ expect{ spree_post :update, params }
+ .to_not change{ subscription.subscription_line_items.count }
json_response = JSON.parse(response.body)
- expect(json_response['errors']['subscription_line_items']).to eq ["#{product2.name} - #{variant2.full_name} is not available from the selected schedule"]
+ expect(json_response['errors']['subscription_line_items'])
+ .to eq ["#{product2.name} - #{variant2.full_name} " \
+ "is not available from the selected schedule"]
end
end
@@ -462,7 +465,10 @@ describe Admin::SubscriptionsController, type: :controller do
spree_put :cancel, params
expect(response.status).to be 409
json_response = JSON.parse(response.body)
- expect(json_response['errors']['open_orders']).to eq 'Some orders for this subscription are currently open. The customer has already been notified that the order will be placed. Would you like to cancel these order(s) or keep them?'
+ expect(json_response['errors']['open_orders'])
+ .to eq 'Some orders for this subscription are currently open. ' \
+ 'The customer has already been notified that the order will be placed. ' \
+ 'Would you like to cancel these order(s) or keep them?'
end
end
@@ -563,7 +569,10 @@ describe Admin::SubscriptionsController, type: :controller do
spree_put :pause, params
expect(response.status).to be 409
json_response = JSON.parse(response.body)
- expect(json_response['errors']['open_orders']).to eq 'Some orders for this subscription are currently open. The customer has already been notified that the order will be placed. Would you like to cancel these order(s) or keep them?'
+ expect(json_response['errors']['open_orders'])
+ .to eq 'Some orders for this subscription are currently open. ' \
+ 'The customer has already been notified that the order will be placed. ' \
+ 'Would you like to cancel these order(s) or keep them?'
end
end
@@ -683,7 +692,9 @@ describe Admin::SubscriptionsController, type: :controller do
spree_put :unpause, params
expect(response.status).to be 409
json_response = JSON.parse(response.body)
- expect(json_response['errors']['canceled_orders']).to eq 'Some orders for this subscription can be resumed right now. You can resume them from the orders dropdown.'
+ expect(json_response['errors']['canceled_orders'])
+ .to eq 'Some orders for this subscription can be resumed right now. ' \
+ 'You can resume them from the orders dropdown.'
end
end
@@ -712,7 +723,8 @@ describe Admin::SubscriptionsController, type: :controller do
expect(subscription.reload.paused_at).to be nil
end
- context "when there is an open OC and no associated orders exist yet for it (OC was opened when the subscription was paused)" do
+ context "when there is an open OC and no associated orders exist yet for it " \
+ "(OC was opened when the subscription was paused)" do
it "creates an associated order" do
spree_put :unpause, params
diff --git a/spec/controllers/admin/variant_overrides_controller_spec.rb b/spec/controllers/admin/variant_overrides_controller_spec.rb
index 6a3aa8c0e5..dfdb64d736 100644
--- a/spec/controllers/admin/variant_overrides_controller_spec.rb
+++ b/spec/controllers/admin/variant_overrides_controller_spec.rb
@@ -76,8 +76,8 @@ describe Admin::VariantOverridesController, type: :controller do
context "where params for a variant override are blank" do
let(:variant_override_params) {
- [{ id: variant_override.id, price: "", count_on_hand: "", default_stock: nil, resettable: nil,
- sku: nil, on_demand: nil }]
+ [{ id: variant_override.id, price: "", count_on_hand: "", default_stock: nil,
+ resettable: nil, sku: nil, on_demand: nil }]
}
it "destroys the variant override" do
@@ -145,7 +145,8 @@ describe Admin::VariantOverridesController, type: :controller do
allow(controller).to receive(:spree_current_user) { hub.owner }
end
- context "where the producer has not granted create_variant_overrides permission to the hub" do
+ context "where the producer has not granted create_variant_overrides permission " \
+ "to the hub" do
it "restricts access" do
put :bulk_reset, params: params
expect(response).to redirect_to unauthorized_path
@@ -174,14 +175,15 @@ describe Admin::VariantOverridesController, type: :controller do
expect(variant_override2.reload.count_on_hand).to eq 2 # reset disabled
end
- context "and the producer has granted create_variant_overrides permission to another hub I manage" do
+ context "and the producer has granted create_variant_overrides permission " \
+ "to another hub I manage" do
before { hub.owner.update_attribute(:enterprise_limit, 2) }
let(:hub2) { create(:distributor_enterprise, owner: hub.owner) }
let(:product) { create(:product, supplier: producer) }
let(:variant3) { create(:variant, product: product) }
let!(:variant_override3) {
- create(:variant_override, hub: hub2, variant: variant3, count_on_hand: 1, default_stock: 13,
- resettable: true)
+ create(:variant_override, hub: hub2, variant: variant3, count_on_hand: 1,
+ default_stock: 13, resettable: true)
}
let!(:er2) {
create(:enterprise_relationship, parent: producer, child: hub2,
diff --git a/spec/controllers/api/v0/base_controller_spec.rb b/spec/controllers/api/v0/base_controller_spec.rb
index a2b9bdde62..ae57801550 100644
--- a/spec/controllers/api/v0/base_controller_spec.rb
+++ b/spec/controllers/api/v0/base_controller_spec.rb
@@ -60,7 +60,8 @@ describe Api::V0::BaseController do
expect(subject).to receive(:authenticate_user).and_return(true)
expect(subject).to receive(:index).and_raise(ActiveRecord::RecordNotFound.new)
get :index
- expect(json_response).to eq( "error" => "The resource you were looking for could not be found." )
+ expect(json_response)
+ .to eq( "error" => "The resource you were looking for could not be found." )
expect(response.status).to eq(404)
end
end
diff --git a/spec/controllers/api/v0/exchange_products_controller_spec.rb b/spec/controllers/api/v0/exchange_products_controller_spec.rb
index a0a895edea..670d98902d 100644
--- a/spec/controllers/api/v0/exchange_products_controller_spec.rb
+++ b/spec/controllers/api/v0/exchange_products_controller_spec.rb
@@ -38,7 +38,8 @@ module Api
it "uses exchange order_cycle, incoming and enterprise to fetch products" do
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
+ expect(json_response["products"].first["supplier_name"])
+ .to eq exchange.variants.first.product.supplier.name
end
end
@@ -46,7 +47,8 @@ module Api
it "uses params order_cycle, incoming and enterprise to fetch products" do
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
+ expect(json_response["products"].first["supplier_name"])
+ .to eq exchange.variants.first.product.supplier.name
end
end
end
diff --git a/spec/controllers/api/v0/order_cycles_controller_spec.rb b/spec/controllers/api/v0/order_cycles_controller_spec.rb
index 2ed60907cf..8953f3cd8f 100644
--- a/spec/controllers/api/v0/order_cycles_controller_spec.rb
+++ b/spec/controllers/api/v0/order_cycles_controller_spec.rb
@@ -175,7 +175,8 @@ module Api
it "returns hidden variants made visible for this specific customer" do
vo1.update_attribute(:tag_list, default_hide_rule.preferred_variant_tags)
vo3.update_attribute(:tag_list,
- "#{show_rule.preferred_variant_tags},#{default_hide_rule.preferred_variant_tags}")
+ "#{show_rule.preferred_variant_tags}," \
+ "#{default_hide_rule.preferred_variant_tags}")
customer.update_attribute(:tag_list, show_rule.preferred_customer_tags)
api_get :products, id: order_cycle.id, distributor: distributor.id
diff --git a/spec/controllers/api/v0/orders_controller_spec.rb b/spec/controllers/api/v0/orders_controller_spec.rb
index 63dfdd21fe..af31a7f45c 100644
--- a/spec/controllers/api/v0/orders_controller_spec.rb
+++ b/spec/controllers/api/v0/orders_controller_spec.rb
@@ -21,19 +21,23 @@ module Api
let!(:order_cycle2) { create(:simple_order_cycle, coordinator: coordinator2) }
let!(:order1) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
- distributor: distributor, billing_address: create(:address, lastname: "c"), total: 5.0)
+ distributor: distributor, billing_address: create(:address, lastname: "c"),
+ total: 5.0)
end
let!(:order2) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
- distributor: distributor2, billing_address: create(:address, lastname: "a"), total: 10.0)
+ distributor: distributor2, billing_address: create(:address, lastname: "a"),
+ total: 10.0)
end
let!(:order3) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
- distributor: distributor, billing_address: create(:address, lastname: "b"), total: 1.0 )
+ distributor: distributor, billing_address: create(:address, lastname: "b"),
+ total: 1.0 )
end
let!(:order4) do
create(:completed_order_with_fees, order_cycle: order_cycle2, distributor: distributor2,
- billing_address: create(:address, lastname: "d"), total: 15.0)
+ billing_address: create(:address, lastname: "d"),
+ total: 15.0)
end
let!(:order5) { create(:order, state: 'cart', completed_at: nil) }
let!(:line_item1) do
@@ -137,7 +141,8 @@ module Api
end
it 'can sort orders by bill_address.lastname' do
- get :index, params: { q: { completed_at_not_null: true, s: 'bill_address_lastname ASC' } },
+ get :index, params: { q: { completed_at_not_null: true,
+ s: 'bill_address_lastname ASC' } },
as: :json
expect(json_response['orders']
@@ -232,7 +237,8 @@ module Api
expect_order
end
- it "can view an order with weight calculator (this validates case where options[current_order] is nil on the shipping method serializer)" do
+ it "can view an order with weight calculator (this validates case " \
+ "where options[current_order] is nil on the shipping method serializer)" do
order.shipping_method.update_attribute(:calculator,
create(:weight_calculator, calculable: order))
allow(controller).to receive(:current_order).and_return order
@@ -267,8 +273,10 @@ module Api
expect(json_response[:payments].first[:amount]).to eq order.payments.first.amount.to_s
expect(json_response[:line_items].size).to eq order.line_items.size
- expect(json_response[:line_items].first[:variant][:product_name]).to eq order.line_items.first.variant.product.name
- expect(json_response[:line_items].first[:tax_category_id]).to eq order.line_items.first.product.tax_category_id
+ expect(json_response[:line_items].first[:variant][:product_name])
+ .to eq order.line_items.first.variant.product.name
+ expect(json_response[:line_items].first[:tax_category_id])
+ .to eq order.line_items.first.product.tax_category_id
end
end
end
@@ -309,7 +317,8 @@ module Api
it "returns an error" do
put :capture, params: { id: order.number }
- expect(json_response['error']).to eq 'Payment could not be processed, please check the details you entered'
+ expect(json_response['error'])
+ .to eq 'Payment could not be processed, please check the details you entered'
end
end
end
diff --git a/spec/controllers/cart_controller_spec.rb b/spec/controllers/cart_controller_spec.rb
index 1c69a2bbe5..6c3fe1b5c6 100644
--- a/spec/controllers/cart_controller_spec.rb
+++ b/spec/controllers/cart_controller_spec.rb
@@ -85,7 +85,8 @@ describe CartController, type: :controller do
it "returns the variant override stock levels of the variant requested but not in the order" do
# This test passes because the variant requested gets added to the order
- # If the variant was not added to the order, VariantsStockLevels alternative calculation would fail
+ # If the variant was not added to the order,
+ # VariantsStockLevels alternative calculation would fail
# See #3222 for more details
# This indicates that the VariantsStockLevels alternative calculation is never reached
spree_post :populate, variants: { variant_not_in_the_order.id => 1 }
diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb
index d0f0c97c55..894603aea4 100644
--- a/spec/controllers/enterprises_controller_spec.rb
+++ b/spec/controllers/enterprises_controller_spec.rb
@@ -94,7 +94,7 @@ describe EnterprisesController, type: :controller do
end
end
- it "empties an order that was set for a previous distributor, when shopping at a new distributor" do
+ it "empties an order set for a previous distributor, when shopping at a new distributor" do
line_item = create(:line_item)
controller.current_order.line_items << line_item
@@ -185,7 +185,8 @@ describe EnterprisesController, type: :controller do
end
it "shows a flash message with the error" do
- expect(request.flash[:error]).to eq('The shop you are looking for doesn\'t exist or is inactive on OFN. Please check other shops.')
+ expect(request.flash[:error]).to eq('The shop you are looking for doesn\'t exist or ' \
+ 'is inactive on OFN. Please check other shops.')
end
end
end
diff --git a/spec/controllers/line_items_controller_spec.rb b/spec/controllers/line_items_controller_spec.rb
index 28f446b4f1..85c92f96d0 100644
--- a/spec/controllers/line_items_controller_spec.rb
+++ b/spec/controllers/line_items_controller_spec.rb
@@ -169,7 +169,8 @@ describe LineItemsController, type: :controller do
let(:enterprise_fee) { create(:enterprise_fee, calculator: calculator) }
let!(:exchange) {
create(:exchange, incoming: true, sender: variant1.product.supplier,
- receiver: order_cycle.coordinator, variants: [variant1, variant2], enterprise_fees: [enterprise_fee])
+ receiver: order_cycle.coordinator, variants: [variant1, variant2],
+ enterprise_fees: [enterprise_fee])
}
let!(:order) do
order = create(:completed_order_with_totals, user: user, distributor: distributor,
diff --git a/spec/controllers/shops_controller_spec.rb b/spec/controllers/shops_controller_spec.rb
index 59865906a2..97cea60cb9 100644
--- a/spec/controllers/shops_controller_spec.rb
+++ b/spec/controllers/shops_controller_spec.rb
@@ -43,7 +43,8 @@ describe ShopsController, type: :controller do
get :index
expect(response.body)
- .to match(/"distributed_properties":\[{"id":\d+,"name":"certified","presentation":"certified"}\]/)
+ .to match(/"distributed_properties":\[{"id":\d+,"name":
+ "certified","presentation":"certified"}\]/x)
end
it 'renders distributed properties' do
diff --git a/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb b/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb
index 2247eb3517..f5f4b29df4 100644
--- a/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb
+++ b/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb
@@ -52,7 +52,12 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
context "when adding details of a registered user" do
it "redirects to shipments on success" do
spree_post :update,
- order: { email: user.email, bill_address_attributes: address_params, ship_address_attributes: address_params }, order_id: order.number
+ order: {
+ email: user.email,
+ bill_address_attributes: address_params,
+ ship_address_attributes: address_params,
+ },
+ order_id: order.number
order.reload
@@ -63,7 +68,12 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
context "when adding details of an unregistered user" do
it "redirects to shipments on success" do
spree_post :update,
- order: { email: 'unregistered@email.com', bill_address_attributes: address_params, ship_address_attributes: address_params }, order_id: order.number
+ order: {
+ email: 'unregistered@email.com',
+ bill_address_attributes: address_params,
+ ship_address_attributes: address_params,
+ },
+ order_id: order.number
order.reload
diff --git a/spec/controllers/spree/admin/orders/invoices_spec.rb b/spec/controllers/spree/admin/orders/invoices_spec.rb
index 0482069cb5..a2cb39ca59 100644
--- a/spec/controllers/spree/admin/orders/invoices_spec.rb
+++ b/spec/controllers/spree/admin/orders/invoices_spec.rb
@@ -42,7 +42,8 @@ describe Spree::Admin::OrdersController, type: :controller do
spree_get :invoice, params
end.to_not change{ Spree::OrderMailer.deliveries.count }
expect(response).to redirect_to spree.edit_admin_order_path(order)
- expect(flash[:error]).to eq "#{distributor.name} must have a valid ABN before invoices can be sent."
+ expect(flash[:error])
+ .to eq "#{distributor.name} must have a valid ABN before invoices can be sent."
end
end
diff --git a/spec/controllers/spree/admin/orders_controller_spec.rb b/spec/controllers/spree/admin/orders_controller_spec.rb
index 5664d9e3a5..3737941a94 100644
--- a/spec/controllers/spree/admin/orders_controller_spec.rb
+++ b/spec/controllers/spree/admin/orders_controller_spec.rb
@@ -76,11 +76,13 @@ describe Spree::Admin::OrdersController, type: :controller do
let(:enterprise_fee) { create(:enterprise_fee, calculator: build(:calculator_per_item) ) }
let!(:exchange) {
create(:exchange, incoming: true, sender: variant1.product.supplier,
- receiver: order_cycle.coordinator, variants: [variant1, variant2], enterprise_fees: [enterprise_fee])
+ receiver: order_cycle.coordinator, variants: [variant1, variant2],
+ enterprise_fees: [enterprise_fee])
}
let!(:order) do
order = create(:completed_order_with_totals, line_items_count: 2,
- distributor: distributor, order_cycle: order_cycle)
+ distributor: distributor,
+ order_cycle: order_cycle)
order.reload.line_items.first.update(variant_id: variant1.id)
order.line_items.last.update(variant_id: variant2.id)
break unless order.next! while !order.completed?
@@ -94,14 +96,16 @@ describe Spree::Admin::OrdersController, type: :controller do
end
it "recalculates fees if the orders contents have changed" do
- expect(order.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
+ expect(order.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 2
order.contents.add(order.line_items.first.variant, 1)
spree_put :update, { id: order.number }
- expect(order.reload.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 3)
+ expect(order.reload.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 3)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 3
end
@@ -258,7 +262,8 @@ describe Spree::Admin::OrdersController, type: :controller do
spree_put :update, params
- expect(flash[:error]).to eq "Distributor or order cycle cannot supply the products in your cart"
+ expect(flash[:error])
+ .to eq "Distributor or order cycle cannot supply the products in your cart"
expect(response).to redirect_to spree.edit_admin_order_path(order)
end
end
diff --git a/spec/controllers/spree/admin/payment_methods_controller_spec.rb b/spec/controllers/spree/admin/payment_methods_controller_spec.rb
index a966cdf630..7eba0835b3 100644
--- a/spec/controllers/spree/admin/payment_methods_controller_spec.rb
+++ b/spec/controllers/spree/admin/payment_methods_controller_spec.rb
@@ -72,7 +72,10 @@ module Spree
it "does not clear password on update" do
expect(payment_method.preferred_password).to eq "haxme"
spree_put :update, id: payment_method.id,
- payment_method: { type: payment_method.class.to_s, preferred_password: "" }
+ payment_method: {
+ type: payment_method.class.to_s,
+ preferred_password: ""
+ }
expect(response).to redirect_to spree.edit_admin_payment_method_path(payment_method)
payment_method.reload
@@ -95,7 +98,8 @@ module Spree
}.to change(Spree::PaymentMethod, :count).by(1)
expect(response).to be_redirect
- expect(response).to redirect_to spree.edit_admin_payment_method_path(assigns(:payment_method))
+ expect(response).to redirect_to spree
+ .edit_admin_payment_method_path(assigns(:payment_method))
end
it "can not create a payment method of an invalid type" do
@@ -171,7 +175,8 @@ module Spree
before { allow(controller).to receive(:spree_current_user) { user } }
- context "when an attempt is made to change the stripe account holder (preferred_enterprise_id)" do
+ context "when an attempt is made to change " \
+ "the stripe account holder (preferred_enterprise_id)" do
let(:params) {
{
id: payment_method.id,
@@ -206,7 +211,8 @@ module Spree
it "does not save the payment method" do
spree_put :update, params
expect(response).to render_template :edit
- expect(assigns(:payment_method).errors.messages[:stripe_account_owner]).to include 'can\'t be blank'
+ expect(assigns(:payment_method).errors
+ .messages[:stripe_account_owner]).to include 'can\'t be blank'
end
end
@@ -216,7 +222,8 @@ module Spree
it "does not save the payment method" do
spree_put :update, params
expect(response).to render_template :edit
- expect(assigns(:payment_method).errors.messages[:stripe_account_owner]).to include 'can\'t be blank'
+ expect(assigns(:payment_method).errors
+ .messages[:stripe_account_owner]).to include 'can\'t be blank'
end
end
end
@@ -230,7 +237,8 @@ module Spree
let(:user) do
new_user = create(:user, email: 'enterprise@hub.com', password: 'blahblah',
password_confirmation: 'blahblah', )
- new_user.spree_roles = [] # for some reason unbeknown to me, this new user gets admin permissions by default.
+ # for some reason unbeknown to me, this new user gets admin permissions by default.
+ new_user.spree_roles = []
new_user.enterprise_roles.build(enterprise: enterprise).save
new_user.save
new_user
diff --git a/spec/controllers/spree/admin/variants_controller_spec.rb b/spec/controllers/spree/admin/variants_controller_spec.rb
index fa59adab89..20f18c292a 100644
--- a/spec/controllers/spree/admin/variants_controller_spec.rb
+++ b/spec/controllers/spree/admin/variants_controller_spec.rb
@@ -83,7 +83,8 @@ module Spree
it 'redirects to admin_product_variants_url' do
spree_delete :destroy, id: variant.id, product_id: variant.product.permalink,
format: 'html'
- expect(response).to redirect_to spree.admin_product_variants_url(variant.product.permalink)
+ expect(response).to redirect_to spree
+ .admin_product_variants_url(variant.product.permalink)
end
it 'destroys all its exchanges' do
diff --git a/spec/controllers/spree/credit_cards_controller_spec.rb b/spec/controllers/spree/credit_cards_controller_spec.rb
index 34ec3c0951..df065d1d1b 100644
--- a/spec/controllers/spree/credit_cards_controller_spec.rb
+++ b/spec/controllers/spree/credit_cards_controller_spec.rb
@@ -221,11 +221,12 @@ describe Spree::CreditCardsController, type: :controller do
it "deletes the card and redirects to account_path" do
expect{ spree_delete :destroy, params }.to change(Spree::CreditCard, :count).by(-1)
- expect(flash[:success]).to eq "Your card has been removed (number: %s)" % "x-#{card.last_digits}"
+ expect(flash[:success])
+ .to eq "Your card has been removed (number: %s)" % "x-#{card.last_digits}"
expect(response.status).to eq 200
end
- context "the card is the default card and there are existing authorizations for the user" do
+ context "card is the default card and there are existing authorizations for the user" do
before do
card.update_attribute(:is_default, true)
end
diff --git a/spec/controllers/spree/orders_controller_spec.rb b/spec/controllers/spree/orders_controller_spec.rb
index ace06eccee..d863666fd2 100644
--- a/spec/controllers/spree/orders_controller_spec.rb
+++ b/spec/controllers/spree/orders_controller_spec.rb
@@ -123,7 +123,8 @@ describe Spree::OrdersController, type: :controller do
get :edit
expect(response).to redirect_to root_url
- expect(flash[:info]).to eq('The hub you have selected is temporarily closed for orders. Please try again later.')
+ expect(flash[:info]).to eq('The hub you have selected is temporarily closed for orders. ' \
+ 'Please try again later.')
end
describe "when an item is in the cart" do
@@ -162,7 +163,8 @@ describe Spree::OrdersController, type: :controller do
it "displays a flash message when we view the cart" do
get :edit
expect(response.status).to eq 200
- expect(flash[:error]).to eq 'An item in your cart has become unavailable. Please update the selected quantities.'
+ expect(flash[:error]).to eq 'An item in your cart has become unavailable. ' \
+ 'Please update the selected quantities.'
end
end
@@ -174,7 +176,8 @@ describe Spree::OrdersController, type: :controller do
it "displays a flash message when we view the cart" do
get :edit
expect(response.status).to eq 200
- expect(flash[:error]).to eq 'An item in your cart has become unavailable. Please update the selected quantities.'
+ expect(flash[:error]).to eq 'An item in your cart has become unavailable. ' \
+ 'Please update the selected quantities.'
end
end
end
@@ -232,7 +235,8 @@ describe Spree::OrdersController, type: :controller do
let(:shipping_tax_category) { create(:tax_category, tax_rates: [shipping_tax_rate]) }
let(:order) {
create(:completed_order_with_fees, distributor: distributor, shipping_fee: shipping_fee,
- payment_fee: payment_fee, shipping_tax_category: shipping_tax_category)
+ payment_fee: payment_fee,
+ shipping_tax_category: shipping_tax_category)
}
let(:line_item1) { order.line_items.first }
let(:line_item2) { order.line_items.second }
@@ -280,11 +284,13 @@ describe Spree::OrdersController, type: :controller do
let(:enterprise_fee) { create(:enterprise_fee, calculator: build(:calculator_per_item) ) }
let!(:exchange) {
create(:exchange, incoming: true, sender: variant1.product.supplier,
- receiver: order_cycle.coordinator, variants: [variant1, variant2], enterprise_fees: [enterprise_fee])
+ receiver: order_cycle.coordinator, variants: [variant1, variant2],
+ enterprise_fees: [enterprise_fee])
}
let!(:order) do
order = create(:completed_order_with_totals, line_items_count: 2, user: user,
- distributor: distributor, order_cycle: order_cycle)
+ distributor: distributor,
+ order_cycle: order_cycle)
order.reload.line_items.first.update(variant_id: variant1.id)
order.reload.line_items.last.update(variant_id: variant2.id)
break unless order.next! while !order.completed?
@@ -303,13 +309,15 @@ describe Spree::OrdersController, type: :controller do
end
it "updates the fees" do
- expect(order.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
+ expect(order.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 2
allow(controller).to receive_messages spree_current_user: user
spree_post :update, params
- expect(order.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 3)
+ expect(order.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 3)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 3
end
@@ -322,13 +330,15 @@ describe Spree::OrdersController, type: :controller do
}
it "updates the fees" do
- expect(order.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
+ expect(order.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 2)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 2
allow(controller).to receive_messages spree_current_user: user
spree_post :update, params
- expect(order.total).to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 1)
+ expect(order.total)
+ .to eq order.item_total + (enterprise_fee.calculator.preferred_amount * 1)
expect(order.adjustment_total).to eq enterprise_fee.calculator.preferred_amount * 1
end
end
@@ -360,7 +370,8 @@ describe Spree::OrdersController, type: :controller do
it "does not remove items, flash suggests cancellation" do
spree_post :update, params
- expect(flash[:error]).to eq 'Cannot remove the final item from an order, please cancel the order instead.'
+ expect(flash[:error])
+ .to eq 'Cannot remove the final item from an order, please cancel the order instead.'
expect(response).to redirect_to order_path(order)
expect(order.reload.line_items.count).to eq 2
end
diff --git a/spec/controllers/stripe/webhooks_controller_spec.rb b/spec/controllers/stripe/webhooks_controller_spec.rb
index c993f91d35..0e87b9517f 100644
--- a/spec/controllers/stripe/webhooks_controller_spec.rb
+++ b/spec/controllers/stripe/webhooks_controller_spec.rb
@@ -29,9 +29,10 @@ describe Stripe::WebhooksController, type: :controller do
context "when event signature verification fails" do
before do
- allow(Stripe::Webhook).to receive(:construct_event).and_raise Stripe::SignatureVerificationError.new(
- "verfication failed", "header"
- )
+ allow(Stripe::Webhook).to receive(:construct_event)
+ .and_raise Stripe::SignatureVerificationError.new(
+ "verfication failed", "header"
+ )
end
it "responds with a 401" do
diff --git a/spec/factories/stock_location_factory.rb b/spec/factories/stock_location_factory.rb
index 1022c986af..66260b654e 100644
--- a/spec/factories/stock_location_factory.rb
+++ b/spec/factories/stock_location_factory.rb
@@ -16,8 +16,8 @@ FactoryBot.define do
country { |stock_location| Spree::Country.first || stock_location.association(:country) }
state do |stock_location|
- stock_location.country.states.first || stock_location.association(:state,
- country: stock_location.country)
+ stock_location.country.states.first ||
+ stock_location.association(:state, country: stock_location.country)
end
factory :stock_location_with_items do
@@ -27,8 +27,10 @@ FactoryBot.define do
product_1 = create(:product)
product_2 = create(:product)
- stock_location.stock_items.where(variant_id: product_1.variants.first.id).first.adjust_count_on_hand(10)
- stock_location.stock_items.where(variant_id: product_2.variants.first.id).first.adjust_count_on_hand(20)
+ stock_location.stock_items.where(variant_id: product_1.variants.first.id)
+ .first.adjust_count_on_hand(10)
+ stock_location.stock_items.where(variant_id: product_2.variants.first.id)
+ .first.adjust_count_on_hand(20)
end
end
end
diff --git a/spec/helpers/injection_helper_spec.rb b/spec/helpers/injection_helper_spec.rb
index 06319fa87b..75fbb5189c 100644
--- a/spec/helpers/injection_helper_spec.rb
+++ b/spec/helpers/injection_helper_spec.rb
@@ -59,7 +59,8 @@ describe InjectionHelper, type: :helper do
end
it "injects current OC when OC not null" do
- allow(helper).to receive(:current_order_cycle).and_return order_cycle = create(:simple_order_cycle)
+ allow(helper).to receive(:current_order_cycle)
+ .and_return order_cycle = create(:simple_order_cycle)
expect(helper.inject_current_order_cycle).to match order_cycle.id.to_s
end
end
diff --git a/spec/helpers/order_cycles_helper_spec.rb b/spec/helpers/order_cycles_helper_spec.rb
index a5fa043c12..504170ba7d 100644
--- a/spec/helpers/order_cycles_helper_spec.rb
+++ b/spec/helpers/order_cycles_helper_spec.rb
@@ -33,8 +33,8 @@ describe OrderCyclesHelper, type: :helper do
end
it "asks for a validation option list" do
- expect(helper).to receive(:validated_enterprise_options).with("enterprise list",
- shipping_and_payment_methods: true)
+ expect(helper).to receive(:validated_enterprise_options)
+ .with("enterprise list", shipping_and_payment_methods: true)
helper.permitted_hub_enterprise_options_for(oc)
end
end
diff --git a/spec/helpers/spree/admin/base_helper_spec.rb b/spec/helpers/spree/admin/base_helper_spec.rb
index 4a862dd831..e16c8ff730 100644
--- a/spec/helpers/spree/admin/base_helper_spec.rb
+++ b/spec/helpers/spree/admin/base_helper_spec.rb
@@ -15,7 +15,10 @@ describe Spree::Admin::BaseHelper, type: :helper do
subject { helper.link_to_remove_fields(name, form, options) }
it 'returns an `a` tag followed by a hidden `input` tag' do
- expect(subject).to eq("Hola<input type="hidden" name="_method" value="destroy">")
+ expect(subject).to eq("" \
+ "Hola<input type="hidden" " \
+ "name="_method" value="destroy">")
end
end
end
diff --git a/spec/jobs/subscription_confirm_job_spec.rb b/spec/jobs/subscription_confirm_job_spec.rb
index 7c7748818a..62d02fc00d 100644
--- a/spec/jobs/subscription_confirm_job_spec.rb
+++ b/spec/jobs/subscription_confirm_job_spec.rb
@@ -122,7 +122,8 @@ describe SubscriptionConfirmJob do
}
let!(:order_cycle5) { create(:simple_order_cycle, orders_close_at: 1.minute.from_now) }
- it "returns closed order cycles whose orders_close_at or updated_at date is within the last hour" do
+ it "returns closed order cycles whose orders_close_at " \
+ "or updated_at date is within the last hour" do
order_cycles = job.send(:recently_closed_order_cycles)
expect(order_cycles).to include order_cycle3, order_cycle4
expect(order_cycles).to_not include order_cycle1, order_cycle2, order_cycle5
diff --git a/spec/jobs/subscription_placement_job_spec.rb b/spec/jobs/subscription_placement_job_spec.rb
index c4ee87bb94..ed1bb5b70e 100644
--- a/spec/jobs/subscription_placement_job_spec.rb
+++ b/spec/jobs/subscription_placement_job_spec.rb
@@ -81,7 +81,8 @@ describe SubscriptionPlacementJob do
job.perform
expect(summarizer.recorded_issues[order.id])
- .to eq("Errors: Cannot transition state via :next from :address (Reason(s): Items cannot be shipped)")
+ .to eq("Errors: Cannot transition state via :next from :address " \
+ "(Reason(s): Items cannot be shipped)")
end
end
end
diff --git a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
index f6fe5627b8..7812a2086e 100644
--- a/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
+++ b/spec/lib/open_food_network/enterprise_fee_calculator_spec.rb
@@ -15,7 +15,7 @@ module OpenFoodNetwork
let(:product2) { create(:simple_product, supplier: supplier2, price: 20.00) }
describe "calculating fees for a variant" do
- describe "summing all the per-item fees for the variant in the specified hub + order cycle" do
+ describe "summing all the per-item fees for variant in the specified hub + order cycle" do
let(:enterprise_fee1) { create(:enterprise_fee, amount: 20) }
let(:enterprise_fee2) { create(:enterprise_fee, amount: 3) }
let(:enterprise_fee3) {
@@ -24,33 +24,36 @@ 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.variants.first])
+ create(:exchange, order_cycle: order_cycle, sender: supplier1, receiver: coordinator,
+ incoming: true, enterprise_fees: [enterprise_fee1],
+ variants: [product1.variants.first])
}
let!(:exchange2) {
- create(:exchange, order_cycle: order_cycle, sender: supplier2, receiver: coordinator, incoming: true,
- enterprise_fees: [enterprise_fee2], variants: [product2.variants.first])
+ create(:exchange, order_cycle: order_cycle, sender: supplier2, receiver: coordinator,
+ incoming: true, enterprise_fees: [enterprise_fee2],
+ variants: [product2.variants.first])
}
it "calculates via regular computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_for(product1.variants.first)).to eq(20)
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_for(product2.variants.first)).to eq(3)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_for(product1.variants.first)).to eq(20)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_for(product2.variants.first)).to eq(3)
end
it "calculates via indexed computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_for(product1.variants.first)).to eq(20)
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_for(product2.variants.first)).to eq(3)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_for(product1.variants.first)).to eq(20)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_for(product2.variants.first)).to eq(3)
end
end
describe "coordinator fees" do
let!(:exchange) {
- create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor, incoming: false,
- enterprise_fees: [], variants: [product1.variants.first])
+ create(:exchange, order_cycle: order_cycle, sender: coordinator,
+ receiver: distributor, incoming: false, enterprise_fees: [],
+ variants: [product1.variants.first])
}
before do
@@ -58,52 +61,61 @@ module OpenFoodNetwork
end
it "sums via regular computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_for(product1.variants.first)).to eq(23)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_for(product1.variants.first)).to eq(23)
end
it "sums via indexed computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_for(product1.variants.first)).to eq(23)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_for(product1.variants.first)).to eq(23)
end
end
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.variants.first])
+ create(:exchange, order_cycle: order_cycle, sender: coordinator,
+ receiver: distributor, incoming: false,
+ enterprise_fees: [enterprise_fee1,
+ enterprise_fee2,
+ enterprise_fee3],
+ variants: [product1.variants.first])
}
it "sums via regular computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_for(product1.variants.first)).to eq(23)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_for(product1.variants.first)).to eq(23)
end
it "sums via indexed computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_for(product1.variants.first)).to eq(23)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_for(product1.variants.first)).to eq(23)
end
end
end
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))
+ 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.variants.first])
+ create(:exchange, order_cycle: order_cycle, sender: coordinator, receiver: distributor,
+ incoming: false, enterprise_fees: [enterprise_fee1],
+ variants: [product1.variants.first])
}
it "sums via regular computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_for(product1.variants.first)).to eq(2.00)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_for(product1.variants.first)).to eq(2.00)
end
it "sums via indexed computation" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_for(product1.variants.first)).to eq(2.00)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_for(product1.variants.first)).to eq(2.00)
end
end
end
@@ -135,31 +147,31 @@ module OpenFoodNetwork
end
it "returns a breakdown of fees" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_by_type_for(product1.variants.first)).to eq(admin: 1.23, sales: 4.56, packing: 7.89,
- transport: 0.12, fundraising: 3.45)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_by_type_for(product1.variants.first))
+ .to eq(admin: 1.23, sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45)
end
it "filters out zero fees" do
ef_admin.calculator.update_attribute :preferred_amount, 0
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).fees_by_type_for(product1.variants.first)).to eq(sales: 4.56, packing: 7.89, transport: 0.12,
- fundraising: 3.45)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .fees_by_type_for(product1.variants.first))
+ .to eq(sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45)
end
end
describe "indexed computation" do
it "returns a breakdown of fees" do
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_by_type_for(product1.variants.first)).to eq(admin: 1.23, sales: 4.56,
- packing: 7.89, transport: 0.12, fundraising: 3.45)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_by_type_for(product1.variants.first))
+ .to eq(admin: 1.23, sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45)
end
it "filters out zero fees" do
ef_admin.calculator.update_attribute :preferred_amount, 0
- expect(EnterpriseFeeCalculator.new(distributor,
- order_cycle).indexed_fees_by_type_for(product1.variants.first)).to eq(sales: 4.56, packing: 7.89,
- transport: 0.12, fundraising: 3.45)
+ expect(EnterpriseFeeCalculator.new(distributor, order_cycle)
+ .indexed_fees_by_type_for(product1.variants.first))
+ .to eq(sales: 4.56, packing: 7.89, transport: 0.12, fundraising: 3.45)
end
end
end
@@ -224,14 +236,14 @@ module OpenFoodNetwork
end
it "includes the exchange variant id" do
- expect(subject.send(:per_item_enterprise_fees_with_exchange_details).first.variant_id.to_i).to eq(
- v.id
- )
+ expect(subject.send(:per_item_enterprise_fees_with_exchange_details)
+ .first.variant_id.to_i).to eq(v.id)
end
it "does not include outgoing exchanges to other distributors" do
create(:exchange, order_cycle: order_cycle, sender: order_cycle.coordinator,
- receiver: distributor_other, enterprise_fees: [ef_other_distributor], variants: [v])
+ receiver: distributor_other, enterprise_fees: [ef_other_distributor],
+ variants: [v])
expect(subject.send(:per_item_enterprise_fees_with_exchange_details)).to eq([ef_exchange])
end
@@ -293,7 +305,8 @@ module OpenFoodNetwork
it "makes fee applicators for a line item" do
expect(efc.send(:per_item_enterprise_fee_applicators_for, line_item.variant))
- .to eq [OpenFoodNetwork::EnterpriseFeeApplicator.new(ef1, line_item.variant, 'supplier'),
+ .to eq [OpenFoodNetwork::EnterpriseFeeApplicator.new(ef1, line_item.variant,
+ 'supplier'),
OpenFoodNetwork::EnterpriseFeeApplicator.new(ef2, line_item.variant,
'distributor'),
OpenFoodNetwork::EnterpriseFeeApplicator.new(ef3, line_item.variant,
diff --git a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb
index 677152ce9f..306f1932b2 100644
--- a/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb
+++ b/spec/lib/open_food_network/order_cycle_form_applicator_spec.rb
@@ -14,20 +14,24 @@ module OpenFoodNetwork
supplier_id = 456
incoming_exchange = { enterprise_id: supplier_id, incoming: true,
- variants: { '1' => true, '2' => false, '3' => true }, enterprise_fee_ids: [1, 2], receival_instructions: 'receival instructions' }
+ variants: { '1' => true, '2' => false, '3' => true },
+ enterprise_fee_ids: [1, 2],
+ receival_instructions: 'receival instructions' }
oc = double(:order_cycle, coordinator_id: coordinator_id, exchanges: [],
incoming_exchanges: [incoming_exchange], outgoing_exchanges: [])
applicator = OrderCycleFormApplicator.new(oc, user)
- expect(applicator).to receive(:incoming_exchange_variant_ids).with(incoming_exchange).and_return([
- 1, 3
- ])
+ expect(applicator).to receive(:incoming_exchange_variant_ids)
+ .with(incoming_exchange).and_return([1, 3])
expect(applicator).to receive(:exchange_exists?).with(supplier_id, coordinator_id,
true).and_return(false)
- expect(applicator).to receive(:add_exchange).with(supplier_id, coordinator_id, true,
- variant_ids: [1, 3], enterprise_fee_ids: [1, 2], receival_instructions: 'receival instructions')
+ expect(applicator).to receive(:add_exchange)
+ .with(supplier_id, coordinator_id, true,
+ variant_ids: [1, 3],
+ enterprise_fee_ids: [1, 2],
+ receival_instructions: 'receival instructions')
expect(applicator).to receive(:destroy_untouched_exchanges)
applicator.go!
@@ -38,20 +42,26 @@ module OpenFoodNetwork
distributor_id = 456
outgoing_exchange = { enterprise_id: distributor_id, incoming: false,
- variants: { '1' => true, '2' => false, '3' => true }, enterprise_fee_ids: [1, 2], pickup_time: 'pickup time', pickup_instructions: 'pickup instructions', tag_list: 'wholesale' }
+ variants: { '1' => true, '2' => false, '3' => true },
+ enterprise_fee_ids: [1, 2], pickup_time: 'pickup time',
+ pickup_instructions: 'pickup instructions', tag_list: 'wholesale' }
oc = double(:order_cycle, coordinator_id: coordinator_id, exchanges: [],
incoming_exchanges: [], outgoing_exchanges: [outgoing_exchange])
applicator = OrderCycleFormApplicator.new(oc, user)
- expect(applicator).to receive(:outgoing_exchange_variant_ids).with(outgoing_exchange).and_return([
- 1, 3
- ])
+ expect(applicator).to receive(:outgoing_exchange_variant_ids)
+ .with(outgoing_exchange).and_return([1, 3])
expect(applicator).to receive(:exchange_exists?).with(coordinator_id, distributor_id,
false).and_return(false)
- expect(applicator).to receive(:add_exchange).with(coordinator_id, distributor_id, false,
- variant_ids: [1, 3], enterprise_fee_ids: [1, 2], pickup_time: 'pickup time', pickup_instructions: 'pickup instructions', tag_list: 'wholesale')
+ expect(applicator).to receive(:add_exchange)
+ .with(coordinator_id, distributor_id, false,
+ variant_ids: [1, 3],
+ enterprise_fee_ids: [1, 2],
+ pickup_time: 'pickup time',
+ pickup_instructions: 'pickup instructions',
+ tag_list: 'wholesale')
expect(applicator).to receive(:destroy_untouched_exchanges)
applicator.go!
@@ -62,7 +72,9 @@ module OpenFoodNetwork
supplier_id = 456
incoming_exchange = { enterprise_id: supplier_id, incoming: true,
- variants: { '1' => true, '2' => false, '3' => true }, enterprise_fee_ids: [1, 2], receival_instructions: 'receival instructions' }
+ variants: { '1' => true, '2' => false, '3' => true },
+ enterprise_fee_ids: [1, 2],
+ receival_instructions: 'receival instructions' }
oc = double(:order_cycle,
coordinator_id: coordinator_id,
@@ -73,13 +85,15 @@ module OpenFoodNetwork
applicator = OrderCycleFormApplicator.new(oc, user)
- expect(applicator).to receive(:incoming_exchange_variant_ids).with(incoming_exchange).and_return([
- 1, 3
- ])
+ expect(applicator).to receive(:incoming_exchange_variant_ids)
+ .with(incoming_exchange).and_return([1, 3])
expect(applicator).to receive(:exchange_exists?).with(supplier_id, coordinator_id,
true).and_return(true)
- expect(applicator).to receive(:update_exchange).with(supplier_id, coordinator_id, true,
- variant_ids: [1, 3], enterprise_fee_ids: [1, 2], receival_instructions: 'receival instructions')
+ expect(applicator).to receive(:update_exchange)
+ .with(supplier_id, coordinator_id, true,
+ variant_ids: [1, 3],
+ enterprise_fee_ids: [1, 2],
+ receival_instructions: 'receival instructions')
expect(applicator).to receive(:destroy_untouched_exchanges)
applicator.go!
@@ -90,7 +104,9 @@ module OpenFoodNetwork
distributor_id = 456
outgoing_exchange = { enterprise_id: distributor_id, incoming: false,
- variants: { '1' => true, '2' => false, '3' => true }, enterprise_fee_ids: [1, 2], pickup_time: 'pickup time', pickup_instructions: 'pickup instructions', tag_list: 'wholesale' }
+ variants: { '1' => true, '2' => false, '3' => true },
+ enterprise_fee_ids: [1, 2], pickup_time: 'pickup time',
+ pickup_instructions: 'pickup instructions', tag_list: 'wholesale' }
oc = double(:order_cycle,
coordinator_id: coordinator_id,
@@ -101,13 +117,17 @@ module OpenFoodNetwork
applicator = OrderCycleFormApplicator.new(oc, user)
- expect(applicator).to receive(:outgoing_exchange_variant_ids).with(outgoing_exchange).and_return([
- 1, 3
- ])
+ expect(applicator).to receive(:outgoing_exchange_variant_ids)
+ .with(outgoing_exchange).and_return([1, 3])
expect(applicator).to receive(:exchange_exists?).with(coordinator_id, distributor_id,
false).and_return(true)
- expect(applicator).to receive(:update_exchange).with(coordinator_id, distributor_id, false,
- variant_ids: [1, 3], enterprise_fee_ids: [1, 2], pickup_time: 'pickup time', pickup_instructions: 'pickup instructions', tag_list: 'wholesale')
+ expect(applicator).to receive(:update_exchange)
+ .with(coordinator_id, distributor_id, false,
+ variant_ids: [1, 3],
+ enterprise_fee_ids: [1, 2],
+ pickup_time: 'pickup time',
+ pickup_instructions: 'pickup instructions',
+ tag_list: 'wholesale')
expect(applicator).to receive(:destroy_untouched_exchanges)
applicator.go!
@@ -232,7 +252,8 @@ module OpenFoodNetwork
# Keeps existing variants that are not editable
expect(ids).to include v6.id
- # Removes existing variants that are not in an incoming exchange, regardless of whether they are not editable
+ # Removes existing variants that are not in an incoming exchange,
+ # regardless of whether they are not editable
expect(ids).to_not include v7.id, v8.id
# Does not add variants that are not in an incoming exchange
@@ -362,7 +383,8 @@ module OpenFoodNetwork
allow(applicator).to receive(:manages_coordinator?) { true }
applicator.send(:touched_exchanges=, [])
applicator.send(:add_exchange, sender.id, receiver.id, incoming,
- variant_ids: [variant1.id, variant2.id], enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
+ variant_ids: [variant1.id, variant2.id],
+ enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
end
it "adds new exchanges" do
@@ -381,7 +403,8 @@ module OpenFoodNetwork
before do
allow(applicator).to receive(:manages_coordinator?) { false }
applicator.send(:add_exchange, sender.id, receiver.id, incoming,
- variant_ids: [variant1.id, variant2.id], enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
+ variant_ids: [variant1.id, variant2.id],
+ enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
end
it "does not add new exchanges" do
@@ -405,7 +428,8 @@ module OpenFoodNetwork
let!(:exchange) {
create(:exchange, order_cycle: oc, sender: sender, receiver: receiver, incoming: incoming,
- variant_ids: [variant1.id, variant2.id], enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
+ variant_ids: [variant1.id, variant2.id],
+ enterprise_fee_ids: [enterprise_fee1.id, enterprise_fee2.id])
}
context "as a manager of the coorindator" do
@@ -415,7 +439,11 @@ module OpenFoodNetwork
allow(applicator).to receive(:permission_for) { true }
applicator.send(:touched_exchanges=, [])
applicator.send(:update_exchange, sender.id, receiver.id, incoming,
- variant_ids: [variant1.id, variant3.id], enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], pickup_time: 'New Pickup Time', pickup_instructions: 'New Pickup Instructions', tag_list: 'wholesale')
+ variant_ids: [variant1.id, variant3.id],
+ enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id],
+ pickup_time: 'New Pickup Time',
+ pickup_instructions: 'New Pickup Instructions',
+ tag_list: 'wholesale')
end
it "updates the variants, enterprise fees tags, and pickup information of the exchange" do
@@ -436,7 +464,11 @@ module OpenFoodNetwork
allow(applicator).to receive(:permission_for) { true }
applicator.send(:touched_exchanges=, [])
applicator.send(:update_exchange, sender.id, receiver.id, incoming,
- variant_ids: [variant1.id, variant3.id], enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], pickup_time: 'New Pickup Time', pickup_instructions: 'New Pickup Instructions', tag_list: 'wholesale')
+ variant_ids: [variant1.id, variant3.id],
+ enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id],
+ pickup_time: 'New Pickup Time',
+ pickup_instructions: 'New Pickup Instructions',
+ tag_list: 'wholesale')
end
it "updates the variants, enterprise fees, tags and pickup information of the exchange" do
@@ -457,7 +489,11 @@ module OpenFoodNetwork
allow(applicator).to receive(:permission_for) { true }
applicator.send(:touched_exchanges=, [])
applicator.send(:update_exchange, sender.id, receiver.id, incoming,
- variant_ids: [variant1.id, variant3.id], enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id], pickup_time: 'New Pickup Time', pickup_instructions: 'New Pickup Instructions', tag_list: 'wholesale')
+ variant_ids: [variant1.id, variant3.id],
+ enterprise_fee_ids: [enterprise_fee2.id, enterprise_fee3.id],
+ pickup_time: 'New Pickup Time',
+ pickup_instructions: 'New Pickup Instructions',
+ tag_list: 'wholesale')
end
it "updates the variants in the exchange, but not the fees, tags or pickup information" do
diff --git a/spec/lib/open_food_network/order_cycle_permissions_spec.rb b/spec/lib/open_food_network/order_cycle_permissions_spec.rb
index 4cabc5d3ac..4e05bcb38b 100644
--- a/spec/lib/open_food_network/order_cycle_permissions_spec.rb
+++ b/spec/lib/open_food_network/order_cycle_permissions_spec.rb
@@ -205,7 +205,7 @@ module OpenFoodNetwork
expect(enterprises).to_not include producer, coordinator
end
- context "and distributes variants distributed by an unmanaged and unpermitted producer" do
+ context "and distributes variants distributed by an unmanaged & unpermitted producer" do
before {
ex.variants << create(:variant, product: create(:product, supplier: producer))
}
@@ -418,9 +418,11 @@ module OpenFoodNetwork
end
end
- # TODO: this is testing legacy behaviour for backwards compatability, remove when behaviour no longer required
+ # TODO: this is testing legacy behaviour for backwards compatability,
+ # remove when behaviour no longer required
describe "legacy compatability" do
- context "where my hub's outgoing exchange contains variants of a producer I don't manage and has not given my hub P-OC" do
+ context "where my hub's outgoing exchange contains variants of a producer " \
+ "I don't manage and has not given my hub P-OC" do
let!(:product) { create(:product, supplier: producer) }
let!(:variant) { create(:variant, product: product) }
let!(:ex_out) {
@@ -478,7 +480,8 @@ module OpenFoodNetwork
end
end
- # TODO: this is testing legacy behaviour for backwards compatability, remove when behaviour no longer required
+ # TODO: this is testing legacy behaviour for backwards compatability,
+ # remove when behaviour no longer required
describe "legacy compatability" do
context "where an outgoing exchange contains variants of a producer I manage" do
let!(:product) { create(:product, supplier: producer) }
@@ -506,7 +509,8 @@ module OpenFoodNetwork
end
end
- describe "finding the variants within a hypothetical exchange between two enterprises which are visible to a user" do
+ describe "finding the variants within a hypothetical exchange " \
+ "between two enterprises which are visible to a user" do
let!(:producer1) { create(:supplier_enterprise) }
let!(:producer2) { create(:supplier_enterprise) }
let!(:v1) { create(:variant, product: create(:simple_product, supplier: producer1)) }
@@ -591,13 +595,14 @@ module OpenFoodNetwork
context "where the coordinator produces products" do
let!(:v3) { create(:variant, product: create(:simple_product, supplier: coordinator)) }
- it "returns any variants produced by the coordinator itself for exchanges with 'self'" do
+ it "returns any variants produced by the coordinator itself for exchanges w/ 'self'" do
visible = permissions.visible_variants_for_outgoing_exchanges_to(coordinator)
expect(visible).to include v3
expect(visible).to_not include v1, v2
end
- it "does not return coordinator's variants for exchanges with other hubs, when permission has not been granted" do
+ it "does not return coordinator's variants for exchanges with other hubs, " \
+ "when permission has not been granted" do
visible = permissions.visible_variants_for_outgoing_exchanges_to(hub)
expect(visible).to include v1
expect(visible).to_not include v2, v3
@@ -605,7 +610,8 @@ module OpenFoodNetwork
end
# TODO: for backwards compatability, remove later
- context "when an exchange exists between the coordinator and the hub within this order cycle" do
+ context "when an exchange exists between the coordinator " \
+ "and the hub within this order cycle" do
let!(:ex) {
create(:exchange, order_cycle: oc, sender: coordinator, receiver: hub,
incoming: false)
@@ -645,7 +651,8 @@ module OpenFoodNetwork
end
# TODO: for backwards compatability, remove later
- context "when an exchange exists between the coordinator and the hub within this order cycle" do
+ context "when an exchange exists between the coordinator " \
+ "and the hub within this order cycle" do
let!(:ex) {
create(:exchange, order_cycle: oc, sender: coordinator, receiver: hub,
incoming: false)
@@ -727,7 +734,8 @@ module OpenFoodNetwork
end
end
- describe "finding the variants within a hypothetical exchange between two enterprises which are editable by a user" do
+ describe "finding the variants within a hypothetical exchange " \
+ "between two enterprises which are editable by a user" do
let!(:producer1) { create(:supplier_enterprise) }
let!(:producer2) { create(:supplier_enterprise) }
let!(:v1) { create(:variant, product: create(:simple_product, supplier: producer1)) }
@@ -795,13 +803,14 @@ module OpenFoodNetwork
context "where the coordinator produces products" do
let!(:v3) { create(:variant, product: create(:simple_product, supplier: coordinator)) }
- it "returns any variants produced by the coordinator itself for exchanges with 'self'" do
+ it "returns any variants produced by the coordinator itself for exchanges w/ 'self'" do
visible = permissions.editable_variants_for_outgoing_exchanges_to(coordinator)
expect(visible).to include v3
expect(visible).to_not include v1, v2
end
- it "does not return coordinator's variants for exchanges with other hubs, when permission has not been granted" do
+ it "does not return coordinator's variants for exchanges with other hubs, " \
+ "when permission has not been granted" do
visible = permissions.editable_variants_for_outgoing_exchanges_to(hub)
expect(visible).to include v1
expect(visible).to_not include v2, v3
@@ -809,7 +818,7 @@ module OpenFoodNetwork
end
# TODO: for backwards compatability, remove later
- context "when an exchange exists between the coordinator and the hub within this order cycle" do
+ context "when an exchange exists between the coordinator and the hub within this OC" do
let!(:ex) {
create(:exchange, order_cycle: oc, sender: coordinator, receiver: hub,
incoming: false)
@@ -849,7 +858,8 @@ module OpenFoodNetwork
end
# TODO: for backwards compatability, remove later
- context "when an exchange exists between the coordinator and the hub within this order cycle" do
+ context "when an exchange exists between the coordinator " \
+ "and the hub within this order cycle" do
let!(:ex) {
create(:exchange, order_cycle: oc, sender: coordinator, receiver: hub,
incoming: false)
diff --git a/spec/lib/open_food_network/permissions_spec.rb b/spec/lib/open_food_network/permissions_spec.rb
index 3eabe3f0ac..62e9e2aa7a 100644
--- a/spec/lib/open_food_network/permissions_spec.rb
+++ b/spec/lib/open_food_network/permissions_spec.rb
@@ -36,7 +36,7 @@ module OpenFoodNetwork
end
end
- describe "finding managed and related enterprises granting or granted a particular permission" do
+ describe "finding managed & related enterprises granting or granted a particular permission" do
describe "as super admin" do
before { allow(user).to receive(:admin?) { true } }
@@ -157,7 +157,8 @@ module OpenFoodNetwork
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
@@ -180,7 +181,8 @@ module OpenFoodNetwork
expect(permissions.variant_override_enterprises_per_hub[hub.id]).to_not include producer2.id
end
- it "returns itself if self is also a primary producer (even when no explicit permission exists)" do
+ it "returns itself if self is also a primary producer " \
+ "(even when no explicit permission exists)" do
hub.update_attribute(:is_primary_producer, true)
expect(permissions.variant_override_enterprises_per_hub[hub.id]).to include hub.id
diff --git a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
index 930c078f29..4b6b2f8cb7 100644
--- a/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
+++ b/spec/lib/open_food_network/scope_variant_to_hub_spec.rb
@@ -10,8 +10,8 @@ module OpenFoodNetwork
let(:v2) { create(:variant, price: 22.22, on_hand: 5) }
let(:v3) { create(:variant, price: 33.33, on_hand: 6) }
let(:vo) {
- create(:variant_override, hub: hub, variant: v, price: 22.22, count_on_hand: 2, on_demand: false,
- sku: "VOSKU")
+ create(:variant_override, hub: hub, variant: v, price: 22.22, count_on_hand: 2,
+ on_demand: false, sku: "VOSKU")
}
let(:vo2) {
create(:variant_override, hub: hub, variant: v2, price: 33.33, count_on_hand: nil,
diff --git a/spec/lib/open_food_network/tag_rule_applicator_spec.rb b/spec/lib/open_food_network/tag_rule_applicator_spec.rb
index 7ec0e29f2a..336324fb3f 100644
--- a/spec/lib/open_food_network/tag_rule_applicator_spec.rb
+++ b/spec/lib/open_food_network/tag_rule_applicator_spec.rb
@@ -8,27 +8,40 @@ module OpenFoodNetwork
let!(:enterprise) { create(:distributor_enterprise) }
let!(:oc_tag_rule) {
create(:filter_order_cycles_tag_rule, enterprise: enterprise, priority: 6,
- preferred_customer_tags: "tag1", preferred_exchange_tags: "tag1", preferred_matched_order_cycles_visibility: "visible" )
+ preferred_customer_tags: "tag1",
+ preferred_exchange_tags: "tag1",
+ preferred_matched_order_cycles_visibility: "visible" )
}
let!(:product_tag_rule1) {
create(:filter_products_tag_rule, enterprise: enterprise, priority: 5,
- preferred_customer_tags: "tag1", preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "visible" )
+ preferred_customer_tags: "tag1",
+ preferred_variant_tags: "tag1",
+ preferred_matched_variants_visibility: "visible" )
}
let!(:product_tag_rule2) {
create(:filter_products_tag_rule, enterprise: enterprise, priority: 4,
- preferred_customer_tags: "tag1", preferred_variant_tags: "tag3", preferred_matched_variants_visibility: "hidden" )
+ preferred_customer_tags: "tag1",
+ preferred_variant_tags: "tag3",
+ preferred_matched_variants_visibility: "hidden" )
}
let!(:product_tag_rule3) {
create(:filter_products_tag_rule, enterprise: enterprise, priority: 3,
- preferred_customer_tags: "tag2", preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "visible" )
+ preferred_customer_tags: "tag2",
+ preferred_variant_tags: "tag1",
+ preferred_matched_variants_visibility: "visible" )
}
let!(:default_product_tag_rule) {
create(:filter_products_tag_rule, enterprise: enterprise, priority: 2, is_default: true,
- preferred_variant_tags: "tag1", preferred_matched_variants_visibility: "hidden" )
+ preferred_variant_tags: "tag1",
+ preferred_matched_variants_visibility: "hidden" )
}
let!(:sm_tag_rule) {
- create(:filter_shipping_methods_tag_rule, enterprise: enterprise, priority: 1,
- preferred_customer_tags: "tag1", preferred_shipping_method_tags: "tag1", preferred_matched_shipping_methods_visibility: "visible" )
+ create(
+ :filter_shipping_methods_tag_rule, enterprise: enterprise, priority: 1,
+ preferred_customer_tags: "tag1",
+ preferred_shipping_method_tags: "tag1",
+ preferred_matched_shipping_methods_visibility: "visible"
+ )
}
describe "initialisation" do
@@ -98,7 +111,8 @@ module OpenFoodNetwork
product_tag_rule1]
end
- it "splits rules into those which match customer tags and those which don't, in order of priority" do
+ it "splits rules into those which match customer tags " \
+ "and those which don't, in order of priority" do
expect(customer_rules).to eq [product_tag_rule2, product_tag_rule1]
end
@@ -247,7 +261,8 @@ module OpenFoodNetwork
}
let(:product2) {
{ :id => 2, :name => 'product 2',
- "variants" => [{ :id => 5, "tag_list" => ["tag1"] }, { :id => 9, "tag_list" => ["tag2"] }] }
+ "variants" => [{ :id => 5, "tag_list" => ["tag1"] },
+ { :id => 9, "tag_list" => ["tag2"] }] }
}
let(:product3) {
{ :id => 3, :name => 'product 3', "variants" => [{ :id => 6, "tag_list" => ["tag3"] }] }
diff --git a/spec/lib/reports/customers_report_spec.rb b/spec/lib/reports/customers_report_spec.rb
index e3861b4e32..425e101b96 100644
--- a/spec/lib/reports/customers_report_spec.rb
+++ b/spec/lib/reports/customers_report_spec.rb
@@ -63,8 +63,9 @@ module Reporting
subject { Addresses.new user, {} }
it "returns headers for addresses" do
- expect(subject.table_headers).to eq(["First Name", "Last Name", "Billing Address", "Email",
- "Phone", "Hub", "Hub Address", "Shipping Method"])
+ expect(subject.table_headers).to eq(["First Name", "Last Name", "Billing Address",
+ "Email", "Phone", "Hub", "Hub Address",
+ "Shipping Method"])
end
it "builds a table from a list of variants" do
@@ -78,7 +79,8 @@ module Reporting
a.firstname, a.lastname,
[a.address1, a.address2, a.city].join(" "),
o.email, a.phone, d.name,
- [d.address.address1, d.address.address2, d.address.city].join(" "),
+ [d.address.address1, d.address.address2,
+ d.address.city].join(" "),
o.shipping_method.name
]])
end
diff --git a/spec/lib/reports/order_cycle_management_report_spec.rb b/spec/lib/reports/order_cycle_management_report_spec.rb
index 4b92055748..62a18e600b 100644
--- a/spec/lib/reports/order_cycle_management_report_spec.rb
+++ b/spec/lib/reports/order_cycle_management_report_spec.rb
@@ -193,21 +193,23 @@ module Reporting
it 'returns rows with delivery information' do
allow(subject).to receive(:unformatted_render?).and_return(true)
- expect(subject.table_rows).to eq([[
- order.ship_address.firstname,
- order.ship_address.lastname,
- order.distributor.name,
- "",
- "#{order.ship_address.address1} #{order.ship_address.address2} #{order.ship_address.city}",
- order.ship_address.zipcode,
- order.ship_address.phone,
- order.shipment.shipping_method.name,
- nil,
- order.total,
- -order.total,
- false,
- order.special_instructions
- ]])
+ expect(subject.table_rows)
+ .to eq([[
+ order.ship_address.firstname,
+ order.ship_address.lastname,
+ order.distributor.name,
+ "",
+ "#{order.ship_address.address1} #{order.ship_address.address2} " \
+ "#{order.ship_address.city}",
+ order.ship_address.zipcode,
+ order.ship_address.phone,
+ order.shipment.shipping_method.name,
+ nil,
+ order.total,
+ -order.total,
+ false,
+ order.special_instructions
+ ]])
end
end
end
diff --git a/spec/lib/reports/products_and_inventory_report_spec.rb b/spec/lib/reports/products_and_inventory_report_spec.rb
index 193a46e7b8..7337a674bf 100644
--- a/spec/lib/reports/products_and_inventory_report_spec.rb
+++ b/spec/lib/reports/products_and_inventory_report_spec.rb
@@ -41,9 +41,8 @@ module Reporting
allow(variant).to receive_message_chain(:product, :supplier, :address,
:city).and_return("A city")
allow(variant).to receive_message_chain(:product, :name).and_return("Product Name")
- allow(variant).to receive_message_chain(:product,
- :properties).and_return [double(name: "property1"),
- double(name: "property2")]
+ allow(variant).to receive_message_chain(:product, :properties)
+ .and_return [double(name: "property1"), double(name: "property2")]
allow(variant).to receive_message_chain(:product,
:taxons).and_return [double(name: "taxon1"),
double(name: "taxon2")]
diff --git a/spec/lib/reports/users_and_enterprises_report_spec.rb b/spec/lib/reports/users_and_enterprises_report_spec.rb
index 0bcc77dc93..12c4f1bd05 100644
--- a/spec/lib/reports/users_and_enterprises_report_spec.rb
+++ b/spec/lib/reports/users_and_enterprises_report_spec.rb
@@ -19,7 +19,8 @@ module Reporting
it "should concatenate owner and manager queries" do
expect(subject).to receive(:owners_and_enterprises).once
expect(subject).to receive(:managers_and_enterprises).once
- expect(owners_and_enterprises).to receive(:concat).with(managers_and_enterprises).and_return []
+ expect(owners_and_enterprises).to receive(:concat)
+ .with(managers_and_enterprises).and_return []
expect(subject).to receive(:sort).with []
subject.query_result
end
diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb
index af305532a2..9a2d3c4066 100644
--- a/spec/mailers/order_mailer_spec.rb
+++ b/spec/mailers/order_mailer_spec.rb
@@ -163,7 +163,8 @@ describe Spree::OrderMailer do
create(:address, address1: "distributor address", city: 'The Shire', zipcode: "1234")
}
let(:order) {
- create(:order_with_line_items, distributor: distributor, bill_address: bill_address, ship_address: ship_address,
+ create(:order_with_line_items, distributor: distributor, bill_address: bill_address,
+ ship_address: ship_address,
special_instructions: shipping_instructions)
}
diff --git a/spec/mailers/producer_mailer_spec.rb b/spec/mailers/producer_mailer_spec.rb
index 84f0d430da..153b72aac4 100644
--- a/spec/mailers/producer_mailer_spec.rb
+++ b/spec/mailers/producer_mailer_spec.rb
@@ -168,8 +168,8 @@ describe ProducerMailer, type: :mailer do
create(:order, :with_line_item, distributor: d1, order_cycle: order_cycle, state: 'complete',
bill_address: FactoryBot.create(:address, last_name: "Abby"))
create(:order, :with_line_item, distributor: d1, order_cycle: order_cycle, state: 'complete',
- bill_address: FactoryBot.create(:address, last_name: "maggie"))
- expect(mail.body.encoded).to match(/.*Abby.*Doe.*maggie/m)
+ bill_address: FactoryBot.create(:address, last_name: "smith"))
+ expect(mail.body.encoded).to match(/.*Abby.*Doe.*smith/m)
end
end
diff --git a/spec/mailers/subscription_mailer_spec.rb b/spec/mailers/subscription_mailer_spec.rb
index 5ce3ad3720..967bececec 100644
--- a/spec/mailers/subscription_mailer_spec.rb
+++ b/spec/mailers/subscription_mailer_spec.rb
@@ -35,7 +35,8 @@ describe SubscriptionMailer, type: :mailer do
body = SubscriptionMailer.deliveries.last.body.encoded
expect(body).to include "This order was automatically created for you."
- expect(body).to_not include "Unfortunately, not all products that you requested were available."
+ expect(body).to_not include "Unfortunately, not all products " \
+ "that you requested were available."
end
end
@@ -54,7 +55,9 @@ describe SubscriptionMailer, type: :mailer do
it "provides link to make changes" do
expect(body).to match %r{make changes}
- expect(body).to_not match %r{view details of this order}
+ expect(body).to_not match %r{
+ view details of this order
+ }
end
context "when the distributor does not allow changes to the order" do
@@ -62,7 +65,8 @@ describe SubscriptionMailer, type: :mailer do
it "provides link to view details" do
expect(body).to_not match %r{make changes}
- expect(body).to match %r{view details of this order}
+ expect(body)
+ .to match %r{view details of this order}
end
end
end
@@ -203,9 +207,10 @@ describe SubscriptionMailer, type: :mailer do
it "sends the email" do
body = strip_tags(SubscriptionMailer.deliveries.last.body.encoded)
expect(body).to include 'We tried to process a payment, but had some problems...'
- email_so_failed_payment_explainer_html = "The payment for your subscription with %s \
-failed because of a problem with your credit card. %s has been notified \
-of this failed payment."
+ email_so_failed_payment_explainer_html = "The payment for your subscription with %s" \
+ " failed because of a problem with your " \
+ "credit card. %s has been " \
+ "notified of this failed payment."
explainer = email_so_failed_payment_explainer_html % ([subscription.shop.name] * 2)
expect(body).to include strip_tags(explainer)
details = 'Here are the details of the failure provided by the payment gateway:'
@@ -255,11 +260,14 @@ of this failed payment."
allow(summary).to receive(:issues) { {} }
end
- it "sends the email, which notifies the enterprise that all orders were successfully processed" do
+ it "sends the email, which notifies the enterprise that all orders " \
+ "were successfully processed" do
SubscriptionMailer.placement_summary_email(summary).deliver_now
- expect(body).to include("Below is a summary of the subscription orders that have just been placed for %s." % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 37)
+ expect(body).to include("Below is a summary of the subscription orders " \
+ "that have just been placed for %s." % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 37)
expect(body).to include 'All were processed successfully.'
expect(body).to_not include 'Details of the issues encountered are provided below.'
end
@@ -287,12 +295,15 @@ of this failed payment."
context "when no unrecorded issues are present" do
it "sends the email, which notifies the enterprise that some issues were encountered" do
SubscriptionMailer.placement_summary_email(summary).deliver_now
- expect(body).to include("Below is a summary of the subscription orders that have just been placed for %s." % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 37)
+ expect(body).to include("Below is a summary of the subscription orders " \
+ "that have just been placed for %s." % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 37)
expect(body).to include('Of these, %d were processed successfully.' % 35)
expect(body).to include 'Details of the issues encountered are provided below.'
expect(body).to include('Error Encountered (%d orders)' % 2)
- expect(body).to include 'Automatic processing of these orders failed due to an error. The error has been listed where possible.'
+ expect(body).to include 'Automatic processing of these orders failed due to an error. ' \
+ 'The error has been listed where possible.'
# Lists orders for which an error was encountered
expect(body).to include order1.number
@@ -316,9 +327,12 @@ of this failed payment."
expect(summary).to receive(:orders_affected_by).with(:other) { [order3, order4] }
SubscriptionMailer.placement_summary_email(summary).deliver_now
expect(body).to include("Error Encountered (%d orders)" % 2)
- expect(body).to include 'Automatic processing of these orders failed due to an error. The error has been listed where possible.'
+ expect(body).to include 'Automatic processing of these orders failed due to an error. ' \
+ 'The error has been listed where possible.'
expect(body).to include("Other Failure (%d orders)" % 2)
- expect(body).to include 'Automatic processing of these orders failed for an unknown reason. This should not occur, please contact us if you are seeing this.'
+ expect(body).to include 'Automatic processing of these orders failed ' \
+ 'for an unknown reason. This should not occur, ' \
+ 'please contact us if you are seeing this.'
# Lists orders for which no error or success was recorded
expect(body).to include order3.number
@@ -341,12 +355,15 @@ of this failed payment."
end
it "sends the email, which notifies the enterprise that some issues were encountered" do
- expect(body).to include("Below is a summary of the subscription orders that have just been placed for %s" % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 2)
+ expect(body).to include("Below is a summary of the subscription orders " \
+ "that have just been placed for %s" % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 2)
expect(body).to include 'Of these, none were processed successfully.'
expect(body).to include 'Details of the issues encountered are provided below.'
expect(body).to include("Insufficient Stock (%d orders)" % 2)
- expect(body).to include 'These orders were processed but insufficient stock was available for some requested items'
+ expect(body).to include 'These orders were processed but insufficient stock ' \
+ 'was available for some requested items'
# Lists orders for which an error was encountered
expect(body).to include order1.number
@@ -377,9 +394,12 @@ of this failed payment."
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
end
- it "sends the email, which notifies the enterprise that all orders were successfully processed" do
- expect(body).to include("Below is a summary of the subscription orders that have just been finalised for %s." % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 37)
+ it "sends the email, which notifies the enterprise " \
+ "that all orders were successfully processed" do
+ expect(body).to include("Below is a summary of the subscription orders " \
+ "that have just been finalised for %s." % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 37)
expect(body).to include 'All were processed successfully.'
expect(body).to_not include 'Details of the issues encountered are provided below.'
end
@@ -402,12 +422,15 @@ of this failed payment."
context "when no unrecorded issues are present" do
it "sends the email, which notifies the enterprise that some issues were encountered" do
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
- expect(body).to include("Below is a summary of the subscription orders that have just been finalised for %s." % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 37)
+ expect(body).to include("Below is a summary of the subscription orders " \
+ "that have just been finalised for %s." % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 37)
expect(body).to include("Of these, %d were processed successfully." % 35)
expect(body).to include 'Details of the issues encountered are provided below.'
expect(body).to include("Failed Payment (%d orders)" % 2)
- expect(body).to include 'Automatic processing of payment for these orders failed due to an error. The error has been listed where possible.'
+ expect(body).to include 'Automatic processing of payment for these orders failed ' \
+ 'due to an error. The error has been listed where possible.'
# Lists orders for which an error was encountered
expect(body).to include order1.number
@@ -431,9 +454,12 @@ of this failed payment."
expect(summary).to receive(:orders_affected_by).with(:other) { [order3, order4] }
SubscriptionMailer.confirmation_summary_email(summary).deliver_now
expect(body).to include("Failed Payment (%d orders)" % 2)
- expect(body).to include 'Automatic processing of payment for these orders failed due to an error. The error has been listed where possible.'
+ expect(body).to include 'Automatic processing of payment for these orders failed ' \
+ 'due to an error. The error has been listed where possible.'
expect(body).to include("Other Failure (%d orders)" % 2)
- expect(body).to include 'Automatic processing of these orders failed for an unknown reason. This should not occur, please contact us if you are seeing this.'
+ expect(body).to include 'Automatic processing of these orders failed ' \
+ 'for an unknown reason. This should not occur, ' \
+ 'please contact us if you are seeing this.'
# Lists orders for which no error or success was recorded
expect(body).to include order3.number
@@ -456,12 +482,15 @@ of this failed payment."
end
it "sends the email, which notifies the enterprise that some issues were encountered" do
- expect(body).to include("Below is a summary of the subscription orders that have just been finalised for %s." % shop.name)
- expect(body).to include("A total of %d subscriptions were marked for automatic processing." % 2)
+ expect(body).to include("Below is a summary of the subscription orders that " \
+ "have just been finalised for %s." % shop.name)
+ expect(body).to include("A total of %d subscriptions were marked " \
+ "for automatic processing." % 2)
expect(body).to include 'Of these, none were processed successfully.'
expect(body).to include 'Details of the issues encountered are provided below.'
expect(body).to include("Insufficient Stock (%d orders)" % 2)
- expect(body).to include 'These orders were processed but insufficient stock was available for some requested items'
+ expect(body).to include 'These orders were processed but insufficient stock ' \
+ 'was available for some requested items'
# Lists orders for which an error was encountered
expect(body).to include order1.number
diff --git a/spec/models/concerns/calculated_adjustments_spec.rb b/spec/models/concerns/calculated_adjustments_spec.rb
index b024c679e4..0c54d9be02 100644
--- a/spec/models/concerns/calculated_adjustments_spec.rb
+++ b/spec/models/concerns/calculated_adjustments_spec.rb
@@ -33,7 +33,8 @@ describe CalculatedAdjustments do
expect(target.adjustments.first.order_id).to eq order.id
end
- it "should have the correct originator and an amount derived from the calculator and supplied calculable" do
+ it "should have the correct originator and an amount derived " \
+ "from the calculator and supplied calculable" do
adjustment = tax_rate.create_adjustment("foo", target)
expect(adjustment).not_to be_nil
expect(adjustment.amount).to eq 10
diff --git a/spec/models/concerns/order_shipment_spec.rb b/spec/models/concerns/order_shipment_spec.rb
index 2b1aa320d5..c69e54b4a0 100644
--- a/spec/models/concerns/order_shipment_spec.rb
+++ b/spec/models/concerns/order_shipment_spec.rb
@@ -43,7 +43,8 @@ describe OrderShipment do
it "returns nil for empty shipping_method_id" do
empty_shipping_method_id = ' '
- expect(shipment.shipping_rates).to_not receive(:find_by).with(shipping_method_id: empty_shipping_method_id)
+ expect(shipment.shipping_rates).to_not receive(:find_by)
+ .with(shipping_method_id: empty_shipping_method_id)
expect(order.select_shipping_method(empty_shipping_method_id)).to be_nil
end
@@ -52,9 +53,8 @@ describe OrderShipment do
context "when shipping_method_id is not valid for the order" do
it "returns nil" do
invalid_shipping_method_id = order.shipment.shipping_method.id + 1000
- expect(shipment.shipping_rates).to receive(:find_by).with(shipping_method_id: invalid_shipping_method_id) {
- nil
- }
+ expect(shipment.shipping_rates).to receive(:find_by)
+ .with(shipping_method_id: invalid_shipping_method_id) { nil }
expect(order.select_shipping_method(invalid_shipping_method_id)).to be_nil
end
@@ -72,10 +72,12 @@ describe OrderShipment do
let(:expensive_shipping_method) { create(:shipping_method_with, :expensive_name) }
before { shipment.add_shipping_method(expensive_shipping_method, false ) }
- it "selects a shipping method that was not selected by default and persists the selection in the database" do
+ it "selects a shipping method that was not selected by default " \
+ "and persists the selection in the database" do
expect(shipment.shipping_method).to eq shipping_method
- expect(order.select_shipping_method(expensive_shipping_method.id)).to eq expensive_shipping_method
+ expect(order.select_shipping_method(expensive_shipping_method.id))
+ .to eq expensive_shipping_method
expect(shipment.shipping_method).to eq expensive_shipping_method
diff --git a/spec/models/concerns/product_stock_spec.rb b/spec/models/concerns/product_stock_spec.rb
index 7d2dff11d5..c8ce00dc28 100644
--- a/spec/models/concerns/product_stock_spec.rb
+++ b/spec/models/concerns/product_stock_spec.rb
@@ -33,7 +33,8 @@ describe ProductStock do
describe "product.on_hand" do
it "is the sum of the products variants on_hand values" do
- expect(product.on_hand).to eq(product.variants.first.on_hand + product.variants.second.on_hand)
+ expect(product.on_hand)
+ .to eq(product.variants.first.on_hand + product.variants.second.on_hand)
end
end
end
diff --git a/spec/models/enterprise_relationship_spec.rb b/spec/models/enterprise_relationship_spec.rb
index 38d8196ff9..644c051062 100644
--- a/spec/models/enterprise_relationship_spec.rb
+++ b/spec/models/enterprise_relationship_spec.rb
@@ -155,29 +155,47 @@ describe EnterpriseRelationship do
context "when variant_override permission is present" do
let!(:er) {
create(:enterprise_relationship, child: hub, parent: producer,
- permissions_list: [:add_to_order_cycles, :create_variant_overrides] )
+ permissions_list: [:add_to_order_cycles,
+ :create_variant_overrides] )
}
let!(:some_other_er) {
create(:enterprise_relationship, child: hub, parent: some_other_producer,
- permissions_list: [:add_to_order_cycles, :create_variant_overrides] )
+ permissions_list: [:add_to_order_cycles,
+ :create_variant_overrides] )
}
let!(:vo1) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: producer)))
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: producer
+ )
+ ))
}
let!(:vo2) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: producer)))
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: producer
+ )
+ ))
}
let!(:vo3) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: some_other_producer)))
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: some_other_producer
+ )
+ ))
}
context "revoking variant override permissions" do
context "when the enterprise relationship is destroyed" do
before { er.destroy }
- it "should set permission_revoked_at to the current time for all variant overrides of the relationship" do
+ it "should set permission_revoked_at to the current time " \
+ "for all variant overrides of the relationship" do
expect(vo1.reload.permission_revoked_at).to_not be_nil
expect(vo2.reload.permission_revoked_at).to_not be_nil
expect(vo2.reload.permission_revoked_at).to_not be_nil
@@ -187,7 +205,8 @@ describe EnterpriseRelationship do
context "and is then removed" do
before { er.permissions_list = [:add_to_order_cycles]; er.save! }
- it "should set permission_revoked_at to the current time for all relevant variant overrides" do
+ it "should set permission_revoked_at to the current time " \
+ "for all relevant variant overrides" do
expect(vo1.reload.permission_revoked_at).to_not be_nil
expect(vo2.reload.permission_revoked_at).to_not be_nil
end
@@ -219,15 +238,33 @@ describe EnterpriseRelationship do
}
let!(:vo1) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: producer)), permission_revoked_at: Time.now.in_time_zone)
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: producer
+ )
+ ),
+ permission_revoked_at: Time.now.in_time_zone)
}
let!(:vo2) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: producer)), permission_revoked_at: Time.now.in_time_zone)
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: producer
+ )
+ ),
+ permission_revoked_at: Time.now.in_time_zone)
}
let!(:vo3) {
create(:variant_override, hub: hub,
- variant: create(:variant, product: create(:product, supplier: some_other_producer)), permission_revoked_at: Time.now.in_time_zone)
+ variant: create(
+ :variant,
+ product: create(
+ :product, supplier: some_other_producer
+ )
+ ),
+ permission_revoked_at: Time.now.in_time_zone)
}
context "and is then added" do
diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb
index 3aaf3ca6a4..fbe15221d5 100644
--- a/spec/models/enterprise_spec.rb
+++ b/spec/models/enterprise_spec.rb
@@ -112,7 +112,8 @@ describe Enterprise do
e2.owner = u1
e2.save!
}.to raise_error ActiveRecord::RecordInvalid,
- "Validation failed: #{u1.email} is not permitted to own any more enterprises (limit is 5)."
+ "Validation failed: #{u1.email} is not permitted " \
+ "to own any more enterprises (limit is 5)."
end
end
end
@@ -496,7 +497,8 @@ describe Enterprise do
d = create(:distributor_enterprise)
p = create(:product)
create(:simple_order_cycle, orders_open_at: 10.days.from_now,
- orders_close_at: 17.days.from_now, suppliers: [s], distributors: [d], variants: [p.variants.first])
+ orders_close_at: 17.days.from_now, suppliers: [s],
+ distributors: [d], variants: [p.variants.first])
expect(Enterprise.distributors_with_active_order_cycles).not_to include d
end
end
@@ -541,7 +543,8 @@ describe Enterprise do
it "does not return duplicate enterprises" do
another_product = create(:product)
order_cycle = create(:simple_order_cycle, distributors: [distributor],
- variants: [product.variants.first, another_product.variants.first])
+ variants: [product.variants.first,
+ another_product.variants.first])
expect(Enterprise.distributing_products([product.id,
another_product.id])).to eq([distributor])
end
@@ -588,7 +591,8 @@ describe Enterprise do
hub2
end
- it "creates links from the new producer to all hubs owned by the same user, granting add_to_order_cycle and create_variant_overrides permissions" do
+ it "creates links from the new producer to all hubs owned by the same user, " \
+ "granting add_to_order_cycle and create_variant_overrides permissions" do
producer1
should_have_enterprise_relationship from: producer1, to: hub1,
@@ -605,7 +609,8 @@ describe Enterprise do
end
describe "when a new hub is created" do
- it "it creates links to the hub, from all producers owned by the same user, granting add_to_order_cycle and create_variant_overrides permissions" do
+ it "it creates links to the hub, from all producers owned by the same user, " \
+ "granting add_to_order_cycle and create_variant_overrides permissions" do
producer1
producer2
hub1
@@ -616,7 +621,8 @@ describe Enterprise do
with: [:add_to_order_cycle, :create_variant_overrides]
end
- it "creates links from the new hub to all hubs owned by the same user, granting add_to_order_cycle permission" do
+ it "creates links from the new hub to all hubs owned by the same user, " \
+ "granting add_to_order_cycle permission" do
hub1
hub2
hub3
@@ -644,7 +650,8 @@ describe Enterprise do
expect(er).not_to be_nil
if opts[:with] == :all_permissions
expect(er.permissions.map(&:name)).to match_array ['add_to_order_cycle',
- 'manage_products', 'edit_profile', 'create_variant_overrides']
+ 'manage_products', 'edit_profile',
+ 'create_variant_overrides']
elsif opts.key? :with
expect(er.permissions.map(&:name)).to match_array opts[:with].map(&:to_s)
end
@@ -774,7 +781,8 @@ describe Enterprise do
let!(:enterprise2) { create(:enterprise, permalink: "permalink1") }
it "parameterizes the value provided" do
- expect(Enterprise.find_available_permalink("Some Unused Permalink")).to eq "some-unused-permalink"
+ expect(Enterprise.find_available_permalink("Some Unused Permalink"))
+ .to eq "some-unused-permalink"
end
it "sets the permalink to 'my-enterprise' if parametized permalink is blank" do
diff --git a/spec/models/exchange_spec.rb b/spec/models/exchange_spec.rb
index 7fa4f8974a..62b7af1693 100644
--- a/spec/models/exchange_spec.rb
+++ b/spec/models/exchange_spec.rb
@@ -15,11 +15,12 @@ describe Exchange do
end
end
- it "should not be valid when (sender, receiver, direction) set are not unique for its order cycle" do
+ it "shouldn't be valid when (sender, receiver, direction) set aren't unique for its OC" do
e1 = create(:exchange)
e2 = build(:exchange,
- order_cycle: e1.order_cycle, sender: e1.sender, receiver: e1.receiver, incoming: e1.incoming)
+ order_cycle: e1.order_cycle, sender: e1.sender, receiver: e1.receiver,
+ incoming: e1.incoming)
expect(e2).not_to be_valid
e2.incoming = !e2.incoming
diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb
index 574c1e090c..fd90ad7c32 100644
--- a/spec/models/order_cycle_spec.rb
+++ b/spec/models/order_cycle_spec.rb
@@ -276,7 +276,8 @@ describe OrderCycle do
@e0 = create(:exchange, order_cycle: @oc, sender: create(:enterprise),
receiver: @oc.coordinator, incoming: true)
@e1 = create(:exchange, order_cycle: @oc, sender: @oc.coordinator, receiver: @d1,
- incoming: false, pickup_time: '5pm Tuesday', pickup_instructions: "Come get it!")
+ incoming: false, pickup_time: '5pm Tuesday',
+ pickup_instructions: "Come get it!")
@e2 = create(:exchange, order_cycle: @oc, sender: @oc.coordinator, receiver: @d2,
incoming: false, pickup_time: nil)
end
@@ -384,7 +385,8 @@ describe OrderCycle do
it "should give the soonest opening order cycle for a distributor" do
distributor = create(:distributor_enterprise)
oc = create(:simple_order_cycle, name: 'oc 1', distributors: [distributor],
- orders_open_at: 10.days.from_now, orders_close_at: 11.days.from_now)
+ orders_open_at: 10.days.from_now,
+ orders_close_at: 11.days.from_now)
expect(OrderCycle.first_opening_for(distributor)).to eq(oc)
end
@@ -398,9 +400,11 @@ describe OrderCycle do
it "should give the soonest closing order cycle for a distributor" do
distributor = create(:distributor_enterprise)
oc = create(:simple_order_cycle, name: 'oc 1', distributors: [distributor],
- orders_open_at: 1.day.ago, orders_close_at: 11.days.from_now)
+ orders_open_at: 1.day.ago,
+ orders_close_at: 11.days.from_now)
oc2 = create(:simple_order_cycle, name: 'oc 2', distributors: [distributor],
- orders_open_at: 2.days.ago, orders_close_at: 12.days.from_now)
+ orders_open_at: 2.days.ago,
+ orders_close_at: 12.days.from_now)
expect(OrderCycle.first_closing_for(distributor)).to eq(oc)
end
end
diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb
index 8d83fd57e9..98fe95bad5 100644
--- a/spec/models/product_importer_spec.rb
+++ b/spec/models/product_importer_spec.rb
@@ -52,33 +52,39 @@ describe ProductImport::ProductImporter do
primary_taxon_id: category.id, description: nil)
}
let!(:product3) {
- create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Sprouts', unit_value: '500',
- primary_taxon_id: category.id)
+ create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Sprouts',
+ unit_value: '500', primary_taxon_id: category.id)
}
let!(:product4) {
create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Cabbage', unit_value: '1',
- variant_unit_scale: nil, variant_unit: "items", variant_unit_name: "Whole", primary_taxon_id: category.id)
+ variant_unit_scale: nil, variant_unit: "items",
+ variant_unit_name: "Whole", primary_taxon_id: category.id)
}
let!(:product5) {
- create(:simple_product, supplier: enterprise2, on_hand: '100', name: 'Lettuce', unit_value: '500',
- primary_taxon_id: category.id)
+ create(:simple_product, supplier: enterprise2, on_hand: '100', name: 'Lettuce',
+ unit_value: '500', primary_taxon_id: category.id)
}
let!(:product6) {
create(:simple_product, supplier: enterprise3, on_hand: '100', name: 'Beetroot',
- unit_value: '500', on_demand: true, variant_unit_scale: 1, variant_unit: 'weight', primary_taxon_id: category.id, description: nil)
+ unit_value: '500', on_demand: true, variant_unit_scale: 1,
+ variant_unit: 'weight', primary_taxon_id: category.id, description: nil)
}
let!(:product7) {
- create(:simple_product, supplier: enterprise3, on_hand: '100', name: 'Tomato', unit_value: '500',
- variant_unit_scale: 1, variant_unit: 'weight', primary_taxon_id: category.id, description: nil)
+ create(:simple_product, supplier: enterprise3, on_hand: '100', name: 'Tomato',
+ unit_value: '500', variant_unit_scale: 1,
+ variant_unit: 'weight', primary_taxon_id: category.id,
+ description: nil)
}
let!(:product8) {
create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Oats', description: "",
- unit_value: '500', variant_unit_scale: 1, variant_unit: 'weight', primary_taxon_id: category4.id)
+ unit_value: '500', variant_unit_scale: 1, variant_unit: 'weight',
+ primary_taxon_id: category4.id)
}
let!(:product9) {
create(:simple_product, supplier: enterprise, on_hand: '100', name: 'Oats', description: "",
- unit_value: '500', variant_unit_scale: 1, variant_unit: 'weight', primary_taxon_id: category4.id)
+ unit_value: '500', variant_unit_scale: 1, variant_unit: 'weight',
+ primary_taxon_id: category4.id)
}
let!(:variant2) {
create(:variant, product_id: product8.id, price: '4.50', on_hand: '100', unit_value: '500',
@@ -244,11 +250,13 @@ describe ProductImport::ProductImporter do
let(:csv_data) {
csv = "name,producer,category,on_hand,price,units,unit_type,shipping_category\n"
csv += "Good Carrots,#{enterprise.name},Vegetables,5,3.20,500,g,#{shipping_category.name}\n"
- csv += "Malformed \rBrocolli,#{enterprise.name},Vegetables,8,2.50,200,g,#{shipping_category.name}\n"
+ csv += "Malformed \rBrocolli,#{enterprise.name},
+ Vegetables,8,2.50,200,g,#{shipping_category.name}\n"
}
let(:importer) { import_data csv_data }
- # an unquoted \n will create a non valid line which will fail entry validation hence why we are only testing with \r
+ # an unquoted \n will create a non valid line which will fail entry validation
+ # hence why we are only testing with \r
it "should raise an unquoted field error if data include unquoted field with \r character" do
expect(importer.errors.messages.values).to include(
[format("Product Import encountered a malformed CSV: %s",
@@ -542,22 +550,22 @@ describe ProductImport::ProductImporter do
expect(filter('invalid', entries)).to eq 2
importer.entries.each do |entry|
- expect(entry.errors.messages.values).to include ['cannot be updated on existing products via product import']
+ expect(entry.errors.messages.values)
+ .to include ['cannot be updated on existing products via product import']
end
end
end
- describe "when more than one product of the same name already exists with multiple variants each" do
+ describe "when more than one product of same name already exists with multiple variants each" do
let(:csv_data) {
- CSV.generate do |csv|
- csv << ["name", "producer", "category", "description", "on_hand", "price", "units",
- "unit_type", "display_name", "shipping_category"]
- csv << ["Oats", enterprise.name, "Cereal", "", "50", "3.50", "500", "g", "Rolled Oats", shipping_category.name] # Update
- csv << ["Oats", enterprise.name, "Cereal", "", "80", "3.75", "500", "g", "Flaked Oats", shipping_category.name] # Update
- csv << ["Oats", enterprise.name, "Cereal", "", "60", "5.50", "500", "g", "Magic Oats", shipping_category.name] # Add
- csv << ["Oats", enterprise.name, "Cereal", "", "70", "8.50", "500", "g", "French Oats", shipping_category.name] # Add
- csv << ["Oats", enterprise.name, "Cereal", "", "70", "8.50", "500", "g", "Scottish Oats", shipping_category.name] # Add
- end
+ <<~CSV
+ name,producer,category,description,on_hand,price,units,unit_type,display_name,shipping_category
+ Oats,#{enterprise.name},Cereal,,50,3.50,500,g,Rolled Oats,#{shipping_category.name}
+ Oats,#{enterprise.name},Cereal,,80,3.75,500,g,Flaked Oats,#{shipping_category.name}
+ Oats,#{enterprise.name},Cereal,,60,5.50,500,g,Magic Oats,#{shipping_category.name}
+ Oats,#{enterprise.name},Cereal,,70,8.50,500,g,French Oats,#{shipping_category.name}
+ Oats,#{enterprise.name},Cereal,,70,8.50,500,g,Scottish Oats,#{shipping_category.name}
+ CSV
}
let(:importer) { import_data csv_data }
@@ -589,11 +597,26 @@ describe ProductImport::ProductImporter do
CSV.generate do |csv|
csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type",
"display_name", "shipping_category"]
- csv << ["Bag of Oats", enterprise.name, "Cereal", "60", "5.50", "500", "g", "Magic Oats", shipping_category.name] # Add
- csv << ["Bag of Oats", enterprise.name, "Cereal", "70", "8.50", "500", "g", "French Oats", shipping_category.name] # Add
- csv << ["Bag of Oats", enterprise.name, "Cereal", "80", "9.50", "500", "g", "Organic Oats", shipping_category.name] # Add
- csv << ["Bag of Oats", enterprise.name, "Cereal", "90", "7.50", "500", "g", "Scottish Oats", shipping_category.name] # Add
- csv << ["Bag of Oats", enterprise.name, "Cereal", "30", "6.50", "500", "g", "Breakfast Oats", shipping_category.name] # Add
+ csv << [
+ "Bag of Oats", enterprise.name, "Cereal", "60", "5.50",
+ "500", "g", "Magic Oats", shipping_category.name
+ ] # Add
+ csv << [
+ "Bag of Oats", enterprise.name, "Cereal", "70", "8.50",
+ "500", "g", "French Oats", shipping_category.name
+ ] # Add
+ csv << [
+ "Bag of Oats", enterprise.name, "Cereal", "80", "9.50",
+ "500", "g", "Organic Oats", shipping_category.name
+ ] # Add
+ csv << [
+ "Bag of Oats", enterprise.name, "Cereal", "90", "7.50",
+ "500", "g", "Scottish Oats", shipping_category.name
+ ] # Add
+ csv << [
+ "Bag of Oats", enterprise.name, "Cereal", "30", "6.50",
+ "500", "g", "Breakfast Oats", shipping_category.name
+ ] # Add
end
}
@@ -831,7 +854,8 @@ describe ProductImport::ProductImporter do
expect(beans.count_on_hand).to eq 777
end
- it "does not allow creating inventories for producers that a user's hubs don't have permission for" do
+ it "does not allow creating inventories for producers " \
+ "that a user's hubs don't have permission for" do
csv_data = CSV.generate do |csv|
csv << ["name", "producer", "on_hand", "price", "units", "unit_type"]
csv << ["Beans", enterprise.name, "5", "3.20", "500", "g"]
@@ -855,7 +879,8 @@ describe ProductImport::ProductImporter do
end
describe "applying settings and defaults on import" do
- it "can reset all products for an enterprise that are not present in the uploaded file to zero stock" do
+ it "can reset all products for an enterprise that are not present " \
+ "in the uploaded file to zero stock" do
csv_data = CSV.generate do |csv|
csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type",
"shipping_category"]
@@ -891,12 +916,14 @@ describe ProductImport::ProductImporter do
expect(Spree::Product.find_by(name: 'Carrots').on_hand).to eq 5 # Present in file, added
expect(Spree::Product.find_by(name: 'Beans').on_hand).to eq 6 # Present in file, updated
- expect(Spree::Product.find_by(name: 'Sprouts').on_hand).to eq 0 # In enterprise, not in file
- expect(Spree::Product.find_by(name: 'Cabbage').on_hand).to eq 0 # In enterprise, not in file
- expect(Spree::Product.find_by(name: 'Lettuce').on_hand).to eq 100 # In different enterprise; unchanged
+ expect(Spree::Product.find_by(name: 'Sprouts').on_hand).to eq 0 # In enterprise, not file
+ expect(Spree::Product.find_by(name: 'Cabbage').on_hand).to eq 0 # In enterprise, not file
+ expect(Spree::Product.find_by(name: 'Lettuce').on_hand)
+ .to eq 100 # In different enterprise; unchanged
end
- it "can reset all inventory items for an enterprise that are not present in the uploaded file to zero stock" do
+ it "can reset all inventory items for an enterprise that are not present " \
+ "in the uploaded file to zero stock" do
csv_data = CSV.generate do |csv|
csv << ["name", "distributor", "producer", "on_hand", "price", "units", "unit_type"]
csv << ["Beans", enterprise2.name, enterprise.name, "6", "3.20", "500", "g"]
@@ -920,7 +947,8 @@ describe ProductImport::ProductImporter do
updated_ids = importer.updated_ids
importer = import_data csv_data, import_into: 'inventories', reset_all_absent: true,
- updated_ids: updated_ids, enterprises_to_reset: [enterprise2.id]
+ updated_ids: updated_ids,
+ enterprises_to_reset: [enterprise2.id]
importer.reset_absent(updated_ids)
beans = VariantOverride.where(variant_id: product2.variants.first.id,
diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb
index cc0dc1aa59..379329812d 100644
--- a/spec/models/spree/ability_spec.rb
+++ b/spec/models/spree/ability_spec.rb
@@ -341,7 +341,8 @@ describe Spree::Ability do
)
end
- it "should be able to read/write related enterprises' products and variants with manage_products permission" do
+ it "should be able to read/write related enterprises' products " \
+ "and variants with manage_products permission" do
er_ps
is_expected.to have_ability([:admin, :read, :update, :bulk_update, :clone, :destroy],
for: p_related)
@@ -415,7 +416,7 @@ describe Spree::Ability do
is_expected.to have_ability(:destroy, for: er1)
end
- it "should be able to destroy enterprise relationships for other enterprises that are linked as child" do
+ it "should be able to destroy enterprise relationships for other child-linked enterprises" do
is_expected.to have_ability(:destroy, for: er2)
end
@@ -471,8 +472,8 @@ describe Spree::Ability do
context "where the enterprise is in an order_cycle" do
let!(:order_cycle) { create(:simple_order_cycle) }
let!(:exchange){
- create(:exchange, incoming: true, order_cycle: order_cycle, receiver: order_cycle.coordinator,
- sender: s1)
+ create(:exchange, incoming: true, order_cycle: order_cycle,
+ receiver: order_cycle.coordinator, sender: s1)
}
it "should be able to access read/update order cycle actions" do
@@ -539,13 +540,15 @@ describe Spree::Ability do
)
end
- it "should be able to manage shipping methods, payment methods and enterprise fees for enterprises it manages" do
+ it "should be able to manage shipping methods, payment methods and enterprise fees " \
+ "for enterprises it manages" do
is_expected.to have_ability(
[:manage_shipping_methods, :manage_payment_methods, :manage_enterprise_fees], for: d1
)
end
- it "should not be able to manage shipping methods, payment methods and enterprise fees for enterprises it has edit profile permission to" do
+ it "should not be able to manage shipping methods, payment methods and enterprise fees " \
+ "for enterprises it has edit profile permission to" do
is_expected.not_to have_ability(
[:manage_shipping_methods, :manage_payment_methods,
:manage_enterprise_fees], for: d_related
@@ -573,11 +576,12 @@ describe Spree::Ability do
is_expected.to have_ability([:admin, :index, :read, :update], for: vo1)
end
- it "should not be able to read/write variant overrides when producer of product hasn't granted permission" do
+ it "should not be able to read/write variant overrides " \
+ "when producer of product hasn't granted permission" do
is_expected.not_to have_ability([:admin, :index, :read, :update], for: vo2)
end
- it "should not be able to read/write variant overrides when we can't add hub to order cycle" do
+ it "shouldn't be able to read/write variant overrides when we can't add hub to OC" do
is_expected.not_to have_ability([:admin, :index, :read, :update], for: vo3)
end
@@ -648,7 +652,7 @@ describe Spree::Ability do
is_expected.to have_ability(:destroy, for: er2)
end
- it "should be able to destroy enterprise relationships for other enterprises that are linked as child" do
+ it "should be able to destroy enterprise relationships for other child-linked enterprises" do
is_expected.to have_ability(:destroy, for: er1)
end
@@ -854,7 +858,7 @@ describe Spree::Ability do
end
end
- describe "when owner of the enterprise with create_variant_overrides permission to the producer" do
+ describe "when owner of enterprise with create_variant_overrides permission to the producer" do
let!(:authorized_enterprise) do
create(:enterprise, sells: "any").tap do |record|
create(:enterprise_relationship, parent: producer, child: record,
diff --git a/spec/models/spree/address_spec.rb b/spec/models/spree/address_spec.rb
index a19eba80f6..84276a0adc 100644
--- a/spec/models/spree/address_spec.rb
+++ b/spec/models/spree/address_spec.rb
@@ -4,7 +4,8 @@ require 'spec_helper'
describe Spree::Address do
describe "clone" do
- it "creates a copy of the address with the exception of the id, updated_at and created_at attributes" do
+ it "creates a copy of the address with the exception of the id, " \
+ "updated_at and created_at attributes" do
state = build_stubbed(:state)
original = build_stubbed(:address,
address1: 'address1',
diff --git a/spec/models/spree/classification_spec.rb b/spec/models/spree/classification_spec.rb
index 6a35477f12..2724e9d7d6 100644
--- a/spec/models/spree/classification_spec.rb
+++ b/spec/models/spree/classification_spec.rb
@@ -12,7 +12,10 @@ module Spree
product.update(primary_taxon: taxon)
expect(classification.destroy).to be false
- expect(classification.errors.messages[:base]).to eq(["Taxon #{taxon.name} is the primary taxon of #{product.name} and cannot be deleted"])
+ expect(classification.errors.messages[:base])
+ .to eq(
+ ["Taxon #{taxon.name} is the primary taxon of #{product.name} and cannot be deleted"]
+ )
expect(classification.reload).to be
end
end
diff --git a/spec/models/spree/inventory_unit_spec.rb b/spec/models/spree/inventory_unit_spec.rb
index e83056c264..7a77bba476 100644
--- a/spec/models/spree/inventory_unit_spec.rb
+++ b/spec/models/spree/inventory_unit_spec.rb
@@ -32,7 +32,8 @@ describe Spree::InventoryUnit do
expect { units.first.save! }.to_not raise_error
end
- it "finds inventory units from its stock location when the unit's variant matches the stock item's variant" do
+ it "finds inventory units from its stock location " \
+ "when the unit's variant matches the stock item's variant" do
expect(Spree::InventoryUnit.backordered_for_stock_item(stock_item)).to eq [unit]
end
@@ -42,7 +43,8 @@ describe Spree::InventoryUnit do
other_variant_unit.variant = create(:variant)
other_variant_unit.save!
- expect(Spree::InventoryUnit.backordered_for_stock_item(stock_item)).to_not include(other_variant_unit)
+ expect(Spree::InventoryUnit.backordered_for_stock_item(stock_item))
+ .to_not include(other_variant_unit)
end
end
diff --git a/spec/models/spree/order/checkout_spec.rb b/spec/models/spree/order/checkout_spec.rb
index 02847257ea..8ed666961d 100644
--- a/spec/models/spree/order/checkout_spec.rb
+++ b/spec/models/spree/order/checkout_spec.rb
@@ -35,8 +35,9 @@ describe Spree::Order::Checkout do
it "cannot transition to address without any line items" do
expect(order.line_items).to be_blank
- expect(lambda { order.next! }).to raise_error(StateMachines::InvalidTransition,
- /#{Spree.t(:there_are_no_items_for_this_order)}/)
+ expect(lambda { order.next! })
+ .to raise_error(StateMachines::InvalidTransition,
+ /#{Spree.t(:there_are_no_items_for_this_order)}/)
end
context "from address" do
diff --git a/spec/models/spree/order_inventory_spec.rb b/spec/models/spree/order_inventory_spec.rb
index bc8a035d53..b363fa62bb 100644
--- a/spec/models/spree/order_inventory_spec.rb
+++ b/spec/models/spree/order_inventory_spec.rb
@@ -111,11 +111,17 @@ describe Spree::OrderInventory do
end
it 'should destroy backordered units first' do
- allow(shipment).to receive_messages(inventory_units_for: [build(:inventory_unit, variant_id: variant.id, state: 'backordered'),
- build(:inventory_unit,
- variant_id: variant.id, state: 'on_hand'),
- build(:inventory_unit,
- variant_id: variant.id, state: 'backordered')])
+ allow(shipment).to receive_messages(inventory_units_for: [
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'backordered'),
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'on_hand'),
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'backordered')
+ ] )
expect(shipment.inventory_units_for[0]).to receive(:destroy)
expect(shipment.inventory_units_for[1]).not_to receive(:destroy)
@@ -125,9 +131,14 @@ describe Spree::OrderInventory do
end
it 'should destroy unshipped units first' do
- allow(shipment).to receive_messages(inventory_units_for: [build(:inventory_unit, variant_id: variant.id, state: 'shipped'),
- build(:inventory_unit,
- variant_id: variant.id, state: 'on_hand')] )
+ allow(shipment).to receive_messages(inventory_units_for: [
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'shipped'),
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'on_hand')
+ ] )
expect(shipment.inventory_units_for[0]).not_to receive(:destroy)
expect(shipment.inventory_units_for[1]).to receive(:destroy)
@@ -136,9 +147,14 @@ describe Spree::OrderInventory do
end
it 'only attempts to destroy as many units as are eligible, and return amount destroyed' do
- allow(shipment).to receive_messages(inventory_units_for: [build(:inventory_unit, variant_id: variant.id, state: 'shipped'),
- build(:inventory_unit,
- variant_id: variant.id, state: 'on_hand')] )
+ allow(shipment).to receive_messages(inventory_units_for: [
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'shipped'),
+ build(:inventory_unit,
+ variant_id: variant.id,
+ state: 'on_hand')
+ ] )
expect(shipment.inventory_units_for[0]).not_to receive(:destroy)
expect(shipment.inventory_units_for[1]).to receive(:destroy)
diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb
index adaaf97f4e..33856edd3b 100644
--- a/spec/models/spree/order_spec.rb
+++ b/spec/models/spree/order_spec.rb
@@ -10,13 +10,15 @@ describe Spree::Order do
it "provides friendly error messages" do
order.ship_address = Spree::Address.new
order.save
- expect(order.errors.full_messages).to include "Shipping address (Street + House number) can't be blank"
+ expect(order.errors.full_messages)
+ .to include "Shipping address (Street + House number) can't be blank"
end
it "provides friendly error messages for bill address" do
order.bill_address = Spree::Address.new
order.save
- expect(order.errors.full_messages).to include "Billing address (Street + House number) can't be blank"
+ expect(order.errors.full_messages)
+ .to include "Billing address (Street + House number) can't be blank"
end
end
@@ -200,7 +202,8 @@ describe Spree::Order do
end
it "should log state event" do
- expect(order.state_changes).to receive(:create).exactly(3).times # order, shipment & payment state changes
+ # order, shipment & payment state changes
+ expect(order.state_changes).to receive(:create).exactly(3).times
order.finalize!
end
@@ -428,7 +431,8 @@ describe Spree::Order do
end
# Regression test for Spree #2191
- context "when an order has an adjustment that zeroes the total, but another adjustment for shipping that raises it above zero" do
+ context "when an order has an adjustment that zeroes the total, but another adjustment " \
+ "for shipping that raises it above zero" do
let!(:persisted_order) { create(:order) }
let!(:line_item) { create(:line_item) }
let!(:shipping_method) do
@@ -565,7 +569,8 @@ describe Spree::Order do
expect_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).
to receive(:create_line_item_adjustments_for).
with(line_item)
- allow_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator).to receive(:create_order_adjustments_for)
+ allow_any_instance_of(OpenFoodNetwork::EnterpriseFeeCalculator)
+ .to receive(:create_order_adjustments_for)
allow(subject).to receive(:order_cycle) { order_cycle }
subject.recreate_all_fees!
@@ -886,7 +891,8 @@ describe Spree::Order do
subject.line_items = [line_item1, line_item2]
end
- it "allows the change when all variants in the order are provided by the new distributor in the new order cycle" do
+ it "allows the change when all variants in the order are provided " \
+ "by the new distributor in the new order cycle" do
new_distributor = create(:enterprise)
new_order_cycle = create(:simple_order_cycle, distributors: [new_distributor],
variants: [variant1, variant2])
@@ -897,13 +903,14 @@ describe Spree::Order do
expect(subject).to be_valid
end
- it "does not allow the change when not all variants in the order are provided by the new distributor" do
+ it "doesn't allow change when not all variants in order are provided by new distributor" do
new_distributor = create(:enterprise)
create(:simple_order_cycle, distributors: [new_distributor], variants: [variant1])
subject.distributor = new_distributor
expect(subject).not_to be_valid
- expect(subject.errors.messages).to eq(base: ["Distributor or order cycle cannot supply the products in your cart"])
+ expect(subject.errors.messages)
+ .to eq(base: ["Distributor or order cycle cannot supply the products in your cart"])
end
end
@@ -1093,7 +1100,9 @@ describe Spree::Order do
it "returns a validation error" do
expect{ order.next }.to change(order.errors, :count).from(0).to(1)
- expect(order.errors.messages[:email]).to eq ['This email address is already registered. Please log in to continue, or go back and use another email address.']
+ expect(order.errors.messages[:email]).to eq ['This email address is already registered. ' \
+ 'Please log in to continue, or go back and ' \
+ 'use another email address.']
expect(order.state).to eq 'cart'
end
end
@@ -1228,7 +1237,8 @@ describe Spree::Order do
it "returns previous items" do
expect(order.finalised_line_items.length).to eq 11
- expect(order.finalised_line_items).to match_array(prev_order.line_items + prev_order2.line_items)
+ expect(order.finalised_line_items)
+ .to match_array(prev_order.line_items + prev_order2.line_items)
end
end
end
diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb
index 32dba2f627..8951832e56 100644
--- a/spec/models/spree/payment_method_spec.rb
+++ b/spec/models/spree/payment_method_spec.rb
@@ -115,7 +115,8 @@ describe Spree::PaymentMethod do
end
it "generates a clean name for known Payment Method types" do
- expect(Spree::PaymentMethod::Check.clean_name).to eq('Cash/EFT/etc. (payments for which automatic validation is not required)')
+ expect(Spree::PaymentMethod::Check.clean_name)
+ .to eq('Cash/EFT/etc. (payments for which automatic validation is not required)')
expect(Spree::Gateway::PayPalExpress.clean_name).to eq('PayPal Express')
expect(Spree::Gateway::StripeSCA.clean_name).to eq('Stripe SCA')
expect(Spree::Gateway::BogusSimple.clean_name).to eq('BogusSimple')
@@ -133,7 +134,8 @@ describe Spree::PaymentMethod do
expect(flat_rate_payment_method.compute_amount(order)).to eq 10
flat_percent_payment_method = create(:payment_method,
- calculator: ::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10))
+ calculator: ::Calculator::FlatPercentItemTotal
+ .new(preferred_flat_percent: 10))
expect(flat_percent_payment_method.compute_amount(order)).to eq 0
product = create(:product)
diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb
index d47f1f7144..6d39f2e553 100644
--- a/spec/models/spree/payment_spec.rb
+++ b/spec/models/spree/payment_spec.rb
@@ -105,7 +105,8 @@ describe Spree::Payment do
end
it "should invalidate if payment method doesnt support source" do
- expect(payment.payment_method).to receive(:supports?).with(payment.source).and_return(false)
+ expect(payment.payment_method).to receive(:supports?)
+ .with(payment.source).and_return(false)
expect { payment.process! }.to raise_error(Spree::Core::GatewayError)
expect(payment.state).to eq('invalid')
end
@@ -439,7 +440,7 @@ describe Spree::Payment do
allow(payment.order).to receive(:outstanding_balance) { 101 }
end
- it "should call credit on the gateway with the original payment amount and response_code" do
+ it "should call credit on the gateway with original payment amount and response_code" do
expect(gateway).to receive(:credit).with(
amount_in_cents.to_f, card, '123', anything
).and_return(success_response)
diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb
index 9097e170d5..ac6675cb62 100644
--- a/spec/models/spree/product_spec.rb
+++ b/spec/models/spree/product_spec.rb
@@ -138,7 +138,8 @@ module Spree
Spree::Property.where(name: 'foo').first_or_create!(presentation: "Foo's Presentation Name")
product.set_property('foo', 'value1')
product.set_property('bar', 'value2')
- expect(Spree::Property.where(name: 'foo').first.presentation).to eq "Foo's Presentation Name"
+ expect(Spree::Property.where(name: 'foo').first.presentation)
+ .to eq "Foo's Presentation Name"
expect(Spree::Property.where(name: 'bar').first.presentation).to eq "bar"
end
end
@@ -191,7 +192,7 @@ module Spree
expect(Spree::Product.with_properties([])).to eq []
end
- it "returns only products with the wanted property set both on supplier and on the product itself" do
+ it "returns only products with the wanted property set both on supplier & product itself" do
expect(
Spree::Product.with_properties([wanted_property.id])
).to match_array [
@@ -610,9 +611,11 @@ module Spree
p2 = create(:product)
p3 = create(:product)
oc2 = create(:simple_order_cycle, suppliers: [s], distributors: [d2],
- variants: [p2.variants.first], orders_open_at: 8.days.ago, orders_close_at: 1.day.ago)
+ variants: [p2.variants.first],
+ orders_open_at: 8.days.ago, orders_close_at: 1.day.ago)
oc2 = create(:simple_order_cycle, suppliers: [s], distributors: [d3],
- variants: [p3.variants.first], orders_close_at: Date.tomorrow)
+ variants: [p3.variants.first],
+ orders_close_at: Date.tomorrow)
expect(Product.in_an_active_order_cycle).to eq([p3])
end
end
@@ -713,8 +716,9 @@ module Spree
product.set_property 'Organic Certified', 'NASAA 12345'
property = product.properties.last
- expect(product.properties_including_inherited).to eq([{ id: property.id,
- name: "Organic Certified", value: 'NASAA 12345' }])
+ expect(product.properties_including_inherited)
+ .to eq([{ id: property.id, name: "Organic Certified",
+ value: 'NASAA 12345' }])
end
it "returns producer properties as a hash" do
@@ -724,8 +728,9 @@ module Spree
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
property = supplier.properties.last
- expect(product.properties_including_inherited).to eq([{ id: property.id,
- name: "Organic Certified", value: 'NASAA 54321' }])
+ expect(product.properties_including_inherited)
+ .to eq([{ id: property.id, name: "Organic Certified",
+ value: 'NASAA 54321' }])
end
it "overrides producer properties with product properties" do
@@ -736,8 +741,9 @@ module Spree
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
property = product.properties.last
- expect(product.properties_including_inherited).to eq([{ id: property.id,
- name: "Organic Certified", value: 'NASAA 12345' }])
+ expect(product.properties_including_inherited)
+ .to eq([{ id: property.id, name: "Organic Certified",
+ value: 'NASAA 12345' }])
end
context "when product has an inherit_properties value set to true" do
@@ -748,8 +754,9 @@ module Spree
supplier.set_producer_property 'Organic Certified', 'NASAA 54321'
property = supplier.properties.last
- expect(product.properties_including_inherited).to eq([{ id: property.id,
- name: "Organic Certified", value: 'NASAA 54321' }])
+ expect(product.properties_including_inherited)
+ .to eq([{ id: property.id, name: "Organic Certified",
+ value: 'NASAA 54321' }])
end
end
diff --git a/spec/models/spree/shipping_method_spec.rb b/spec/models/spree/shipping_method_spec.rb
index 6031cd53f7..ec34bf3570 100644
--- a/spec/models/spree/shipping_method_spec.rb
+++ b/spec/models/spree/shipping_method_spec.rb
@@ -169,7 +169,8 @@ module Spree
shipping_categories: []
)
expect(shipping_method).not_to be_valid
- expect(shipping_method.errors[:base].first).to eq "You need to select at least one shipping category"
+ expect(shipping_method.errors[:base].first)
+ .to eq "You need to select at least one shipping category"
end
context "one associated" do