diff --git a/adr/00003-testing-practices.md b/adr/00003-testing-practices.md index 35820fb81c..9784f8cae4 100644 --- a/adr/00003-testing-practices.md +++ b/adr/00003-testing-practices.md @@ -19,13 +19,13 @@ Use the following test types for our classes, modules, and functionalities. ```ruby RSpec.describe User, type: :model do subject { build(:user) } - + describe ".class_method" do it "does something" do expect(User.class_method).to do_something end end - + describe "#instance_method" do it "does something" do expect(subject.instance_method).to do_something @@ -41,7 +41,7 @@ Use the following test types for our classes, modules, and functionalities. expect(User.class_method).to do_something end end - + describe "#instance_method" do it "does something" do expect(subject.instance_method).to do_something @@ -59,11 +59,11 @@ Use the following test types for our classes, modules, and functionalities. given_i_am_on_the_landing_page i_can_see_something end - + def given_i_am_on_the_landing_page visit "/" end - + def i_can_see_something expect(page).to have_content("Something") end @@ -81,25 +81,19 @@ Use the following test types for our classes, modules, and functionalities. # Base happy path first it "returns a list of users" do get :index - - expected_json = [ - { - id: 1, - first_name: "John", - last_name: "Doe" - } - ] - + + expected_json = [{ id: 1, first_name: "John", last_name: "Doe" }] + expect(response.body).to eq(expected_json) end - + # Happy path variants next context "when given a 'name' query parameter" do it "returns a list of users filtered by name" do # Assertion end end - + # Error paths context "without authentication" do it "returns a 401 error" do @@ -107,7 +101,7 @@ Use the following test types for our classes, modules, and functionalities. end end end - + context "POST /users" do it "returns a list of users" do get :index diff --git a/app/models/dfe_sign_in_user.rb b/app/models/dfe_sign_in_user.rb index 4ae7efd6b1..f46cef7c89 100644 --- a/app/models/dfe_sign_in_user.rb +++ b/app/models/dfe_sign_in_user.rb @@ -21,7 +21,7 @@ def self.begin_session!(session, omniauth_payload) "email" => omniauth_payload["info"]["email"], # "dfe_sign_in_uid" => omniauth_payload["uid"], "first_name" => omniauth_payload["info"]["first_name"], - "last_name" => omniauth_payload["info"]["last_name"] + "last_name" => omniauth_payload["info"]["last_name"], # "last_active_at" => Time.zone.now, # "id_token" => omniauth_payload["credentials"]["id_token"], # "provider" => omniauth_payload["provider"], @@ -39,7 +39,7 @@ def self.load_from_session(session) last_name: dfe_sign_in_session["last_name"], # id_token: dfe_sign_in_session["id_token"], # provider: dfe_sign_in_session["provider"], - service: session["service"] + service: session["service"], ) end diff --git a/app/services/gias_csv_importer.rb b/app/services/gias_csv_importer.rb index 439057049e..ac2a4fb226 100644 --- a/app/services/gias_csv_importer.rb +++ b/app/services/gias_csv_importer.rb @@ -32,7 +32,7 @@ def call address2: school["Locality"].presence, address3: school["Address3"].presence, website: school["SchoolWebsite"].presence, - telephone: school["TelephoneNum"].presence + telephone: school["TelephoneNum"].presence, } end diff --git a/bin/bundle b/bin/bundle index e7b4ab397f..f762277c87 100755 --- a/bin/bundle +++ b/bin/bundle @@ -102,7 +102,7 @@ m = require_error = activation_error_handling { require "bundler/version" } if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?( - Gem::Version.new(Bundler::VERSION) + Gem::Version.new(Bundler::VERSION), ) return end diff --git a/config/application.rb b/config/application.rb index 2aeb8a349f..700c90e186 100644 --- a/config/application.rb +++ b/config/application.rb @@ -33,7 +33,7 @@ class Application < Rails::Application config.autoload_lib(ignore: %w[]) config.assets.paths << Rails.root.join( - "node_modules/govuk-frontend/dist/govuk/assets" + "node_modules/govuk-frontend/dist/govuk/assets", ) config.autoload_paths += %W[#{config.root}/app/assets/components] diff --git a/config/environments/development.rb b/config/environments/development.rb index 735c2d6306..fb54819e24 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -25,7 +25,7 @@ config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}", } else config.action_controller.perform_caching = false @@ -35,7 +35,7 @@ config.action_mailer.delivery_method = :notify config.action_mailer.notify_settings = { - api_key: ENV.fetch("GOVUK_NOTIFY_API_KEY") + api_key: ENV.fetch("GOVUK_NOTIFY_API_KEY"), } # Store uploaded files on the local file system (see config/storage.yml for options). diff --git a/config/environments/test.rb b/config/environments/test.rb index b8cfb2842b..aad4bd68ab 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -19,7 +19,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}", } # Show full error reports and disable caching. diff --git a/config/initializers/better_html.rb b/config/initializers/better_html.rb index 957f6f86a5..37d889823b 100644 --- a/config/initializers/better_html.rb +++ b/config/initializers/better_html.rb @@ -3,7 +3,7 @@ BetterHtml.config = BetterHtml::Config.new( - YAML.safe_load(File.read(Rails.root.join(".better-html.yml"))) + YAML.safe_load(File.read(Rails.root.join(".better-html.yml"))), ) BetterHtml.configure do |config| diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 433415332b..1899588c75 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -9,7 +9,7 @@ provider( :developer, fields: %i[uid email first_name last_name], - uid_field: :uid + uid_field: :uid, ) end when "dfe-sign-in" diff --git a/config/initializers/persona.rb b/config/initializers/persona.rb index c60e4af2e0..d4833c9aa8 100644 --- a/config/initializers/persona.rb +++ b/config/initializers/persona.rb @@ -6,15 +6,15 @@ { first_name: "Patricia", last_name: "Adebayo", - email: "patricia@example.com" + email: "patricia@example.com", }, { first_name: "Mary", last_name: "Lawson", email: "mary@example.com" }, { first_name: "Colin", last_name: "Chapman", email: "colin@example.com", - support_user: true - } + support_user: true, + }, ].push((DEVELOPER_PERSONA if defined?(DEVELOPER_PERSONA))).compact.freeze PERSONA_EMAILS = PERSONAS.map { |persona| persona[:email] } diff --git a/config/routes/placements.rb b/config/routes/placements.rb index 55c69dddc1..25f30b8416 100644 --- a/config/routes/placements.rb +++ b/config/routes/placements.rb @@ -1,7 +1,7 @@ scope module: :placements, as: :placements, constraints: { - host: ENV["PLACEMENTS_HOST"] + host: ENV["PLACEMENTS_HOST"], } do root to: "pages#index" diff --git a/lib/hosting_environment.rb b/lib/hosting_environment.rb index bcd5d541c8..05b845b63e 100644 --- a/lib/hosting_environment.rb +++ b/lib/hosting_environment.rb @@ -1,7 +1,7 @@ module HostingEnvironment PRODUCTION_BANNER_NAME = { claims: "beta", - placements: "beta" + placements: "beta", }.with_indifferent_access.freeze def self.name(current_service) diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index 6d2fa9fea7..43a5ccb407 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -52,7 +52,7 @@ if Rails.env.development? "trace" => "false", "wrapper_open" => nil, "wrapper_close" => nil, - "with_comment" => "true" + "with_comment" => "true", ) end diff --git a/spec/decorators/persona_decorator_spec.rb b/spec/decorators/persona_decorator_spec.rb index 7f8b645646..3e69318723 100644 --- a/spec/decorators/persona_decorator_spec.rb +++ b/spec/decorators/persona_decorator_spec.rb @@ -11,7 +11,7 @@ context "when the persona is Patricia" do it "returns orange" do expect(build(:persona, :patricia).decorate.type_tag_colour).to eq( - "orange" + "orange", ) end end diff --git a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb index 926cbf3cc5..b8626302bf 100644 --- a/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb +++ b/spec/features/personas/sign_in_as_a_claims_user_persona_spec.rb @@ -70,7 +70,7 @@ def then_i_see_persona_details_for_anne page_has_persona_content( first_name: "Anne", last_name: "Wilson", - email: "anne_wilson@example.org" + email: "anne_wilson@example.org", ) end @@ -78,7 +78,7 @@ def then_i_see_persona_details_for_patricia page_has_persona_content( first_name: "Patricia", last_name: "Adebayo", - email: "patricia@example.com" + email: "patricia@example.com", ) end @@ -86,7 +86,7 @@ def then_i_see_persona_details_for_mary page_has_persona_content( first_name: "Mary", last_name: "Lawson", - email: "mary@example.com" + email: "mary@example.com", ) end @@ -94,7 +94,7 @@ def then_i_see_persona_details_for_colin page_has_persona_content( first_name: "Colin", last_name: "Chapman", - email: "colin@example.com" + email: "colin@example.com", ) end diff --git a/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb b/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb index 0606f6cc91..069e7a5a00 100644 --- a/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb +++ b/spec/features/personas/sign_in_as_a_placements_user_persona_spec.rb @@ -85,7 +85,7 @@ def then_i_see_persona_details_for_anne page_has_persona_content( first_name: "Anne", last_name: "Wilson", - email: "anne_wilson@example.org" + email: "anne_wilson@example.org", ) end @@ -93,7 +93,7 @@ def then_i_see_persona_details_for_patricia page_has_persona_content( first_name: "Patricia", last_name: "Adebayo", - email: "patricia@example.com" + email: "patricia@example.com", ) end @@ -101,7 +101,7 @@ def then_i_see_persona_details_for_mary page_has_persona_content( first_name: "Mary", last_name: "Lawson", - email: "mary@example.com" + email: "mary@example.com", ) end @@ -109,7 +109,7 @@ def then_i_see_persona_details_for_colin page_has_persona_content( first_name: "Colin", last_name: "Chapman", - email: "colin@example.com" + email: "colin@example.com", ) end diff --git a/spec/lib/hosting_environment_spec.rb b/spec/lib/hosting_environment_spec.rb index bd8c8490a9..4f1f767e0b 100644 --- a/spec/lib/hosting_environment_spec.rb +++ b/spec/lib/hosting_environment_spec.rb @@ -26,14 +26,14 @@ it "returns the banner description of the hosting environment for claims" do current_service = "claims" expect(described_class.banner_description(current_service)).to eq( - "Make a complaint or give feedback" + "Make a complaint or give feedback", ) end it "returns the banner description of the hosting environment for placements" do current_service = "placements" expect(described_class.banner_description(current_service)).to eq( - "Make a complaint or give feedback" + "Make a complaint or give feedback", ) end end diff --git a/spec/models/dfe_sign_in_user_spec.rb b/spec/models/dfe_sign_in_user_spec.rb index 536e62db2f..1f56e2cecc 100644 --- a/spec/models/dfe_sign_in_user_spec.rb +++ b/spec/models/dfe_sign_in_user_spec.rb @@ -8,8 +8,8 @@ "info" => { "first_name" => "Example", "last_name" => "User", - "email" => "example_user@example.com" - } + "email" => "example_user@example.com", + }, } DfESignInUser.begin_session!(session, omniauth_payload) @@ -18,9 +18,9 @@ "dfe_sign_in_user" => { "first_name" => "Example", "last_name" => "User", - "email" => "example_user@example.com" - } - } + "email" => "example_user@example.com", + }, + }, ) end end @@ -31,9 +31,9 @@ "dfe_sign_in_user" => { "first_name" => "Example", "last_name" => "User", - "email" => "example_user@example.com" + "email" => "example_user@example.com", }, - "service" => :placements + "service" => :placements, } dfe_sign_in_user = DfESignInUser.load_from_session(session) @@ -53,9 +53,9 @@ "dfe_sign_in_user" => { "first_name" => claims_user.first_name, "last_name" => claims_user.last_name, - "email" => claims_user.email + "email" => claims_user.email, }, - "service" => :claims + "service" => :claims, } dfe_sign_in_user = DfESignInUser.load_from_session(session) @@ -73,9 +73,9 @@ "dfe_sign_in_user" => { "first_name" => placements_user.first_name, "last_name" => placements_user.last_name, - "email" => placements_user.email + "email" => placements_user.email, }, - "service" => :placements + "service" => :placements, } dfe_sign_in_user = DfESignInUser.load_from_session(session) @@ -91,9 +91,9 @@ "dfe_sign_in_user" => { "first_name" => support_user.first_name, "last_name" => support_user.last_name, - "email" => support_user.email + "email" => support_user.email, }, - "service" => :placements + "service" => :placements, } dfe_sign_in_user = DfESignInUser.load_from_session(session) @@ -110,8 +110,8 @@ "dfe_sign_in_user" => { "first_name" => "Example", "last_name" => "User", - "email" => "example_user@example.com" - } + "email" => "example_user@example.com", + }, } DfESignInUser.end_session!(session) diff --git a/spec/models/service_update_spec.rb b/spec/models/service_update_spec.rb index d90c94c54a..929c580a6d 100644 --- a/spec/models/service_update_spec.rb +++ b/spec/models/service_update_spec.rb @@ -11,9 +11,9 @@ { date: "2023-12-14", title: "Claim Update", - content: "Some content" - } - ] + content: "Some content", + }, + ], ) updates = ServiceUpdate.where(service: :claims) expect(updates.length).to eq(1) @@ -34,9 +34,9 @@ { date: "2023-12-14", title: "Placement Update", - content: "Some content" - } - ] + content: "Some content", + }, + ], ) updates = ServiceUpdate.where(service: :placements) expect(updates.length).to eq(1) @@ -60,7 +60,7 @@ it "returns placements YAML file path" do file_path = ServiceUpdate.file_path(service: :placements) expect(file_path).to eq( - Rails.root.join("db/placements_service_updates.yml") + Rails.root.join("db/placements_service_updates.yml"), ) end diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb index 4d85561a6d..782c21c418 100644 --- a/spec/requests/sessions_spec.rb +++ b/spec/requests/sessions_spec.rb @@ -14,7 +14,7 @@ params: { first_name: placements_user.first_name, last_name: placements_user.last_name, - email: placements_user.email + email: placements_user.email, } follow_redirect! diff --git a/spec/services/gias_csv_importer_spec.rb b/spec/services/gias_csv_importer_spec.rb index 73d3e579e3..59894b0f18 100644 --- a/spec/services/gias_csv_importer_spec.rb +++ b/spec/services/gias_csv_importer_spec.rb @@ -15,8 +15,8 @@ it "logs messages to STDOUT" do expect { subject }.to output( match(/Done!/).and(match(/Invalid rows - /)).and( - match(/Row 5 is invalid/) - ) + match(/Row 5 is invalid/), + ), ).to_stdout end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 23fc8f8349..185270855b 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,18 +1,18 @@ -require 'capybara/rspec' +require "capybara/rspec" # Use different Capybara ports when running tests in parallel -if ENV['TEST_ENV_NUMBER'] - Capybara.server_port = 9887 + ENV['TEST_ENV_NUMBER'].to_i +if ENV["TEST_ENV_NUMBER"] + Capybara.server_port = 9887 + ENV["TEST_ENV_NUMBER"].to_i end Capybara.register_driver :chrome_headless do |app| options = Selenium::WebDriver::Chrome::Options.new - options.add_argument('--headless') unless ENV['HEADLESS'] == 'false' - options.add_argument('--no-sandbox') - options.add_argument('--disable-dev-shm-usage') - options.add_argument('--disable-gpu') - options.add_argument('--window-size=1400,1400') + options.add_argument("--headless") unless ENV["HEADLESS"] == "false" + options.add_argument("--no-sandbox") + options.add_argument("--disable-dev-shm-usage") + options.add_argument("--disable-gpu") + options.add_argument("--window-size=1400,1400") Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end diff --git a/spec/tasks/gias_update_spec.rb b/spec/tasks/gias_update_spec.rb index 84df49cbfa..c687653787 100644 --- a/spec/tasks/gias_update_spec.rb +++ b/spec/tasks/gias_update_spec.rb @@ -11,7 +11,7 @@ tempfile = Tempfile.new("foo") expect(Down).to receive(:download).with( - "#{ENV["GIAS_CSV_BASE_URL"]}/#{gias_filename}" + "#{ENV["GIAS_CSV_BASE_URL"]}/#{gias_filename}", ).and_return(tempfile) expect(GiasCsvImporter).to receive(:call).with(tempfile.path) diff --git a/spec/views/erb_safety_check_spec.rb b/spec/views/erb_safety_check_spec.rb index caf14de7a3..7300a7f0f4 100644 --- a/spec/views/erb_safety_check_spec.rb +++ b/spec/views/erb_safety_check_spec.rb @@ -7,7 +7,7 @@ erb_glob = Rails.root.join( - "app/views/**/{*.htm,*.html,*.htm.erb,*.html.erb,*.html+*.erb}" + "app/views/**/{*.htm,*.html,*.htm.erb,*.html.erb,*.html+*.erb}", ) Dir[erb_glob].each do |filename|