From 073ccfe633b668d162f994f5dc65b0c7e35c72c0 Mon Sep 17 00:00:00 2001 From: magicmilo Date: Wed, 27 Oct 2021 14:47:10 +0100 Subject: [PATCH] rubocop --- Gemfile | 2 +- app/models/case_log.rb | 2 +- spec/models/case_log_spec.rb | 8 ++++---- spec/rails_helper.rb | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 0084b7546..c249007c2 100644 --- a/Gemfile +++ b/Gemfile @@ -49,10 +49,10 @@ end group :test do gem "capybara", require: false + gem "database_cleaner-active_record", require: false gem "factory_bot_rails" gem "selenium-webdriver", require: false gem "simplecov", require: false - gem "database_cleaner-active_record", require: false %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib| gem lib, git: "https://github.com/rspec/#{lib}.git", branch: "main", require: false end diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 556013773..2c818c736 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -54,7 +54,7 @@ class CaseLogValidator < ActiveModel::Validator record.errors.add :armed_forces_injured, "You must not answer the armed forces injury question if the tenant has not served in the armed forces or prefer not to say was chosen" end end - + EMPLOYED_STATUSES = ["Full-time - 30 hours or more", "Part-time - Less than 30 hours"].freeze def validate_net_income_uc_proportion(record) (1..8).any? do |n| diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index cad16431f..e0d03ed53 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -115,7 +115,7 @@ RSpec.describe Form, type: :model do }.to raise_error(ActiveRecord::RecordInvalid) end end - + context "fixed term tenancy length" do it "Must not be completed if Type of main tenancy is not responded with either Secure or Assured shorthold " do expect { @@ -163,7 +163,7 @@ RSpec.describe Form, type: :model do }.not_to raise_error end end - + context "armed forces active validation" do it "must be answered if ever served in the forces as a regular" do expect { @@ -176,7 +176,7 @@ RSpec.describe Form, type: :model do expect { CaseLog.create!(armed_forces: "No", armed_forces_active: "Yes") - }.to raise_error + }.to raise_error(ActiveRecord::RecordInvalid) end # Crossover over tests here as injured must be answered as well for no error @@ -185,7 +185,7 @@ RSpec.describe Form, type: :model do CaseLog.create!(armed_forces: "Yes - a regular", armed_forces_active: "Yes", armed_forces_injured: "Yes") - }.not_to raise_error + }.not_to raise_error end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b873a5929..7a6a17442 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -6,7 +6,7 @@ require File.expand_path("../config/environment", __dir__) abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" require "capybara/rspec" -require 'database_cleaner/active_record' +require "database_cleaner/active_record" # Comment to run `js: true specs` with visible browser interaction Capybara.javascript_driver = :selenium_headless @@ -58,6 +58,7 @@ RSpec.configure do |config| uncommitted transaction data setup over the spec's database connection. MSG end + DatabaseCleaner.clean_with(:truncation) end