mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Fixes variable number naming offenses in spec variables
This commit is contained in:
@@ -221,7 +221,7 @@ Metrics/PerceivedComplexity:
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# Offense count: 18
|
||||
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
||||
# SupportedStyles: snake_case, normalcase, non_integer
|
||||
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
|
||||
@@ -229,9 +229,6 @@ Naming/VariableNumber:
|
||||
Exclude:
|
||||
- 'app/models/content_configuration.rb'
|
||||
- 'app/models/preference_sections/main_links_section.rb'
|
||||
- 'spec/controllers/spree/admin/search_controller_spec.rb'
|
||||
- 'spec/models/spree/stock_item_spec.rb'
|
||||
- 'spec/requests/api/orders_spec.rb'
|
||||
|
||||
# Offense count: 144
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
|
||||
@@ -34,9 +34,9 @@ RSpec.describe Spree::Admin::SearchController, type: :controller do
|
||||
end
|
||||
|
||||
describe 'searching for customers' do
|
||||
let!(:customer_1) { create(:customer, enterprise:, email: 'test1@email.com') }
|
||||
let!(:customer_2) { create(:customer, enterprise:, first_name: 'test2') }
|
||||
let!(:customer_3) { create(:customer, email: 'test3@email.com') }
|
||||
let!(:customer1) { create(:customer, enterprise:, email: 'test1@email.com') }
|
||||
let!(:customer2) { create(:customer, enterprise:, first_name: 'test2') }
|
||||
let!(:customer3) { create(:customer, email: 'test3@email.com') }
|
||||
|
||||
describe 'when search owned enterprises' do
|
||||
before do
|
||||
@@ -48,13 +48,13 @@ RSpec.describe Spree::Admin::SearchController, type: :controller do
|
||||
it 'returns a list of customers of the enterprise' do
|
||||
expect(@results.size).to eq 2
|
||||
|
||||
expect(@results.find { |c| c['id'] == customer_1.id }).to be_truthy
|
||||
expect(@results.find { |c| c['id'] == customer_2.id }).to be_truthy
|
||||
expect(@results.find { |c| c['id'] == customer1.id }).to be_truthy
|
||||
expect(@results.find { |c| c['id'] == customer2.id }).to be_truthy
|
||||
end
|
||||
|
||||
it 'does not return the customer of other enterprises' do
|
||||
expect(@results.find { |c| c['id'] == customer_3.id }).to be_nil
|
||||
p customer_3
|
||||
expect(@results.find { |c| c['id'] == customer3.id }).to be_nil
|
||||
p customer3
|
||||
p enterprise
|
||||
end
|
||||
end
|
||||
@@ -62,7 +62,7 @@ RSpec.describe Spree::Admin::SearchController, type: :controller do
|
||||
|
||||
describe 'when search in unmanaged enterprise' do
|
||||
before do
|
||||
spree_get :customers, q: "test", distributor_id: customer_3.enterprise_id
|
||||
spree_get :customers, q: "test", distributor_id: customer3.enterprise_id
|
||||
@results = response.parsed_body
|
||||
end
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ RSpec.describe Spree::StockItem do
|
||||
|
||||
context "item out of stock (by two items)" do
|
||||
let(:inventory_unit) { double('InventoryUnit') }
|
||||
let(:inventory_unit_2) { double('InventoryUnit2') }
|
||||
let(:inventory_unit2) { double('InventoryUnit2') }
|
||||
|
||||
before do
|
||||
allow(subject).to receive(:backorderable?).and_return(true)
|
||||
@@ -89,12 +89,12 @@ RSpec.describe Spree::StockItem do
|
||||
context "adds new items" do
|
||||
before {
|
||||
allow(subject).to receive_messages(backordered_inventory_units: [inventory_unit,
|
||||
inventory_unit_2])
|
||||
inventory_unit2])
|
||||
}
|
||||
|
||||
it "fills existing backorders" do
|
||||
expect(inventory_unit).to receive(:fill_backorder)
|
||||
expect(inventory_unit_2).to receive(:fill_backorder)
|
||||
expect(inventory_unit2).to receive(:fill_backorder)
|
||||
|
||||
subject.adjust_count_on_hand(3)
|
||||
expect(subject.count_on_hand).to eq(1)
|
||||
|
||||
@@ -37,25 +37,25 @@ RSpec.describe 'api/v0/orders', swagger_doc: 'v0.yaml', type: :request do
|
||||
}
|
||||
}
|
||||
context "when there are four orders with different properties set" do
|
||||
let!(:order_dist_1) {
|
||||
let!(:order_dist1) {
|
||||
create(:order_with_distributor, email: "specific_name@example.com")
|
||||
}
|
||||
let!(:li1) { create(:line_item, order: order_dist_1) }
|
||||
let!(:order_dist_2) { create(:order_with_totals_and_distribution) }
|
||||
let!(:li2) { create(:line_item, order: order_dist_2) }
|
||||
let!(:li1) { create(:line_item, order: order_dist1) }
|
||||
let!(:order_dist2) { create(:order_with_totals_and_distribution) }
|
||||
let!(:li2) { create(:line_item, order: order_dist2) }
|
||||
let!(:order_dist_1_complete) {
|
||||
create(:completed_order_with_totals, distributor: order_dist_1.distributor,
|
||||
create(:completed_order_with_totals, distributor: order_dist1.distributor,
|
||||
state: 'complete',
|
||||
completed_at: Time.zone.today - 7.days,
|
||||
line_items_count: 1)
|
||||
}
|
||||
let!(:order_dist_1_credit_owed) {
|
||||
create(:order, distributor: order_dist_1.distributor, payment_state: 'credit_owed',
|
||||
create(:order, distributor: order_dist1.distributor, payment_state: 'credit_owed',
|
||||
completed_at: Time.zone.today)
|
||||
}
|
||||
let!(:li4) { create(:line_item_with_shipment, order: order_dist_1_credit_owed) }
|
||||
|
||||
let(:user) { order_dist_1.distributor.owner }
|
||||
let(:user) { order_dist1.distributor.owner }
|
||||
let(:'X-Spree-Token') do
|
||||
user.generate_api_key
|
||||
user.save
|
||||
@@ -73,9 +73,9 @@ RSpec.describe 'api/v0/orders', swagger_doc: 'v0.yaml', type: :request do
|
||||
end
|
||||
|
||||
context "and queried by distributor id" do
|
||||
let(:'q[distributor_id_eq]') { order_dist_2.distributor.id }
|
||||
let(:'q[distributor_id_eq]') { order_dist2.distributor.id }
|
||||
|
||||
before { order_dist_2.distributor.update owner: user }
|
||||
before { order_dist2.distributor.update owner: user }
|
||||
|
||||
run_test! do |response|
|
||||
expect(response).to have_http_status(200)
|
||||
@@ -83,7 +83,7 @@ RSpec.describe 'api/v0/orders', swagger_doc: 'v0.yaml', type: :request do
|
||||
data = JSON.parse(response.body)
|
||||
orders = data["orders"]
|
||||
expect(orders.size).to eq 1
|
||||
expect(orders.first["id"]).to eq order_dist_2.id
|
||||
expect(orders.first["id"]).to eq order_dist2.id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -126,23 +126,23 @@ RSpec.describe 'api/v0/orders', swagger_doc: 'v0.yaml', type: :request do
|
||||
end
|
||||
|
||||
context "and queried by buyer email contains a specific string" do
|
||||
let(:'q[email_cont]') { order_dist_1.email.split("@").first }
|
||||
let(:'q[email_cont]') { order_dist1.email.split("@").first }
|
||||
run_test! do |response|
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
orders = data["orders"]
|
||||
expect(orders.size).to eq 1
|
||||
expect(orders.first["id"]).to eq order_dist_1.id
|
||||
expect(orders.first["id"]).to eq order_dist1.id
|
||||
end
|
||||
end
|
||||
|
||||
context "and queried by a specific order_cycle" do
|
||||
let(:'q[order_cycle_id_eq]') {
|
||||
order_dist_2.order_cycle.id
|
||||
order_dist2.order_cycle.id
|
||||
}
|
||||
|
||||
before { order_dist_2.distributor.update owner: user }
|
||||
before { order_dist2.distributor.update owner: user }
|
||||
|
||||
run_test! do |response|
|
||||
expect(response).to have_http_status(200)
|
||||
@@ -150,7 +150,7 @@ RSpec.describe 'api/v0/orders', swagger_doc: 'v0.yaml', type: :request do
|
||||
data = JSON.parse(response.body)
|
||||
orders = data["orders"]
|
||||
expect(orders.size).to eq 1
|
||||
expect(orders.first["id"]).to eq order_dist_2.id
|
||||
expect(orders.first["id"]).to eq order_dist2.id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user