Browse Source

Hash syntax

pull/473/head
baarkerlounger 3 years ago
parent
commit
cbdcde2bcd
  1. 8
      Gemfile.lock
  2. 2
      app/models/case_log.rb
  3. 4
      spec/controllers/admin/admin_users_controller_spec.rb
  4. 4
      spec/controllers/admin/case_logs_controller_spec.rb
  5. 4
      spec/controllers/admin/organisations_controller_spec.rb
  6. 4
      spec/controllers/admin/users_controller_spec.rb
  7. 2
      spec/helpers/question_view_helper_spec.rb
  8. 4
      spec/requests/auth/passwords_controller_spec.rb
  9. 2
      spec/requests/bulk_upload_controller_spec.rb
  10. 30
      spec/requests/case_logs_controller_spec.rb
  11. 6
      spec/requests/content_controller_spec.rb
  12. 2
      spec/requests/form_controller_spec.rb
  13. 30
      spec/requests/organisations_controller_spec.rb
  14. 92
      spec/requests/users_controller_spec.rb
  15. 2
      spec/views/form/page_view_spec.rb

8
Gemfile.lock

@ -69,7 +69,7 @@ GEM
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0)
activeadmin (2.11.1) activeadmin (2.11.2)
arbre (~> 1.2, >= 1.2.1) arbre (~> 1.2, >= 1.2.1)
formtastic (>= 3.1, < 5.0) formtastic (>= 3.1, < 5.0)
formtastic_i18n (~> 0.4) formtastic_i18n (~> 0.4)
@ -105,8 +105,8 @@ GEM
ruby2_keywords (>= 0.0.2, < 1.0) ruby2_keywords (>= 0.0.2, < 1.0)
ast (2.4.2) ast (2.4.2)
aws-eventstream (1.2.0) aws-eventstream (1.2.0)
aws-partitions (1.575.0) aws-partitions (1.576.0)
aws-sdk-core (3.130.0) aws-sdk-core (3.130.1)
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0) aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1) aws-sigv4 (~> 1.1)
@ -269,7 +269,7 @@ GEM
globalid globalid
paper_trail (>= 3.0.0) paper_trail (>= 3.0.0)
parallel (1.22.1) parallel (1.22.1)
parser (3.1.1.0) parser (3.1.2.0)
ast (~> 2.4.1) ast (~> 2.4.1)
pg (1.3.5) pg (1.3.5)
postcodes_io (0.4.0) postcodes_io (0.4.0)

2
app/models/case_log.rb

@ -34,7 +34,7 @@ class CaseLog < ApplicationRecord
belongs_to :managing_organisation, class_name: "Organisation" belongs_to :managing_organisation, class_name: "Organisation"
scope :for_organisation, ->(org) { where(owning_organisation: org).or(where(managing_organisation: org)) } scope :for_organisation, ->(org) { where(owning_organisation: org).or(where(managing_organisation: org)) }
scope :filter_by_status, ->(status, _user = nil) { where status: status } scope :filter_by_status, ->(status, _user = nil) { where status: }
scope :filter_by_years, lambda { |years, _user = nil| scope :filter_by_years, lambda { |years, _user = nil|
first_year = years.shift first_year = years.shift
query = filter_by_year(first_year) query = filter_by_year(first_year)

4
spec/controllers/admin/admin_users_controller_spec.rb

@ -28,7 +28,7 @@ describe Admin::AdminUsersController, type: :controller do
let(:params) { { admin_user: { email: "test2@example.com", password: "pAssword1", phone: "07566126368" } } } let(:params) { { admin_user: { email: "test2@example.com", password: "pAssword1", phone: "07566126368" } } }
it "creates a new admin user" do it "creates a new admin user" do
expect { post :create, session: valid_session, params: params }.to change(AdminUser, :count).by(1) expect { post :create, session: valid_session, params: }.to change(AdminUser, :count).by(1)
end end
it "tracks who created the record" do it "tracks who created the record" do
@ -59,7 +59,7 @@ describe Admin::AdminUsersController, type: :controller do
let(:params) { { id: admin_user.id, admin_user: { email: } } } let(:params) { { id: admin_user.id, admin_user: { email: } } }
before do before do
patch :update, session: valid_session, params: params patch :update, session: valid_session, params:
end end
it "updates the user without needing to input a password" do it "updates the user without needing to input a password" do

4
spec/controllers/admin/case_logs_controller_spec.rb

@ -40,7 +40,7 @@ describe Admin::CaseLogsController, type: :controller do
end end
it "creates a new case log" do it "creates a new case log" do
expect { post :create, session: valid_session, params: params }.to change(CaseLog, :count).by(1) expect { post :create, session: valid_session, params: }.to change(CaseLog, :count).by(1)
end end
it "tracks who created the record" do it "tracks who created the record" do
@ -71,7 +71,7 @@ describe Admin::CaseLogsController, type: :controller do
let(:params) { { id: case_log.id, case_log: { tenant_code: } } } let(:params) { { id: case_log.id, case_log: { tenant_code: } } }
before do before do
patch :update, session: valid_session, params: params patch :update, session: valid_session, params:
end end
it "updates the case log" do it "updates the case log" do

4
spec/controllers/admin/organisations_controller_spec.rb

@ -29,7 +29,7 @@ describe Admin::OrganisationsController, type: :controller do
let(:params) { { organisation: { name: "DLUHC", provider_type: "LA" } } } let(:params) { { organisation: { name: "DLUHC", provider_type: "LA" } } }
it "creates a organisation" do it "creates a organisation" do
expect { post :create, session: valid_session, params: params }.to change(Organisation, :count).by(1) expect { post :create, session: valid_session, params: }.to change(Organisation, :count).by(1)
end end
it "tracks who created the record" do it "tracks who created the record" do
@ -59,7 +59,7 @@ describe Admin::OrganisationsController, type: :controller do
let(:params) { { id: organisation.id, organisation: { name: } } } let(:params) { { id: organisation.id, organisation: { name: } } }
before do before do
patch :update, session: valid_session, params: params patch :update, session: valid_session, params:
end end
it "updates the organisation" do it "updates the organisation" do

4
spec/controllers/admin/users_controller_spec.rb

@ -40,7 +40,7 @@ describe Admin::UsersController, type: :controller do
end end
it "creates a new user" do it "creates a new user" do
expect { post :create, session: valid_session, params: params }.to change(User, :count).by(1) expect { post :create, session: valid_session, params: }.to change(User, :count).by(1)
end end
it "tracks who created the record" do it "tracks who created the record" do
@ -73,7 +73,7 @@ describe Admin::UsersController, type: :controller do
let(:params) { { id: user.id, user: { name: } } } let(:params) { { id: user.id, user: { name: } } }
before do before do
patch :update, session: valid_session, params: params patch :update, session: valid_session, params:
end end
it "updates the user without needing to input a password" do it "updates the user without needing to input a password" do

2
spec/helpers/question_view_helper_spec.rb

@ -48,7 +48,7 @@ RSpec.describe QuestionViewHelper do
let(:size) { "m" } let(:size) { "m" }
let(:tag) { "h2" } let(:tag) { "h2" }
let(:legend_options_hash) do let(:legend_options_hash) do
{ text: "Some question header".html_safe, size: size, tag: tag } { text: "Some question header".html_safe, size:, tag: }
end end
context "when viewing a page with a header" do context "when viewing a page with a header" do

4
spec/requests/auth/passwords_controller_spec.rb

@ -139,7 +139,7 @@ RSpec.describe Auth::PasswordsController, type: :request do
it "triggers an email" do it "triggers an email" do
expect(notify_client).to receive(:send_email) expect(notify_client).to receive(:send_email)
put "/admin/password", headers: headers, params: params put "/admin/password", headers:, params:
end end
end end
end end
@ -211,7 +211,7 @@ RSpec.describe Auth::PasswordsController, type: :request do
it "triggers an email" do it "triggers an email" do
expect(notify_client).to receive(:send_email) expect(notify_client).to receive(:send_email)
put "/account/password", headers: headers, params: params put "/account/password", headers:, params:
end end
end end
end end

2
spec/requests/bulk_upload_controller_spec.rb

@ -14,7 +14,7 @@ RSpec.describe BulkUploadController, type: :request do
context "when a user is not signed in" do context "when a user is not signed in" do
describe "GET #show" do describe "GET #show" do
before { get url, headers: headers, params: {} } before { get url, headers:, params: {} }
it "does not let you see the bulk upload page" do it "does not let you see the bulk upload page" do
expect(response).to redirect_to("/account/sign-in") expect(response).to redirect_to("/account/sign-in")

30
spec/requests/case_logs_controller_spec.rb

@ -47,7 +47,7 @@ RSpec.describe CaseLogsController, type: :request do
end end
before do before do
post "/logs", headers: headers, params: params.to_json post "/logs", headers:, params: params.to_json
end end
it "returns http success" do it "returns http success" do
@ -124,7 +124,7 @@ RSpec.describe CaseLogsController, type: :request do
before do before do
RequestHelper.stub_http_requests RequestHelper.stub_http_requests
sign_in user sign_in user
post "/logs", headers: headers post "/logs", headers:
end end
it "tracks who created the record" do it "tracks who created the record" do
@ -289,7 +289,7 @@ RSpec.describe CaseLogsController, type: :request do
context "when there are less than 20 logs" do context "when there are less than 20 logs" do
before do before do
get "/logs", headers: headers, params: {} get "/logs", headers:, params: {}
end end
it "shows a table of logs" do it "shows a table of logs" do
@ -342,7 +342,7 @@ RSpec.describe CaseLogsController, type: :request do
context "when on the first page" do context "when on the first page" do
before do before do
get "/logs", headers: headers, params: {} get "/logs", headers:, params: {}
end end
it "has pagination links" do it "has pagination links" do
@ -363,7 +363,7 @@ RSpec.describe CaseLogsController, type: :request do
context "when on the second page" do context "when on the second page" do
before do before do
get "/logs?page=2", headers: headers, params: {} get "/logs?page=2", headers:, params: {}
end end
it "shows the total log count" do it "shows the total log count" do
@ -394,7 +394,7 @@ RSpec.describe CaseLogsController, type: :request do
let(:id) { completed_case_log.id } let(:id) { completed_case_log.id }
before do before do
get "/logs/#{id}", headers: headers get "/logs/#{id}", headers:
end end
it "returns http success" do it "returns http success" do
@ -428,7 +428,7 @@ RSpec.describe CaseLogsController, type: :request do
context "with case logs that are owned or managed by your organisation" do context "with case logs that are owned or managed by your organisation" do
before do before do
sign_in user sign_in user
get "/logs/#{case_log.id}", headers: headers, params: {} get "/logs/#{case_log.id}", headers:, params: {}
end end
it "shows the tasklist for case logs you have access to" do it "shows the tasklist for case logs you have access to" do
@ -455,7 +455,7 @@ RSpec.describe CaseLogsController, type: :request do
before do before do
sign_in user sign_in user
get "/logs/#{section_completed_case_log.id}", headers: headers, params: {} get "/logs/#{section_completed_case_log.id}", headers:, params: {}
end end
it "displays a section status for a case log" do it "displays a section status for a case log" do
@ -468,7 +468,7 @@ RSpec.describe CaseLogsController, type: :request do
context "with case logs that are not owned or managed by your organisation" do context "with case logs that are not owned or managed by your organisation" do
before do before do
sign_in user sign_in user
get "/logs/#{unauthorized_case_log.id}", headers: headers, params: {} get "/logs/#{unauthorized_case_log.id}", headers:, params: {}
end end
it "does not show the tasklist for case logs you don't have access to" do it "does not show the tasklist for case logs you don't have access to" do
@ -548,7 +548,7 @@ RSpec.describe CaseLogsController, type: :request do
:completed, :completed,
owning_organisation: organisation, owning_organisation: organisation,
managing_organisation: organisation) managing_organisation: organisation)
get "/logs", headers: headers, params: {} get "/logs", headers:, params: {}
end end
it "downloads a CSV file with headers" do it "downloads a CSV file with headers" do
@ -578,7 +578,7 @@ RSpec.describe CaseLogsController, type: :request do
before do before do
sign_in user sign_in user
FactoryBot.create_list(:case_log, 26, owning_organisation: organisation) FactoryBot.create_list(:case_log, 26, owning_organisation: organisation)
get "/logs", headers: headers, params: {} get "/logs", headers:, params: {}
end end
it "does not paginate, it downloads all the user's logs" do it "does not paginate, it downloads all the user's logs" do
@ -598,7 +598,7 @@ RSpec.describe CaseLogsController, type: :request do
let(:id) { case_log.id } let(:id) { case_log.id }
before do before do
patch "/logs/#{id}", headers: headers, params: params.to_json patch "/logs/#{id}", headers:, params: params.to_json
end end
it "returns http success" do it "returns http success" do
@ -656,7 +656,7 @@ RSpec.describe CaseLogsController, type: :request do
let(:id) { case_log.id } let(:id) { case_log.id }
before do before do
put "/logs/#{id}", headers: headers, params: params.to_json put "/logs/#{id}", headers:, params: params.to_json
end end
it "returns http success" do it "returns http success" do
@ -696,7 +696,7 @@ RSpec.describe CaseLogsController, type: :request do
context "when deleting a case log" do context "when deleting a case log" do
before do before do
delete "/logs/#{id}", headers: headers delete "/logs/#{id}", headers:
end end
it "returns http success" do it "returns http success" do
@ -730,7 +730,7 @@ RSpec.describe CaseLogsController, type: :request do
before do before do
allow(CaseLog).to receive(:find_by).and_return(case_log) allow(CaseLog).to receive(:find_by).and_return(case_log)
allow(case_log).to receive(:delete).and_return(false) allow(case_log).to receive(:delete).and_return(false)
delete "/logs/#{id}", headers: headers delete "/logs/#{id}", headers:
end end
it "returns an unprocessable entity 422" do it "returns an unprocessable entity 422" do

6
spec/requests/content_controller_spec.rb

@ -6,7 +6,7 @@ RSpec.describe ContentController, type: :request do
describe "render privacy notice content page" do describe "render privacy notice content page" do
before do before do
get "/privacy-notice", headers: headers, params: {} get "/privacy-notice", headers:, params: {}
end end
it "returns a 200" do it "returns a 200" do
@ -20,7 +20,7 @@ RSpec.describe ContentController, type: :request do
describe "render accessibility statement content page" do describe "render accessibility statement content page" do
before do before do
get "/accessibility-statement", headers: headers, params: {} get "/accessibility-statement", headers:, params: {}
end end
it "returns a 200" do it "returns a 200" do
@ -34,7 +34,7 @@ RSpec.describe ContentController, type: :request do
describe "render data sharing agreement" do describe "render data sharing agreement" do
before do before do
get "/data-sharing-agreement", headers: headers, params: {} get "/data-sharing-agreement", headers:, params: {}
end end
it "returns a 200" do it "returns a 200" do

2
spec/requests/form_controller_spec.rb

@ -131,7 +131,7 @@ RSpec.describe FormController, type: :request do
end end
before do before do
post "/logs/#{case_log.id}/form", params: params post "/logs/#{case_log.id}/form", params:
end end
context "with invalid answers" do context "with invalid answers" do

30
spec/requests/organisations_controller_spec.rb

@ -33,7 +33,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}", headers: headers, params: {} get "/organisations/#{organisation.id}", headers:, params: {}
end end
it "redirects to details" do it "redirects to details" do
@ -44,7 +44,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do
before do before do
sign_in user sign_in user
get "/organisations/#{unauthorised_organisation.id}", headers: headers, params: {} get "/organisations/#{unauthorised_organisation.id}", headers:, params: {}
end end
it "returns not found 404 from org route" do it "returns not found 404 from org route" do
@ -62,7 +62,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/details", headers: headers, params: {} get "/organisations/#{organisation.id}/details", headers:, params: {}
end end
it "shows the tab navigation" do it "shows the tab navigation" do
@ -90,7 +90,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with organisation that are not in scope for the user, i.e. that they do not belong to" do context "with organisation that are not in scope for the user, i.e. that they do not belong to" do
before do before do
sign_in user sign_in user
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} get "/organisations/#{unauthorised_organisation.id}/details", headers:, params: {}
end end
it "returns not found 404 from org details route" do it "returns not found 404 from org details route" do
@ -103,7 +103,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/users", headers: headers, params: {} get "/organisations/#{organisation.id}/users", headers:, params: {}
end end
it "shows the tab navigation" do it "shows the tab navigation" do
@ -130,7 +130,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do context "with an organisation that are not in scope for the user, i.e. that they do not belong to" do
before do before do
sign_in user sign_in user
get "/organisations/#{unauthorised_organisation.id}/users", headers: headers, params: {} get "/organisations/#{unauthorised_organisation.id}/users", headers:, params: {}
end end
it "returns not found 404 from users page" do it "returns not found 404 from users page" do
@ -143,7 +143,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/edit", headers: headers, params: {} get "/organisations/#{organisation.id}/edit", headers:, params: {}
end end
it "shows an edit form" do it "shows an edit form" do
@ -156,7 +156,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user does not belong to" do context "with an organisation that the user does not belong to" do
before do before do
sign_in user sign_in user
get "/organisations/#{unauthorised_organisation.id}/edit", headers: headers, params: {} get "/organisations/#{unauthorised_organisation.id}/edit", headers:, params: {}
end end
it "returns a 404 not found" do it "returns a 404 not found" do
@ -169,7 +169,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
patch "/organisations/#{organisation.id}", headers: headers, params: params patch "/organisations/#{organisation.id}", headers:, params:
end end
it "updates the org" do it "updates the org" do
@ -197,7 +197,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user does not belong to" do context "with an organisation that the user does not belong to" do
before do before do
sign_in user sign_in user
patch "/organisations/#{unauthorised_organisation.id}", headers: headers, params: {} patch "/organisations/#{unauthorised_organisation.id}", headers:, params: {}
end end
it "returns a 404 not found" do it "returns a 404 not found" do
@ -214,7 +214,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/details", headers: headers, params: {} get "/organisations/#{organisation.id}/details", headers:, params: {}
end end
it "shows the tab navigation" do it "shows the tab navigation" do
@ -242,7 +242,7 @@ RSpec.describe OrganisationsController, type: :request do
context "with an organisation that is not in scope for the user, i.e. that they do not belong to" do context "with an organisation that is not in scope for the user, i.e. that they do not belong to" do
before do before do
sign_in user sign_in user
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} get "/organisations/#{unauthorised_organisation.id}/details", headers:, params: {}
end end
it "returns not found 404" do it "returns not found 404" do
@ -254,7 +254,7 @@ RSpec.describe OrganisationsController, type: :request do
context "when accessing the users tab" do context "when accessing the users tab" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/users", headers: headers, params: {} get "/organisations/#{organisation.id}/users", headers:, params: {}
end end
it "returns 200" do it "returns 200" do
@ -265,7 +265,7 @@ RSpec.describe OrganisationsController, type: :request do
describe "#edit" do describe "#edit" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}/edit", headers: headers, params: {} get "/organisations/#{organisation.id}/edit", headers:, params: {}
end end
it "redirects to home" do it "redirects to home" do
@ -276,7 +276,7 @@ RSpec.describe OrganisationsController, type: :request do
describe "#update" do describe "#update" do
before do before do
sign_in user sign_in user
patch "/organisations/#{organisation.id}", headers: headers, params: params patch "/organisations/#{organisation.id}", headers:, params:
end end
it "redirects to home" do it "redirects to home" do

92
spec/requests/users_controller_spec.rb

@ -63,7 +63,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
put "/account", headers: headers, params: params put "/account", headers:, params:
end end
it "shows an error if passwords don't match" do it "shows an error if passwords don't match" do
@ -89,7 +89,7 @@ RSpec.describe UsersController, type: :request do
before do before do
allow(User).to receive(:find_or_initialize_with_error_by).and_return(user) allow(User).to receive(:find_or_initialize_with_error_by).and_return(user)
allow(user).to receive(:reset_password_sent_at).and_return(4.hours.ago) allow(user).to receive(:reset_password_sent_at).and_return(4.hours.ago)
put "/account/password", headers: headers, params: params put "/account/password", headers:, params:
end end
it "shows an error" do it "shows an error" do
@ -115,7 +115,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}", headers: headers, params: {} get "/users/#{user.id}", headers:, params: {}
end end
it "show the user details" do it "show the user details" do
@ -135,7 +135,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}", headers: headers, params: {} get "/users/#{other_user.id}", headers:, params: {}
end end
context "when the user is part of the same organisation" do context "when the user is part of the same organisation" do
@ -172,7 +172,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}/edit", headers: headers, params: {} get "/users/#{user.id}/edit", headers:, params: {}
end end
it "show the edit personal details page" do it "show the edit personal details page" do
@ -191,7 +191,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}/edit", headers: headers, params: {} get "/users/#{other_user.id}/edit", headers:, params: {}
end end
it "returns not found 404" do it "returns not found 404" do
@ -204,7 +204,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/account/edit/password", headers: headers, params: {} get "/account/edit/password", headers:, params: {}
end end
it "shows the edit password page" do it "shows the edit password page" do
@ -219,7 +219,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}/edit", headers: headers, params: {} get "/users/#{other_user.id}/edit", headers:, params: {}
end end
it "returns not found 404" do it "returns not found 404" do
@ -232,7 +232,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "updates the user" do it "updates the user" do
@ -264,7 +264,7 @@ RSpec.describe UsersController, type: :request do
sign_in user sign_in user
allow(User).to receive(:find_by).and_return(user) allow(User).to receive(:find_by).and_return(user)
allow(user).to receive(:update).and_return(false) allow(user).to receive(:update).and_return(false)
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "show an error" do it "show an error" do
@ -277,7 +277,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
patch "/users/#{other_user.id}", headers: headers, params: params patch "/users/#{other_user.id}", headers:, params:
end end
it "returns not found 404" do it "returns not found 404" do
@ -294,7 +294,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "shows an error if passwords don't match" do it "shows an error if passwords don't match" do
@ -314,7 +314,7 @@ RSpec.describe UsersController, type: :request do
}, },
} }
end end
let(:request) { post "/users/", headers: headers, params: params } let(:request) { post "/users/", headers:, params: }
before do before do
sign_in user sign_in user
@ -339,7 +339,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}", headers: headers, params: {} get "/users/#{user.id}", headers:, params: {}
end end
it "show the user details" do it "show the user details" do
@ -359,7 +359,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}", headers: headers, params: {} get "/users/#{other_user.id}", headers:, params: {}
end end
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
@ -399,7 +399,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}/edit", headers: headers, params: {} get "/users/#{user.id}/edit", headers:, params: {}
end end
it "show the edit personal details page" do it "show the edit personal details page" do
@ -422,7 +422,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}/edit", headers: headers, params: {} get "/users/#{other_user.id}/edit", headers:, params: {}
end end
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
@ -457,7 +457,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/account/edit/password", headers: headers, params: {} get "/account/edit/password", headers:, params: {}
end end
it "shows the edit password page" do it "shows the edit password page" do
@ -476,7 +476,7 @@ RSpec.describe UsersController, type: :request do
it "there is no route" do it "there is no route" do
expect { expect {
get "/users/#{other_user.id}/password/edit", headers: headers, params: {} get "/users/#{other_user.id}/password/edit", headers:, params: {}
}.to raise_error(ActionController::RoutingError) }.to raise_error(ActionController::RoutingError)
end end
end end
@ -486,7 +486,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "updates the user" do it "updates the user" do
@ -521,7 +521,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "shows an error if passwords don't match" do it "shows an error if passwords don't match" do
@ -538,12 +538,12 @@ RSpec.describe UsersController, type: :request do
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
it "updates the user" do it "updates the user" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from(other_user.name).to(new_name) .to change { other_user.reload.name }.from(other_user.name).to(new_name)
end end
it "tracks who updated the record" do it "tracks who updated the record" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id) .to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id)
end end
@ -574,12 +574,12 @@ RSpec.describe UsersController, type: :request do
end end
it "does not update the password" do it "does not update the password" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.not_to change(other_user, :encrypted_password) .not_to change(other_user, :encrypted_password)
end end
it "does update other values" do it "does update other values" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from("Danny Rojas").to("new name") .to change { other_user.reload.name }.from("Danny Rojas").to("new name")
end end
end end
@ -592,7 +592,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
patch "/users/#{other_user.id}", headers: headers, params: params patch "/users/#{other_user.id}", headers:, params:
end end
it "returns not found 404" do it "returns not found 404" do
@ -607,7 +607,7 @@ RSpec.describe UsersController, type: :request do
sign_in user sign_in user
allow(User).to receive(:find_by).and_return(user) allow(User).to receive(:find_by).and_return(user)
allow(user).to receive(:update).and_return(false) allow(user).to receive(:update).and_return(false)
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "show an error" do it "show an error" do
@ -627,7 +627,7 @@ RSpec.describe UsersController, type: :request do
}, },
} }
end end
let(:request) { post "/users/", headers: headers, params: params } let(:request) { post "/users/", headers:, params: }
before do before do
sign_in user sign_in user
@ -697,7 +697,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}", headers: headers, params: {} get "/users/#{user.id}", headers:, params: {}
end end
it "show the user details" do it "show the user details" do
@ -717,7 +717,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}", headers: headers, params: {} get "/users/#{other_user.id}", headers:, params: {}
end end
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
@ -766,7 +766,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{user.id}/edit", headers: headers, params: {} get "/users/#{user.id}/edit", headers:, params: {}
end end
it "show the edit personal details page" do it "show the edit personal details page" do
@ -789,7 +789,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user does not match the user ID" do context "when the current user does not match the user ID" do
before do before do
sign_in user sign_in user
get "/users/#{other_user.id}/edit", headers: headers, params: {} get "/users/#{other_user.id}/edit", headers:, params: {}
end end
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
@ -836,7 +836,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
get "/account/edit/password", headers: headers, params: {} get "/account/edit/password", headers:, params: {}
end end
it "shows the edit password page" do it "shows the edit password page" do
@ -855,7 +855,7 @@ RSpec.describe UsersController, type: :request do
it "there is no route" do it "there is no route" do
expect { expect {
get "/users/#{other_user.id}/password/edit", headers: headers, params: {} get "/users/#{other_user.id}/password/edit", headers:, params: {}
}.to raise_error(ActionController::RoutingError) }.to raise_error(ActionController::RoutingError)
end end
end end
@ -865,7 +865,7 @@ RSpec.describe UsersController, type: :request do
context "when the current user matches the user ID" do context "when the current user matches the user ID" do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "updates the user" do it "updates the user" do
@ -900,7 +900,7 @@ RSpec.describe UsersController, type: :request do
before do before do
sign_in user sign_in user
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "shows an error if passwords don't match" do it "shows an error if passwords don't match" do
@ -917,12 +917,12 @@ RSpec.describe UsersController, type: :request do
context "when the user is part of the same organisation as the current user" do context "when the user is part of the same organisation as the current user" do
it "updates the user" do it "updates the user" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from(other_user.name).to(new_name) .to change { other_user.reload.name }.from(other_user.name).to(new_name)
end end
it "tracks who updated the record" do it "tracks who updated the record" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id) .to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id)
end end
@ -953,12 +953,12 @@ RSpec.describe UsersController, type: :request do
end end
it "does not update the password" do it "does not update the password" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.not_to change(other_user, :encrypted_password) .not_to change(other_user, :encrypted_password)
end end
it "does update other values" do it "does update other values" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from("Danny Rojas").to("new name") .to change { other_user.reload.name }.from("Danny Rojas").to("new name")
end end
end end
@ -974,12 +974,12 @@ RSpec.describe UsersController, type: :request do
end end
it "updates the user" do it "updates the user" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from(other_user.name).to(new_name) .to change { other_user.reload.name }.from(other_user.name).to(new_name)
end end
it "tracks who updated the record" do it "tracks who updated the record" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id) .to change { other_user.reload.versions.last.actor&.id }.from(nil).to(user.id)
end end
@ -1010,12 +1010,12 @@ RSpec.describe UsersController, type: :request do
end end
it "does not update the password" do it "does not update the password" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.not_to change(other_user, :encrypted_password) .not_to change(other_user, :encrypted_password)
end end
it "does update other values" do it "does update other values" do
expect { patch "/users/#{other_user.id}", headers: headers, params: params } expect { patch "/users/#{other_user.id}", headers:, params: }
.to change { other_user.reload.name }.from("Danny Rojas").to("new name") .to change { other_user.reload.name }.from("Danny Rojas").to("new name")
end end
end end
@ -1028,7 +1028,7 @@ RSpec.describe UsersController, type: :request do
sign_in user sign_in user
allow(User).to receive(:find_by).and_return(user) allow(User).to receive(:find_by).and_return(user)
allow(user).to receive(:update).and_return(false) allow(user).to receive(:update).and_return(false)
patch "/users/#{user.id}", headers: headers, params: params patch "/users/#{user.id}", headers:, params:
end end
it "show an error" do it "show an error" do
@ -1047,7 +1047,7 @@ RSpec.describe UsersController, type: :request do
}, },
} }
end end
let(:request) { post "/users/", headers: headers, params: params } let(:request) { post "/users/", headers:, params: }
before do before do
sign_in user sign_in user

2
spec/views/form/page_view_spec.rb

@ -35,7 +35,7 @@ RSpec.describe "form/page" do
context "with a page containing a description" do context "with a page containing a description" do
let(:description) { "Test description <a class=\"govuk-link\" href=\"/test-link\">with link</a>." } let(:description) { "Test description <a class=\"govuk-link\" href=\"/test-link\">with link</a>." }
let(:page_attributes) { { description: description } } let(:page_attributes) { { description: } }
let(:expected_html) { '<p class="govuk-body govuk-body-m">Test description <a class="govuk-link" href="/test-link">with link</a>.</p>' } let(:expected_html) { '<p class="govuk-body govuk-body-m">Test description <a class="govuk-link" href="/test-link">with link</a>.</p>' }
it "renders the description" do it "renders the description" do

Loading…
Cancel
Save