Browse Source

refactor: rubocop

pull/1456/head
natdeanlewissoftwire 3 years ago
parent
commit
5bb906563a
  1. 5
      spec/helpers/schemes_helper_spec.rb
  2. 2
      spec/models/scheme_spec.rb
  3. 4
      spec/models/validations/date_validations_spec.rb
  4. 4
      spec/models/validations/setup_validations_spec.rb
  5. 2
      spec/requests/schemes_controller_spec.rb

5
spec/helpers/schemes_helper_spec.rb

@ -106,11 +106,14 @@ RSpec.describe SchemesHelper do
intended_stay: "P", intended_stay: "P",
created_at: Time.zone.local(2022, 4, 1)) created_at: Time.zone.local(2022, 4, 1))
end end
let!(:location) { FactoryBot.create(:location, scheme:) }
let!(:scheme_where_managing_organisation_is_owning_organisation) { FactoryBot.create(:scheme, arrangement_type: "D") } let!(:scheme_where_managing_organisation_is_owning_organisation) { FactoryBot.create(:scheme, arrangement_type: "D") }
let(:support_user) { FactoryBot.create(:user, :support) } let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user, :data_coordinator) } let(:coordinator_user) { FactoryBot.create(:user, :data_coordinator) }
before do
FactoryBot.create(:location, scheme:)
end
it "returns correct display attributes for a support user" do it "returns correct display attributes for a support user" do
attributes = [ attributes = [
{ name: "Scheme code", value: "S#{scheme.id}" }, { name: "Scheme code", value: "S#{scheme.id}" },

2
spec/models/scheme_spec.rb

@ -94,9 +94,9 @@ RSpec.describe Scheme, type: :model do
describe "status" do describe "status" do
let(:scheme) { FactoryBot.build(:scheme) } let(:scheme) { FactoryBot.build(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
Timecop.freeze(2022, 6, 7) Timecop.freeze(2022, 6, 7)
end end

4
spec/models/validations/date_validations_spec.rb

@ -171,9 +171,9 @@ RSpec.describe Validations::DateValidations do
context "with a scheme that is reactivating soon" do context "with a scheme that is reactivating soon" do
let(:scheme) { create(:scheme) } let(:scheme) { create(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:)
scheme.reload scheme.reload
end end
@ -196,9 +196,9 @@ RSpec.describe Validations::DateValidations do
context "with a scheme that has many reactivations soon" do context "with a scheme that has many reactivations soon" do
let(:scheme) { create(:scheme) } let(:scheme) { create(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 2), reactivation_date: Time.zone.local(2022, 8, 3), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 2), reactivation_date: Time.zone.local(2022, 8, 3), scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 1), reactivation_date: Time.zone.local(2022, 9, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 1), reactivation_date: Time.zone.local(2022, 9, 4), scheme:)

4
spec/models/validations/setup_validations_spec.rb

@ -186,9 +186,9 @@ RSpec.describe Validations::SetupValidations do
context "with a scheme that is reactivating soon" do context "with a scheme that is reactivating soon" do
let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) } let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:)
scheme.reload scheme.reload
end end
@ -211,9 +211,9 @@ RSpec.describe Validations::SetupValidations do
context "with a scheme that has many reactivations soon" do context "with a scheme that has many reactivations soon" do
let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) } let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4), reactivation_date: Time.zone.local(2022, 8, 4), scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 2), reactivation_date: Time.zone.local(2022, 8, 3), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 2), reactivation_date: Time.zone.local(2022, 8, 3), scheme:)
create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 1), reactivation_date: Time.zone.local(2022, 9, 4), scheme:) create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 1), reactivation_date: Time.zone.local(2022, 9, 4), scheme:)

2
spec/requests/schemes_controller_spec.rb

@ -264,9 +264,9 @@ RSpec.describe SchemesController, type: :request do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) }
let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period } let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do before do
FactoryBot.create(:location, scheme:)
Timecop.freeze(Time.utc(2022, 10, 10)) Timecop.freeze(Time.utc(2022, 10, 10))
sign_in user sign_in user
add_deactivations add_deactivations

Loading…
Cancel
Save