Browse Source

refactor: rubocop

pull/1455/head
natdeanlewissoftwire 3 years ago
parent
commit
79c16f7094
  1. 5
      spec/helpers/schemes_helper_spec.rb
  2. 8
      spec/models/form/lettings/questions/scheme_id_spec.rb
  3. 2
      spec/models/scheme_spec.rb
  4. 4
      spec/models/validations/date_validations_spec.rb
  5. 5
      spec/models/validations/setup_validations_spec.rb
  6. 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",
created_at: Time.zone.local(2022, 4, 1))
end
let!(:location) { FactoryBot.create(:location, scheme:) }
let!(:scheme_where_managing_organisation_is_owning_organisation) { FactoryBot.create(:scheme, arrangement_type: "D") }
let(:support_user) { FactoryBot.create(:user, :support) }
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
attributes = [
{ name: "Scheme code", value: "S#{scheme.id}" },

8
spec/models/form/lettings/questions/scheme_id_spec.rb

@ -51,7 +51,9 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do
end
context "when a scheme with at least 1 location exists" do
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
FactoryBot.create(:location, scheme:)
end
it "has the correct answer_options based on the schemes the user's organisation owns or manages" do
expected_answer = { "" => "Select an option", scheme.id.to_s => scheme }
@ -82,7 +84,9 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do
end
context "when the question is answered" do
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
FactoryBot.create(:location, scheme:)
end
it "returns scheme as selected answer" do
lettings_log.update!(scheme:)

2
spec/models/scheme_spec.rb

@ -94,9 +94,9 @@ RSpec.describe Scheme, type: :model do
describe "status" do
let(:scheme) { FactoryBot.build(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
FactoryBot.create(:location, scheme:)
Timecop.freeze(2022, 6, 7)
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
let(:scheme) { create(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
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:)
scheme.reload
end
@ -196,9 +196,9 @@ RSpec.describe Validations::DateValidations do
context "with a scheme that has many reactivations soon" do
let(:scheme) { create(:scheme) }
let!(:location) { FactoryBot.create(:location, scheme:) }
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, 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:)

5
spec/models/validations/setup_validations_spec.rb

@ -186,9 +186,8 @@ RSpec.describe Validations::SetupValidations do
context "with a scheme that is reactivating soon" do
let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) }
let!(:location) { FactoryBot.create(:location, scheme:) }
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:)
scheme.reload
end
@ -211,9 +210,9 @@ RSpec.describe Validations::SetupValidations do
context "with a scheme that has many reactivations soon" do
let(:scheme) { create(:scheme, created_at: Time.zone.local(2022, 4, 1)) }
let!(:location) { FactoryBot.create(:location, scheme:) }
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, 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:)

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!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) }
let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period }
let!(:location) { FactoryBot.create(:location, scheme:) }
before do
FactoryBot.create(:location, scheme:)
Timecop.freeze(Time.utc(2022, 10, 10))
sign_in user
add_deactivations

Loading…
Cancel
Save