From 5243e4e8fd3d9d20b8e7f69e8da201579ee83099 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:04:04 -0400 Subject: [PATCH 01/14] build(deps): bump trix from 2.1.2 to 2.1.3 (#5933) Bumps [trix](https://github.com/basecamp/trix) from 2.1.2 to 2.1.3. - [Release notes](https://github.com/basecamp/trix/releases) - [Commits](https://github.com/basecamp/trix/compare/v2.1.2...2.1.3) --- updated-dependencies: - dependency-name: trix dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 31 +++++-------------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index d516830605..d0fe781c86 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "strftime": "^0.10.3", "sweetalert2": "^11.3.5", "tom-select": "^2.3.1", - "trix": "^2.1.2", + "trix": "^2.1.3", "turbolinks": "^5.2.0" }, "version": "0.1.0", diff --git a/yarn.lock b/yarn.lock index ad0aaeec84..2662eefc3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,11 +23,6 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.24.9.tgz#53eee4e68f1c1d0282aa0eb05ddb02d033fc43a0" integrity sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng== -"@babel/compat-data@^7.24.8": - version "7.24.9" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.24.9.tgz#53eee4e68f1c1d0282aa0eb05ddb02d033fc43a0" - integrity sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng== - "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.24.9": version "7.24.9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.24.9.tgz#dc07c9d307162c97fa9484ea997ade65841c7c82" @@ -173,18 +168,7 @@ "@babel/traverse" "^7.24.7" "@babel/types" "^7.24.7" -"@babel/helper-module-transforms@^7.24.7", "@babel/helper-module-transforms@^7.24.9": - version "7.24.9" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz#e13d26306b89eea569180868e652e7f514de9d29" - integrity sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw== - dependencies: - "@babel/helper-environment-visitor" "^7.24.7" - "@babel/helper-module-imports" "^7.24.7" - "@babel/helper-simple-access" "^7.24.7" - "@babel/helper-split-export-declaration" "^7.24.7" - "@babel/helper-validator-identifier" "^7.24.7" - -"@babel/helper-module-transforms@^7.24.8": +"@babel/helper-module-transforms@^7.24.7", "@babel/helper-module-transforms@^7.24.8", "@babel/helper-module-transforms@^7.24.9": version "7.24.9" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz#e13d26306b89eea569180868e652e7f514de9d29" integrity sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw== @@ -263,11 +247,6 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz#3725cdeea8b480e86d34df15304806a06975e33d" integrity sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q== -"@babel/helper-validator-option@^7.24.8": - version "7.24.8" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz#3725cdeea8b480e86d34df15304806a06975e33d" - integrity sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q== - "@babel/helper-wrap-function@^7.24.7": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.24.7.tgz#52d893af7e42edca7c6d2c6764549826336aae1f" @@ -5428,10 +5407,10 @@ tr46@^3.0.0: dependencies: punycode "^2.1.1" -trix@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/trix/-/trix-2.1.2.tgz#8185fa7e12d6cbee93db7f149907b3f7a79b3704" - integrity sha512-PsQC4qn1Ub0djn7FZ9KLzEC2whE1J27JiRycn5WddlVT8JgwKq5PtlXo6rRfjc7Qj2aSzIdjkApai9zAW7/IRA== +trix@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/trix/-/trix-2.1.3.tgz#38c8725cd1864ca5e9784aed7d043fa11669ba81" + integrity sha512-LqMp67LiKMQytAHKqNL1Jgmfz69ViW+WBOQTPA2BlMIuxic1mw5vHgDtOE0bvvojUdjAxh0EJtLpJn6BC/2JKw== tsconfig-paths@^3.14.1: version "3.14.1" From 688fe091698987ec04a67d1b0390a4f7ebabb995 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:04:26 -0400 Subject: [PATCH 02/14] build(deps): bump @fortawesome/fontawesome-free from 6.5.2 to 6.6.0 (#5932) Bumps [@fortawesome/fontawesome-free](https://github.com/FortAwesome/Font-Awesome) from 6.5.2 to 6.6.0. - [Release notes](https://github.com/FortAwesome/Font-Awesome/releases) - [Changelog](https://github.com/FortAwesome/Font-Awesome/blob/6.x/CHANGELOG.md) - [Commits](https://github.com/FortAwesome/Font-Awesome/compare/6.5.2...6.6.0) --- updated-dependencies: - dependency-name: "@fortawesome/fontawesome-free" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d0fe781c86..caacb5f833 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@babel/core": "^7.24.9", - "@fortawesome/fontawesome-free": "^6.5.2", + "@fortawesome/fontawesome-free": "^6.6.0", "@hotwired/stimulus": "^3.2.2", "@popperjs/core": "^2.11.8", "@rails/actioncable": "^7.1.3", diff --git a/yarn.lock b/yarn.lock index 2662eefc3d..ece1da990d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1146,10 +1146,10 @@ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.43.0.tgz#559ca3d9ddbd6bf907ad524320a0d14b85586af0" integrity sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg== -"@fortawesome/fontawesome-free@^6.5.2": - version "6.5.2" - resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.2.tgz#310fe90cb5a8dee9698833171b98e7835404293d" - integrity sha512-hRILoInAx8GNT5IMkrtIt9blOdrqHOnPBH+k70aWUAqPZPgopb9G5EQJFpaBx/S8zp2fC+mPW349Bziuk1o28Q== +"@fortawesome/fontawesome-free@^6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.6.0.tgz#0e984f0f2344ee513c185d87d77defac4c0c8224" + integrity sha512-60G28ke/sXdtS9KZCpZSHHkCbdsOGEhIUGlwq6yhY74UpTiToIh8np7A8yphhM4BWsvNFtIvLpi4co+h9Mr9Ow== "@hapi/hoek@^9.0.0": version "9.3.0" From 69f7c23c0b15139262dd7a3ea232d5ee452ac2cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:07:01 -0400 Subject: [PATCH 03/14] build(deps-dev): bump database_cleaner-active_record from 2.1.0 to 2.2.0 (#5936) Bumps [database_cleaner-active_record](https://github.com/DatabaseCleaner/database_cleaner-active_record) from 2.1.0 to 2.2.0. - [Changelog](https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/main/CHANGELOG.md) - [Commits](https://github.com/DatabaseCleaner/database_cleaner-active_record/compare/v2.1.0...v2.2.0) --- updated-dependencies: - dependency-name: database_cleaner-active_record dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0f39f6bca7..ce7f693dcd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,7 +153,7 @@ GEM cssbundling-rails (1.4.0) railties (>= 6.0.0) csv (3.3.0) - database_cleaner-active_record (2.1.0) + database_cleaner-active_record (2.2.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) From 7d4d66e6be93842c4aaefe087afae453b1208c13 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:07:37 -0400 Subject: [PATCH 04/14] build(deps-dev): bump selenium-webdriver from 4.22.0 to 4.23.0 (#5937) Bumps [selenium-webdriver](https://github.com/SeleniumHQ/selenium) from 4.22.0 to 4.23.0. - [Release notes](https://github.com/SeleniumHQ/selenium/releases) - [Changelog](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES) - [Commits](https://github.com/SeleniumHQ/selenium/compare/selenium-4.22.0...selenium-4.23.0) --- updated-dependencies: - dependency-name: selenium-webdriver dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ce7f693dcd..fd47c2f9f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -486,7 +486,7 @@ GEM nokogiri (>= 1.12.0) scout_apm (5.3.8) parser - selenium-webdriver (4.22.0) + selenium-webdriver (4.23.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -557,7 +557,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.8.1) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) From 04a07e9dfb929250ca1503d980e8891936bd39da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:26:56 -0400 Subject: [PATCH 05/14] build(deps-dev): bump dotenv-rails from 2.8.1 to 3.1.2 (#5713) Bumps [dotenv-rails](https://github.com/bkeepers/dotenv) from 2.8.1 to 3.1.2. - [Release notes](https://github.com/bkeepers/dotenv/releases) - [Changelog](https://github.com/bkeepers/dotenv/blob/main/Changelog.md) - [Commits](https://github.com/bkeepers/dotenv/compare/v2.8.1...v3.1.2) --- updated-dependencies: - dependency-name: dotenv-rails dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fd47c2f9f4..96ccf21e84 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,10 +177,10 @@ GEM docx (0.8.0) nokogiri (~> 1.13, >= 1.13.0) rubyzip (~> 2.0) - dotenv (2.8.1) - dotenv-rails (2.8.1) - dotenv (= 2.8.1) - railties (>= 3.2) + dotenv (3.1.2) + dotenv-rails (3.1.2) + dotenv (= 3.1.2) + railties (>= 6.1) draper (4.0.2) actionpack (>= 5.0) activemodel (>= 5.0) From 0c30c3fb771226ef3aac4391a82f5777b7bf0889 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:28:18 -0400 Subject: [PATCH 06/14] build(deps): bump faker from 3.4.1 to 3.4.2 (#5935) Bumps [faker](https://github.com/faker-ruby/faker) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/faker-ruby/faker/releases) - [Changelog](https://github.com/faker-ruby/faker/blob/main/CHANGELOG.md) - [Commits](https://github.com/faker-ruby/faker/compare/v3.4.1...v3.4.2) --- updated-dependencies: - dependency-name: faker dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 96ccf21e84..ab6ef87aad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -206,7 +206,7 @@ GEM factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) - faker (3.4.1) + faker (3.4.2) i18n (>= 1.8.11, < 2) faraday (1.10.3) faraday-em_http (~> 1.0) From c8e5a8931b72524915f0984e4f4403492774d737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kerim=20Mand=C5=BEo?= <63257395+Kerman07@users.noreply.github.com> Date: Wed, 24 Jul 2024 02:36:46 +0200 Subject: [PATCH 07/14] Fix N+1 issues in casa_cases#show (#5939) Fix N+1 issues in casa_cases#show #5893 --- app/models/case_contact.rb | 2 +- app/views/casa_cases/show.html.erb | 14 ++++++++++++-- spec/models/case_contact_spec.rb | 12 ++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/models/case_contact.rb b/app/models/case_contact.rb index 37696fc9f3..775b453d91 100644 --- a/app/models/case_contact.rb +++ b/app/models/case_contact.rb @@ -233,7 +233,7 @@ def has_casa_case_transitioned def contact_groups_with_types hash = Hash.new { |h, k| h[k] = [] } - contact_types.each do |contact_type| + contact_types.includes(:contact_type_group).each do |contact_type| hash[contact_type.contact_type_group.name] << contact_type.name end hash diff --git a/app/views/casa_cases/show.html.erb b/app/views/casa_cases/show.html.erb index d7c04eabb2..cc895bdb95 100644 --- a/app/views/casa_cases/show.html.erb +++ b/app/views/casa_cases/show.html.erb @@ -130,14 +130,24 @@ <%= render(partial: "case_contacts/case_contact", collection: @casa_case.decorate .case_contacts_ordered_by_occurred_at - .includes(:contact_types) + .includes( + :creator, + :followups, + :contact_types, + contact_topic_answers: [:contact_topic] + ) .grab_all(current_user), as: :contact) %> <% else %> <%= render(partial: "case_contacts/case_contact", collection: @casa_case.decorate .case_contacts_filtered_by_active_assignment_ordered_by_occurred_at - .includes(:contact_types) + .includes( + :creator, + :followups, + :contact_types, + contact_topic_answers: [:contact_topic] + ) .grab_all(current_user), as: :contact) %> <% end %> diff --git a/spec/models/case_contact_spec.rb b/spec/models/case_contact_spec.rb index 5dd56710d2..dfdca9091e 100644 --- a/spec/models/case_contact_spec.rb +++ b/spec/models/case_contact_spec.rb @@ -551,13 +551,13 @@ describe "#contact_groups_with_types" do it "returns the groups with their associated case types" do - group1 = build_stubbed(:contact_type_group, name: "Family") - group2 = build_stubbed(:contact_type_group, name: "Health") - contact_type1 = build_stubbed(:contact_type, contact_type_group: group1, name: "Parent") - contact_type2 = build_stubbed(:contact_type, contact_type_group: group2, name: "Medical Professional") - contact_type3 = build_stubbed(:contact_type, contact_type_group: group2, name: "Other Therapist") + group1 = build(:contact_type_group, name: "Family") + group2 = build(:contact_type_group, name: "Health") + contact_type1 = build(:contact_type, contact_type_group: group1, name: "Parent") + contact_type2 = build(:contact_type, contact_type_group: group2, name: "Medical Professional") + contact_type3 = build(:contact_type, contact_type_group: group2, name: "Other Therapist") case_contact_types = [contact_type1, contact_type2, contact_type3] - case_contact = build_stubbed(:case_contact) + case_contact = create(:case_contact) case_contact.contact_types = case_contact_types groups_with_types = case_contact.contact_groups_with_types From 12768ed45ccee1cd23066672cd4488c755baabef Mon Sep 17 00:00:00 2001 From: Sarah Smulligan <64047083+Smullz622@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:37:07 -0400 Subject: [PATCH 08/14] change div classes to fix checkbox location (#5938) --- .../volunteers/_send_reminder_button.html.erb | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/volunteers/_send_reminder_button.html.erb b/app/views/volunteers/_send_reminder_button.html.erb index e36dfcaeeb..bb309fcbd9 100644 --- a/app/views/volunteers/_send_reminder_button.html.erb +++ b/app/views/volunteers/_send_reminder_button.html.erb @@ -1,14 +1,16 @@ -<%= button_tag( - type: "submit", - class: "main-btn primary-btn btn-hover btn-sm", - id: "reminder_button", - data_toggle: "tooltip", - title: "Remind volunteer to input case contacts".to_s -) do %> - Send Reminder -<% end %> +
+ <%= button_tag( + type: "submit", + class: "main-btn primary-btn btn-hover btn-sm mr-3", + id: "reminder_button", + data_toggle: "tooltip", + title: "Remind volunteer to input case contacts".to_s + ) do %> + Send Reminder + <% end %> -
- <%= check_box_tag 'with_cc', 1, class: 'form-check-input' %> - <%= label_tag 'with_cc', 'Send CC to Supervisor and Admin', class: 'unbold form-check-label' %> +
+ <%= check_box_tag 'with_cc', 1, false, class: 'form-check-input' %> + <%= label_tag 'with_cc', 'Send CC to Supervisor and Admin', class: 'unbold form-check-label ml-2' %> +
From cc17e69f7cf046adb15a823158f4db83ca64d959 Mon Sep 17 00:00:00 2001 From: Yuri Bocharov Date: Tue, 23 Jul 2024 20:41:33 -0400 Subject: [PATCH 09/14] fix: prevent 500 if attempting to unassign supervisor twice (#5922) --- app/controllers/supervisor_volunteers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/supervisor_volunteers_controller.rb b/app/controllers/supervisor_volunteers_controller.rb index 344af4f849..deb8d8e79a 100644 --- a/app/controllers/supervisor_volunteers_controller.rb +++ b/app/controllers/supervisor_volunteers_controller.rb @@ -17,8 +17,8 @@ def create def unassign authorize :supervisor_volunteer volunteer = Volunteer.find(params[:id]) - supervisor = volunteer.supervisor_volunteer.supervisor if unassign_volunteers_supervisor(volunteer) + supervisor = volunteer.supervisor_volunteer.supervisor flash[:notice] = "#{volunteer.display_name} was unassigned from #{supervisor.display_name}." else flash[:alert] = "Something went wrong. Please try again." From 3cf414ae39a652cbe29f4b6264208632779e1e03 Mon Sep 17 00:00:00 2001 From: Yuri Bocharov Date: Tue, 23 Jul 2024 22:21:05 -0400 Subject: [PATCH 10/14] better tracking of metadata around case contacts (#5929) * refactor: switch to callback to update metadata * fix: case contact drafts validation --- .../case_contact_metadata_callback.rb | 25 +++ .../case_contacts/form_controller.rb | 2 +- app/models/case_contact.rb | 4 +- app/services/case_contact_update_service.rb | 28 --- ...l_case_contact_started_metadata_service.rb | 12 ++ ...ackfill_case_contact_started_metadata.rake | 14 ++ .../case_contact_metadata_callback_spec.rb | 143 ++++++++++++ spec/factories/case_contacts.rb | 9 + spec/models/case_contact_spec.rb | 6 +- .../case_contact_update_service_spec.rb | 203 ------------------ ...e_contact_started_metadata_service_spec.rb | 55 +++++ 11 files changed, 265 insertions(+), 236 deletions(-) create mode 100644 app/callbacks/case_contact_metadata_callback.rb delete mode 100644 app/services/case_contact_update_service.rb create mode 100644 app/services/deployment/backfill_case_contact_started_metadata_service.rb create mode 100644 lib/tasks/deployment/20240720232939_backfill_case_contact_started_metadata.rake create mode 100644 spec/callbacks/case_contact_metadata_callback_spec.rb delete mode 100644 spec/services/case_contact_update_service_spec.rb create mode 100644 spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb diff --git a/app/callbacks/case_contact_metadata_callback.rb b/app/callbacks/case_contact_metadata_callback.rb new file mode 100644 index 0000000000..1fa7f0c15d --- /dev/null +++ b/app/callbacks/case_contact_metadata_callback.rb @@ -0,0 +1,25 @@ +class CaseContactMetadataCallback + def after_commit(case_contact) + changes = case_contact.saved_changes + + set_status(changes, case_contact) if changes["id"] + update_status(changes, case_contact) if changes["status"] && changes["id"].nil? + end + + private + + def set_status(changes, case_contact) + metadata = {"status" => {case_contact.status => case_contact.created_at}} + update_metadata(case_contact, metadata) + end + + def update_status(changes, case_contact) + metadata = {"status" => {changes["status"].last => Time.zone.now}} + update_metadata(case_contact, metadata) + end + + def update_metadata(record, new_data) + metadata = record.metadata.deep_merge(new_data) + record.update_columns(metadata: metadata) + end +end diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb index d988c98bdf..350e2b8bba 100644 --- a/app/controllers/case_contacts/form_controller.rb +++ b/app/controllers/case_contacts/form_controller.rb @@ -24,7 +24,7 @@ def update remove_unwanted_contact_types remove_nil_draft_ids - if CaseContactUpdateService.new(@case_contact).update_attrs(case_contact_params) + if @case_contact.update(case_contact_params) respond_to do |format| format.html { if step == steps.last diff --git a/app/models/case_contact.rb b/app/models/case_contact.rb index 775b453d91..643a57a82e 100644 --- a/app/models/case_contact.rb +++ b/app/models/case_contact.rb @@ -29,7 +29,7 @@ class CaseContact < ApplicationRecord # Draft support requires the casa_case to be nil if the contact is in_progress belongs_to :casa_case, optional: true validates :casa_case_id, presence: true, if: :active? - validate :draft_case_ids_not_empty, if: :active_or_details? + validate :draft_case_ids_not_empty, unless: :started? has_many :case_contact_contact_types has_many :contact_types, through: :case_contact_contact_types @@ -37,6 +37,8 @@ class CaseContact < ApplicationRecord has_many :additional_expenses has_many :contact_topic_answers, dependent: :destroy + after_save_commit ::CaseContactMetadataCallback.new + # Corresponds to the steps in the controller, so validations for certain columns can happen at those steps. # These steps must be listed in order and have an html template in case_contacts/form. FORM_STEPS = %i[details notes expenses].freeze diff --git a/app/services/case_contact_update_service.rb b/app/services/case_contact_update_service.rb deleted file mode 100644 index 3b10d18542..0000000000 --- a/app/services/case_contact_update_service.rb +++ /dev/null @@ -1,28 +0,0 @@ -class CaseContactUpdateService - attr_reader :case_contact - - def initialize(case_contact) - @case_contact = case_contact - end - - def update_attrs(new_attrs) - old_attrs = case_contact.as_json - - result = case_contact.update(new_attrs) - update_status_metadata(old_attrs, new_attrs) if result - - result - end - - private - - def update_status_metadata(old_attrs, new_attrs) - return if old_attrs[:status] == new_attrs[:status] - - metadata = case_contact.metadata - metadata["status"] ||= {} - metadata["status"][new_attrs[:status]] = Time.zone.now - - case_contact.update(metadata: metadata) - end -end diff --git a/app/services/deployment/backfill_case_contact_started_metadata_service.rb b/app/services/deployment/backfill_case_contact_started_metadata_service.rb new file mode 100644 index 0000000000..e193b5e6a2 --- /dev/null +++ b/app/services/deployment/backfill_case_contact_started_metadata_service.rb @@ -0,0 +1,12 @@ +module Deployment + class BackfillCaseContactStartedMetadataService + def backfill_metadata + case_contacts = CaseContact.where("metadata->'status' IS NOT NULL AND metadata->'status'->'started' IS NULL") + + case_contacts.each do |case_contact| + case_contact.metadata["status"]["started"] = case_contact.created_at.as_json + case_contact.save! + end + end + end +end diff --git a/lib/tasks/deployment/20240720232939_backfill_case_contact_started_metadata.rake b/lib/tasks/deployment/20240720232939_backfill_case_contact_started_metadata.rake new file mode 100644 index 0000000000..67e139eadd --- /dev/null +++ b/lib/tasks/deployment/20240720232939_backfill_case_contact_started_metadata.rake @@ -0,0 +1,14 @@ +namespace :after_party do + desc "Deployment task: set metadata for status started to every CaseContact that had status metadata" + task backfill_case_contact_started_metadata: :environment do + puts "Running deploy task 'backfill_case_contact_started_metadata'" + + # Put your task implementation HERE. + Deployment::BackfillCaseContactStartedMetadataService.new.backfill_metadata + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/spec/callbacks/case_contact_metadata_callback_spec.rb b/spec/callbacks/case_contact_metadata_callback_spec.rb new file mode 100644 index 0000000000..a0678dcd63 --- /dev/null +++ b/spec/callbacks/case_contact_metadata_callback_spec.rb @@ -0,0 +1,143 @@ +require "rails_helper" + +RSpec.describe CaseContactMetadataCallback do + let(:past) { Date.new(2020, 1, 1).in_time_zone } + let(:parsed_past) { past.as_json } + + let(:present) { Date.new(2024, 1, 1).in_time_zone } + let(:parsed_present) { present.as_json } + + before { travel_to present } + after { travel_back } + + # NOTE: as you might notice these tests are omitting quite a few cases + # ex: notes => details, expenses => notes. I don't think it is worth dealing + # with metadata surrounding cases that are not processed in the correct order. + # A user would not be able to replicate this behavior. + # + describe "after_commit" do + it "sets started metadata when case contact is created" do + cc = create(:case_contact) + + expect(cc.metadata.dig("status", "active")).to eq(parsed_present) + end + + context "case contact is in started status" do + let(:case_contact) { create(:case_contact, status: "started", created_at: past) } + + context "updates to started status" do + before { case_contact.update(status: "started") } + + it "does not update the metadata" do + expect(case_contact.metadata.dig("status", "started")).to eq(parsed_past) + end + end + + context "updates to details status" do + before { case_contact.update(status: "details") } + + it { expect(case_contact.metadata.dig("status", "details")).to eq(parsed_present) } + end + + context "updates to notes status" do + before { case_contact.update(status: "notes") } + + it { expect(case_contact.metadata.dig("status", "notes")).to eq(parsed_present) } + end + + context "updates to expenses status" do + before { case_contact.update(status: "expenses") } + + it { expect(case_contact.metadata.dig("status", "expenses")).to eq(parsed_present) } + end + + context "updates to active status" do + before { case_contact.update(status: "active") } + + it { expect(case_contact.metadata.dig("status", "active")).to eq(parsed_present) } + end + end + + context "case contact is in details status" do + let(:case_contact) { create(:case_contact, status: "details", created_at: past) } + + context "updates to details status" do + before { case_contact.update(status: "details") } + + it "does not update the metadata" do + expect(case_contact.metadata.dig("status", "details")).to eq(parsed_past) + end + end + + context "updates to notes status" do + before { case_contact.update(status: "notes") } + + it { expect(case_contact.metadata.dig("status", "notes")).to eq(parsed_present) } + end + + context "updates to expenses status" do + before { case_contact.update(status: "expenses") } + + it { expect(case_contact.metadata.dig("status", "expenses")).to eq(parsed_present) } + end + + context "updates to active status" do + before { case_contact.update(status: "active") } + + it { expect(case_contact.metadata.dig("status", "active")).to eq(parsed_present) } + end + end + + context "case contact is in notes status" do + let(:case_contact) { create(:case_contact, status: "notes", created_at: past) } + + context "updates to notes status" do + before { case_contact.update(status: "notes") } + + it { expect(case_contact.metadata.dig("status", "notes")).to eq(parsed_past) } + end + + context "updates to expenses status" do + before { case_contact.update(status: "expenses") } + + it { expect(case_contact.metadata.dig("status", "expenses")).to eq(parsed_present) } + end + + context "updates to active status" do + before { case_contact.update(status: "active") } + + it { expect(case_contact.metadata.dig("status", "active")).to eq(parsed_present) } + end + end + + context "case contact is in expenses status" do + let!(:case_contact) { create(:case_contact, status: "expenses", created_at: past) } + + context "updates to expenses status" do + before { case_contact.update(status: "expenses") } + + it "does not update the metadata" do + expect(case_contact.metadata.dig("status", "expenses")).to eq(parsed_past) + end + end + + context "updates to active status" do + before { case_contact.update(status: "active") } + + it { expect(case_contact.metadata.dig("status", "active")).to eq(parsed_present) } + end + end + + context "case contact is in active status" do + let(:case_contact) { create(:case_contact, created_at: past) } + + context "updates to active status" do + before { case_contact.update(status: "active") } + + it "does not update the metadata" do + expect(case_contact.metadata.dig("status", "active")).to eq(parsed_past) + end + end + end + end +end diff --git a/spec/factories/case_contacts.rb b/spec/factories/case_contacts.rb index 4c2698eb89..35a04e83bd 100644 --- a/spec/factories/case_contacts.rb +++ b/spec/factories/case_contacts.rb @@ -59,6 +59,15 @@ trait :expenses_status do draft_case_ids { [1] } + status { "expenses" } + end + + after(:create) do |case_contact, evaluator| + if evaluator.metadata + case_contact.update_columns(metadata: evaluator.metadata) + elsif case_contact.status + case_contact.update_columns(metadata: {"status" => {case_contact.status => case_contact.created_at}}) + end end trait :with_org_topics do diff --git a/spec/models/case_contact_spec.rb b/spec/models/case_contact_spec.rb index dfdca9091e..8183756ead 100644 --- a/spec/models/case_contact_spec.rb +++ b/spec/models/case_contact_spec.rb @@ -134,10 +134,10 @@ expect(obj.errors.full_messages).to include("Must enter miles driven to receive driving reimbursement.") end - it "validates casa case present" do - obj = build_stubbed(:case_contact, :expenses_status, :wants_reimbursement, casa_case: nil) + it "requires a case to be selected" do + obj = build_stubbed(:case_contact, :expenses_status, :wants_reimbursement, draft_case_ids: []) expect(obj).not_to be_valid - expect(obj.errors.full_messages).to include("Casa case can't be blank") + expect(obj.errors.full_messages).to include("You must select at least one casa case.") end end diff --git a/spec/services/case_contact_update_service_spec.rb b/spec/services/case_contact_update_service_spec.rb deleted file mode 100644 index b49b25a438..0000000000 --- a/spec/services/case_contact_update_service_spec.rb +++ /dev/null @@ -1,203 +0,0 @@ -require "rails_helper" - -RSpec.describe CaseContactUpdateService do - let(:updater) { described_class.new(case_contact) } - let(:case_contact) { create(:case_contact) } - - let!(:now) { Time.zone.now } - let!(:one_day_ago) { 1.day.ago } - let!(:two_days_ago) { 2.days.ago } - - before { travel_to one_day_ago } - after { travel_back } - - describe "#update_attributes" do - context "case is in details status" do - let!(:case_contact) { create(:case_contact, status: "details", created_at: two_days_ago) } - - context "status is not updated" do - before { updater.update_attrs({notes: "stuff"}) } - - it { expect(case_contact.metadata).to eq({}) } - it { expect(updater.update_attrs({notes: "stuff"})).to be true } - end - - it "does not update metadata if attrs are invalid" do - result = updater.update_attrs({occurred_at: 50.years.ago}) - expect(case_contact.metadata).to eq({}) - expect(result).to be false - end - - context "gets updated to details" do - before { updater.update_attrs({status: "details"}) } - - it "updates details metadata to current date" do - date = case_contact.metadata.dig("status", "details") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("details") } - end - - context "gets updated to expenses" do - before { updater.update_attrs({status: "expenses"}) } - - it "updates expenses metadata to current date" do - date = case_contact.metadata.dig("status", "expenses") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("expenses") } - end - - context "gets updated to active" do - before { updater.update_attrs({status: "active"}) } - - it "updates active metadata to current date" do - date = case_contact.metadata.dig("status", "active") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("active") } - end - end - - context "case is in expenses status" do - let!(:case_contact) { create(:case_contact, status: "expenses", created_at: two_days_ago) } - - context "status is not updated" do - before { updater.update_attrs({notes: "stuff"}) } - - it { expect(case_contact.metadata).to eq({}) } - it { expect(updater.update_attrs({notes: "stuff"})).to be true } - end - - it "does not update metadata if attrs are invalid" do - result = updater.update_attrs({occurred_at: 50.years.ago}) - expect(case_contact.metadata).to eq({}) - expect(result).to be false - end - - context "gets updated to details" do - before { updater.update_attrs({status: "details"}) } - - it "updates details metadata to current date" do - date = case_contact.metadata.dig("status", "details") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("details") } - end - - context "gets updated to expenses" do - before { updater.update_attrs({status: "expenses"}) } - - it "updates expenses metadata to current date" do - date = case_contact.metadata.dig("status", "expenses") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("expenses") } - end - - context "gets updated to active" do - before { updater.update_attrs({status: "active"}) } - - it "updates active metadata to current date" do - date = case_contact.metadata.dig("status", "active") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("active") } - end - end - - context "case is in active status" do - let!(:case_contact) { create(:case_contact, status: "active", created_at: two_days_ago) } - - context "status is not updated" do - before { updater.update_attrs({notes: "stuff"}) } - - it { expect(case_contact.metadata).to eq({}) } - it { expect(updater.update_attrs({notes: "stuff"})).to be true } - end - - it "does not update metadata if attrs are invalid" do - result = updater.update_attrs({occurred_at: 50.years.ago}) - expect(case_contact.metadata).to eq({}) - expect(result).to be false - end - - context "gets updated to details" do - before { updater.update_attrs({status: "details"}) } - - it "updates details metadata to current date" do - date = case_contact.metadata.dig("status", "details") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("details") } - end - - context "gets updated to expenses" do - before { updater.update_attrs({status: "expenses"}) } - - it "updates expenses metadata to current date" do - date = case_contact.metadata.dig("status", "expenses") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("expenses") } - end - - context "gets updated to active" do - before { updater.update_attrs({status: "active"}) } - - it "updates active metadata to current date" do - date = case_contact.metadata.dig("status", "active") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("active") } - end - end - - context "case is in started status" do - let!(:case_contact) { create(:case_contact, status: "started", created_at: two_days_ago) } - - context "status is not updated" do - before { updater.update_attrs({notes: "stuff"}) } - - it { expect(case_contact.metadata).to eq({}) } - it { expect(updater.update_attrs({notes: "stuff"})).to be true } - end - - it "does not update metadata if attrs are invalid" do - result = updater.update_attrs({occurred_at: 50.years.ago}) - expect(case_contact.metadata).to eq({}) - expect(result).to be false - end - - context "gets updated to details" do - before { updater.update_attrs({status: "details"}) } - - it "updates details metadata to current date" do - date = case_contact.metadata.dig("status", "details") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("details") } - end - - context "gets updated to expenses" do - before { updater.update_attrs({status: "expenses"}) } - - it "updates expenses metadata to current date" do - date = case_contact.metadata.dig("status", "expenses") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("expenses") } - end - - context "gets updated to active" do - before { updater.update_attrs({status: "active"}) } - - it "updates active metadata to current date" do - date = case_contact.metadata.dig("status", "active") - expect(DateTime.parse(date)).to eq(Time.zone.now) - end - it { expect(case_contact.status).to eq("active") } - end - end - end -end diff --git a/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb b/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb new file mode 100644 index 0000000000..0ff4fe8329 --- /dev/null +++ b/spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Deployment::BackfillCaseContactStartedMetadataService do + let(:past) { Date.new(2020, 1, 1).in_time_zone } + let(:parsed_past) { past.as_json } + + let(:present) { Date.new(2024, 1, 1).in_time_zone } + let(:parsed_present) { present.as_json } + + before { travel_to present } + after { travel_back } + + context "when a case contact has status metadata" do + let(:case_contact) { create(:case_contact) } + + context "when a case contact has status started metadata" do + let!(:case_contact) { create(:case_contact, created_at: past, status: "started") } + + it "does not change metadata" do + described_class.new.backfill_metadata + + expect(case_contact.reload.metadata.dig("status", "started")).to eq(parsed_past) + end + end + + context "when a case contact has other status metadata" do + let!(:case_contact) { + create(:case_contact, created_at: past, metadata: + {"status" => {"details" => parsed_past}}) + } + + it "does not change status details" do + described_class.new.backfill_metadata + + expect(case_contact.reload.metadata.dig("status", "started")).to eq(parsed_past) + end + + it "sets status started" do + described_class.new.backfill_metadata + + expect(case_contact.reload.metadata.dig("status", "started")).to eq(parsed_past) + end + end + end + + context "when a case contact has no metadata" do + let!(:case_contact) { create(:case_contact, created_at: past, metadata: {}) } + + it "does not change metadata" do + described_class.new.backfill_metadata + + expect(case_contact.reload.metadata.dig("status", "started")).to be_nil + end + end +end From 7f58519ad6c992cd6ed0eeebd592fd5830bacc75 Mon Sep 17 00:00:00 2001 From: Ken Maeshima <81536479+mononoken@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:31:35 -0700 Subject: [PATCH 11/14] 5906 update renders for turbo (#5930) * Add 422 status to all render messages for unsuccessful form submissions Add 422 status to all form failure statuses that had no status specified * Update these 404 statuses to the more accurate 422 * Update specs to expect 422 when invalid form requests are made --- .../all_casa_admins/casa_admins_controller.rb | 8 ++++---- .../all_casa_admins/casa_orgs_controller.rb | 2 +- app/controllers/all_casa_admins_controller.rb | 6 +++--- app/controllers/banners_controller.rb | 4 ++-- app/controllers/bulk_court_dates_controller.rb | 4 ++-- app/controllers/casa_admins_controller.rb | 8 ++++---- app/controllers/casa_cases_controller.rb | 8 ++++---- app/controllers/casa_org_controller.rb | 2 +- app/controllers/case_assignments_controller.rb | 2 +- app/controllers/case_groups_controller.rb | 4 ++-- app/controllers/checklist_items_controller.rb | 4 ++-- app/controllers/contact_type_groups_controller.rb | 4 ++-- app/controllers/contact_types_controller.rb | 4 ++-- app/controllers/court_dates_controller.rb | 4 ++-- app/controllers/fund_requests_controller.rb | 2 +- app/controllers/hearing_types_controller.rb | 4 ++-- app/controllers/judges_controller.rb | 4 ++-- app/controllers/learning_hour_topics_controller.rb | 4 ++-- app/controllers/learning_hour_types_controller.rb | 4 ++-- app/controllers/learning_hours_controller.rb | 4 ++-- app/controllers/mileage_rates_controller.rb | 4 ++-- app/controllers/supervisors_controller.rb | 4 ++-- app/controllers/users_controller.rb | 14 +++++++------- app/controllers/volunteers_controller.rb | 8 ++++---- spec/requests/all_casa_admins/casa_admins_spec.rb | 8 ++++---- spec/requests/all_casa_admins_spec.rb | 6 +++--- spec/requests/casa_cases_spec.rb | 12 ++++++------ spec/requests/casa_org_spec.rb | 2 +- spec/requests/court_dates_spec.rb | 8 ++++---- spec/requests/fund_requests_spec.rb | 4 ++-- spec/requests/mileage_rates_spec.rb | 6 +++--- spec/requests/supervisors_spec.rb | 2 +- spec/requests/users_spec.rb | 4 ++-- spec/requests/volunteers_spec.rb | 4 ++-- 34 files changed, 86 insertions(+), 86 deletions(-) diff --git a/app/controllers/all_casa_admins/casa_admins_controller.rb b/app/controllers/all_casa_admins/casa_admins_controller.rb index 275cc6adc2..5b39683104 100644 --- a/app/controllers/all_casa_admins/casa_admins_controller.rb +++ b/app/controllers/all_casa_admins/casa_admins_controller.rb @@ -12,7 +12,7 @@ def create service.create! redirect_to all_casa_admins_casa_org_path(@casa_org), notice: "New admin created successfully" rescue ActiveRecord::RecordInvalid - render :new + render :new, status: :unprocessable_entity end end @@ -28,7 +28,7 @@ def update @casa_admin.filter_old_emails!(@casa_admin.email) redirect_to edit_all_casa_admins_casa_org_casa_admin_path(@casa_org), notice: notice else - render :edit + render :edit, status: :unprocessable_entity end end @@ -39,7 +39,7 @@ def activate redirect_to edit_all_casa_admins_casa_org_casa_admin_path, notice: "Admin was activated. They have been sent an email." else - render :edit + render :edit, status: :unprocessable_entity end end @@ -50,7 +50,7 @@ def deactivate redirect_to edit_all_casa_admins_casa_org_casa_admin_path, notice: "Admin was deactivated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/all_casa_admins/casa_orgs_controller.rb b/app/controllers/all_casa_admins/casa_orgs_controller.rb index 8bd740c3d6..cc1faf8565 100644 --- a/app/controllers/all_casa_admins/casa_orgs_controller.rb +++ b/app/controllers/all_casa_admins/casa_orgs_controller.rb @@ -25,7 +25,7 @@ def create end else respond_to do |format| - format.html { render :new } + format.html { render :new, status: :unprocessable_entity } format.json { render json: @casa_org.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/all_casa_admins_controller.rb b/app/controllers/all_casa_admins_controller.rb index 5ab4cf648f..b8918314e5 100644 --- a/app/controllers/all_casa_admins_controller.rb +++ b/app/controllers/all_casa_admins_controller.rb @@ -30,7 +30,7 @@ def create end rescue ActiveRecord::RecordInvalid respond_to do |format| - format.html { render :new } + format.html { render :new, status: :unprocessable_entity } format.json do render json: @all_casa_admin.errors.full_messages, status: :unprocessable_entity @@ -53,7 +53,7 @@ def update end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @user.errors.full_messages, status: :unprocessable_entity } end end @@ -78,7 +78,7 @@ def update_password end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @user.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/banners_controller.rb b/app/controllers/banners_controller.rb index b9ab11d91e..46dc68ba5e 100644 --- a/app/controllers/banners_controller.rb +++ b/app/controllers/banners_controller.rb @@ -35,7 +35,7 @@ def create redirect_to banners_path rescue - render :new + render :new, status: :unprocessable_entity end def update @@ -48,7 +48,7 @@ def update redirect_to banners_path rescue - render :edit + render :edit, status: :unprocessable_entity end def destroy diff --git a/app/controllers/bulk_court_dates_controller.rb b/app/controllers/bulk_court_dates_controller.rb index 85885a40de..ef2be1d2c6 100644 --- a/app/controllers/bulk_court_dates_controller.rb +++ b/app/controllers/bulk_court_dates_controller.rb @@ -15,7 +15,7 @@ def create case_group_id = params[:court_date][:case_group_id] if case_group_id.empty? @court_date = build_court_date_with_error_message - render :new + render :new, status: :unprocessable_entity return end @@ -26,7 +26,7 @@ def create if court_date_with_error @court_date = court_date_with_error - render :new + render :new, status: :unprocessable_entity else redirect_to new_bulk_court_date_path, notice: "#{court_dates.size} #{"court date".pluralize(court_dates.size)} created!" end diff --git a/app/controllers/casa_admins_controller.rb b/app/controllers/casa_admins_controller.rb index cd78106239..39fa8acf89 100644 --- a/app/controllers/casa_admins_controller.rb +++ b/app/controllers/casa_admins_controller.rb @@ -26,7 +26,7 @@ def update end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity } end end @@ -59,7 +59,7 @@ def create end rescue ActiveRecord::RecordInvalid respond_to do |format| - format.html { render :new } + format.html { render :new, status: :unprocessable_entity } format.json { render json: service.casa_admin.errors.full_messages, status: :unprocessable_entity } end end @@ -81,7 +81,7 @@ def activate end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity } end end @@ -100,7 +100,7 @@ def deactivate end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_admin.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/casa_cases_controller.rb b/app/controllers/casa_cases_controller.rb index a3869db3c7..c3b059a31d 100644 --- a/app/controllers/casa_cases_controller.rb +++ b/app/controllers/casa_cases_controller.rb @@ -59,7 +59,7 @@ def create set_contact_types @empty_court_date = court_date_unknown? respond_to do |format| - format.html { render :new } + format.html { render :new, status: :unprocessable_entity } format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity } end end @@ -79,7 +79,7 @@ def update end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity } end end @@ -101,7 +101,7 @@ def deactivate end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity } end end @@ -123,7 +123,7 @@ def reactivate end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_case.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/casa_org_controller.rb b/app/controllers/casa_org_controller.rb index 77392b4ee1..16bc3d7701 100644 --- a/app/controllers/casa_org_controller.rb +++ b/app/controllers/casa_org_controller.rb @@ -28,7 +28,7 @@ def update end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @casa_org.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/case_assignments_controller.rb b/app/controllers/case_assignments_controller.rb index 4096ee0c0a..4737f0fc0c 100644 --- a/app/controllers/case_assignments_controller.rb +++ b/app/controllers/case_assignments_controller.rb @@ -53,7 +53,7 @@ def unassign end else respond_to do |format| - format.html { render :edit } + format.html { render :edit, status: :unprocessable_entity } format.json { render json: @case_assignment.errors.full_messages, status: :unprocessable_entity } end end diff --git a/app/controllers/case_groups_controller.rb b/app/controllers/case_groups_controller.rb index b69f98798a..1fda7b9131 100644 --- a/app/controllers/case_groups_controller.rb +++ b/app/controllers/case_groups_controller.rb @@ -19,7 +19,7 @@ def create if @case_group.save redirect_to case_groups_path, notice: "Case group created!" else - render :new + render :new, status: :unprocessable_entity end end @@ -28,7 +28,7 @@ def update if @case_group.update(case_group_params) redirect_to case_groups_path, notice: "Case group updated!" else - render :new + render :new, status: :unprocessable_entity end end diff --git a/app/controllers/checklist_items_controller.rb b/app/controllers/checklist_items_controller.rb index 4bf78c94fb..0d55fdfece 100644 --- a/app/controllers/checklist_items_controller.rb +++ b/app/controllers/checklist_items_controller.rb @@ -13,7 +13,7 @@ def create set_checklist_updated_date(@hearing_type) redirect_to edit_hearing_type_path(@hearing_type), notice: "Checklist item was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -25,7 +25,7 @@ def update set_checklist_updated_date(@hearing_type) redirect_to edit_hearing_type_path(@hearing_type), notice: "Checklist item was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/contact_type_groups_controller.rb b/app/controllers/contact_type_groups_controller.rb index 3e137680e0..dc2e606925 100644 --- a/app/controllers/contact_type_groups_controller.rb +++ b/app/controllers/contact_type_groups_controller.rb @@ -14,7 +14,7 @@ def create if @contact_type_group.save redirect_to edit_casa_org_path(current_organization), notice: "Contact Type Group was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -27,7 +27,7 @@ def update if @contact_type_group.update(contact_type_group_params) redirect_to edit_casa_org_path(current_organization), notice: "Contact Type Group was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/contact_types_controller.rb b/app/controllers/contact_types_controller.rb index 68af9cb77d..5ca8a7966d 100644 --- a/app/controllers/contact_types_controller.rb +++ b/app/controllers/contact_types_controller.rb @@ -14,7 +14,7 @@ def create if @contact_type.save redirect_to edit_casa_org_path(current_organization), notice: "Contact Type was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -27,7 +27,7 @@ def update if @contact_type.update(contact_type_params) redirect_to edit_casa_org_path(current_organization), notice: "Contact Type was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/court_dates_controller.rb b/app/controllers/court_dates_controller.rb index fab87c8fea..e65cc01451 100644 --- a/app/controllers/court_dates_controller.rb +++ b/app/controllers/court_dates_controller.rb @@ -38,7 +38,7 @@ def create if @court_date.save && @casa_case.save redirect_to casa_case_court_date_path(@casa_case, @court_date), notice: "Court date was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -47,7 +47,7 @@ def update if @court_date.update(court_date_params(@casa_case)) redirect_to casa_case_court_date_path(@casa_case, @court_date), notice: "Court date was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/fund_requests_controller.rb b/app/controllers/fund_requests_controller.rb index 77c049c66b..f2a1aa9bf2 100644 --- a/app/controllers/fund_requests_controller.rb +++ b/app/controllers/fund_requests_controller.rb @@ -15,7 +15,7 @@ def create FundRequestMailer.send_request(nil, @fund_request).deliver redirect_to casa_case_path(@casa_case), notice: "Fund Request was sent for case #{@casa_case.case_number}" else - render :new + render :new, status: :unprocessable_entity end end diff --git a/app/controllers/hearing_types_controller.rb b/app/controllers/hearing_types_controller.rb index 58820a45d0..42c2592e7d 100644 --- a/app/controllers/hearing_types_controller.rb +++ b/app/controllers/hearing_types_controller.rb @@ -14,7 +14,7 @@ def create if @hearing_type.save redirect_to edit_casa_org_path(current_organization), notice: "Hearing Type was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -27,7 +27,7 @@ def update if @hearing_type.update(hearing_type_params) redirect_to edit_casa_org_path(current_organization), notice: "Hearing Type was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/judges_controller.rb b/app/controllers/judges_controller.rb index 4a6b179fc9..0b3226e5c9 100644 --- a/app/controllers/judges_controller.rb +++ b/app/controllers/judges_controller.rb @@ -14,7 +14,7 @@ def create if @judge.save redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -27,7 +27,7 @@ def update if @judge.update(judge_params) redirect_to edit_casa_org_path(current_organization), notice: "Judge was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/learning_hour_topics_controller.rb b/app/controllers/learning_hour_topics_controller.rb index 7063e9ff65..7be8198c61 100644 --- a/app/controllers/learning_hour_topics_controller.rb +++ b/app/controllers/learning_hour_topics_controller.rb @@ -18,7 +18,7 @@ def create if @learning_hour_topic.save redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -28,7 +28,7 @@ def update if @learning_hour_topic.update(learning_hour_topic_params) redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/learning_hour_types_controller.rb b/app/controllers/learning_hour_types_controller.rb index 45ab790d33..62b7cb35c5 100644 --- a/app/controllers/learning_hour_types_controller.rb +++ b/app/controllers/learning_hour_types_controller.rb @@ -18,7 +18,7 @@ def create if @learning_hour_type.save redirect_to edit_casa_org_path(current_organization), notice: "Learning Type was successfully created." else - render :new + render :new, status: :unprocessable_entity end end @@ -28,7 +28,7 @@ def update if @learning_hour_type.update(learning_hour_type_params) redirect_to edit_casa_org_path(current_organization), notice: "Learning Type was successfully updated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/learning_hours_controller.rb b/app/controllers/learning_hours_controller.rb index 0469012c8e..f506fae93f 100644 --- a/app/controllers/learning_hours_controller.rb +++ b/app/controllers/learning_hours_controller.rb @@ -24,7 +24,7 @@ def create if @learning_hour.save format.html { redirect_to learning_hours_path, notice: "New entry was successfully created." } else - format.html { render :new, status: 404 } + format.html { render :new, status: :unprocessable_entity } end end end @@ -39,7 +39,7 @@ def update if @learning_hour.update(update_learning_hours_params) format.html { redirect_to learning_hour_path(@learning_hour), notice: "Entry was successfully updated." } else - format.html { render :edit, status: 404 } + format.html { render :edit, status: :unprocessable_entity } end end end diff --git a/app/controllers/mileage_rates_controller.rb b/app/controllers/mileage_rates_controller.rb index 4ff2c6704b..ae8c1d376e 100644 --- a/app/controllers/mileage_rates_controller.rb +++ b/app/controllers/mileage_rates_controller.rb @@ -18,7 +18,7 @@ def create if @mileage_rate.save redirect_to mileage_rates_path else - render :new + render :new, status: :unprocessable_entity end end @@ -32,7 +32,7 @@ def update if @mileage_rate.update(mileage_rate_params) redirect_to mileage_rates_path else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/supervisors_controller.rb b/app/controllers/supervisors_controller.rb index b4834fce01..42e1bdd5fd 100644 --- a/app/controllers/supervisors_controller.rb +++ b/app/controllers/supervisors_controller.rb @@ -35,7 +35,7 @@ def create sms_status = deliver_sms_to @supervisor, body_msg redirect_to edit_supervisor_path(@supervisor), notice: sms_acct_creation_notice("supervisor", sms_status) else - render new_supervisor_path + render new_supervisor_path, status: :unprocessable_entity end end @@ -55,7 +55,7 @@ def update @supervisor.filter_old_emails!(@supervisor.email) redirect_to edit_supervisor_path(@supervisor), notice: notice else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9eae2a1cac..144d4d3df7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -16,19 +16,19 @@ def update flash[:success] = "Profile was successfully updated." redirect_to edit_users_path else - render :edit + render :edit, status: :unprocessable_entity end end def add_language if @language.nil? @user.errors.add(:language_id, "can not be blank. Please select a language before adding.") - return render "edit" + return render "edit", status: :unprocessable_entity end if current_user.languages.include?(@language) @user.errors.add(:language_id, "#{@language.name} is already in your languages list.") - return render "edit" + return render "edit", status: :unprocessable_entity end current_user.languages << @language @@ -54,11 +54,11 @@ def remove_language def update_password unless valid_user_password @user.errors.add(:base, "Current password is incorrect") - return render "edit" + return render "edit", status: :unprocessable_entity end unless update_user_password - return render "edit" + return render "edit", status: :unprocessable_entity end bypass_sign_in(@user) if @user == true_user @@ -72,11 +72,11 @@ def update_password def update_email unless valid_user_password @user.errors.add(:base, "Current password is incorrect") - return render "edit" + return render "edit", status: :unprocessable_entity end unless update_user_email - return render "edit" + return render "edit", status: :unprocessable_entity end bypass_sign_in(@user) if @user == true_user diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb index 0a3f9d6fa7..519407c3fc 100644 --- a/app/controllers/volunteers_controller.rb +++ b/app/controllers/volunteers_controller.rb @@ -41,7 +41,7 @@ def create sms_status = deliver_sms_to @volunteer, body_msg redirect_to edit_volunteer_path(@volunteer), notice: sms_acct_creation_notice("volunteer", sms_status) else - render :new + render :new, status: :unprocessable_entity end end @@ -58,7 +58,7 @@ def update @volunteer.filter_old_emails!(@volunteer.email) redirect_to edit_volunteer_path(@volunteer), notice: notice else - render :edit + render :edit, status: :unprocessable_entity end end @@ -73,7 +73,7 @@ def activate redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer was activated. They have been sent an email." end else - render :edit + render :edit, status: :unprocessable_entity end end @@ -82,7 +82,7 @@ def deactivate if @volunteer.deactivate redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer was deactivated." else - render :edit + render :edit, status: :unprocessable_entity end end diff --git a/spec/requests/all_casa_admins/casa_admins_spec.rb b/spec/requests/all_casa_admins/casa_admins_spec.rb index 3f570af5db..1d91b46f35 100644 --- a/spec/requests/all_casa_admins/casa_admins_spec.rb +++ b/spec/requests/all_casa_admins/casa_admins_spec.rb @@ -39,7 +39,7 @@ it "renders new page" do expect { subject }.not_to change(CasaAdmin, :count) - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expect(response).to render_template "casa_admins/new" end end @@ -92,7 +92,7 @@ it "renders new page" do subject - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expect(response).to render_template "casa_admins/edit" end end @@ -130,7 +130,7 @@ it "renders edit page" do subject - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expect(response).to render_template "casa_admins/edit" end end @@ -168,7 +168,7 @@ it "renders edit page" do subject - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expect(response).to render_template "casa_admins/edit" end end diff --git a/spec/requests/all_casa_admins_spec.rb b/spec/requests/all_casa_admins_spec.rb index d2896f55fc..37fe7e9e5d 100644 --- a/spec/requests/all_casa_admins_spec.rb +++ b/spec/requests/all_casa_admins_spec.rb @@ -91,7 +91,7 @@ email: "" } } - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expect(response).to render_template "all_casa_admins/new" end @@ -132,7 +132,7 @@ it "does not update the all_casa_admin" do other_admin = create(:all_casa_admin) patch all_casa_admins_path, params: {all_casa_admin: {email: other_admin.email}} - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(:unprocessable_entity) expect(admin.email).to_not eq "newemail@example.com" end @@ -201,7 +201,7 @@ it "does not update the all_casa_admin password" do subject - expect(response).to have_http_status(:ok) + expect(response).to have_http_status(:unprocessable_entity) expect(admin.reload.valid_password?("newpassword")).to be false end diff --git a/spec/requests/casa_cases_spec.rb b/spec/requests/casa_cases_spec.rb index 3008265605..98ea95562e 100644 --- a/spec/requests/casa_cases_spec.rb +++ b/spec/requests/casa_cases_spec.rb @@ -231,9 +231,9 @@ ).by(0) end - it "renders a successful response (i.e. to display the 'new' template)" do + it "renders an unprocessable entity response (i.e. to display the 'new' template)" do post casa_cases_url, params: {casa_case: invalid_attributes} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) end it "also respond to json", :aggregate_failures do @@ -271,9 +271,9 @@ ) end - it "renders a successful response (i.e. to display the 'new' template)" do + it "renders an unprocessable entity response (i.e. to display the 'new' template)" do post casa_cases_url, params: {casa_case: invalid_params} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) end end end @@ -329,9 +329,9 @@ end context "with invalid parameters" do - it "renders a successful response displaying the edit template" do + it "renders an unprocessable entity response displaying the edit template" do patch casa_case_url(casa_case), params: {casa_case: invalid_attributes} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) end it "also responds as json", :aggregate_failures do diff --git a/spec/requests/casa_org_spec.rb b/spec/requests/casa_org_spec.rb index 227c17ebd9..cc358ddef3 100644 --- a/spec/requests/casa_org_spec.rb +++ b/spec/requests/casa_org_spec.rb @@ -113,7 +113,7 @@ end context "and html format" do - it { is_expected.to be_successful } + it { is_expected.to have_http_status(:unprocessable_entity) } it "renders the edit template" do expect(request.body).to match(/error_explanation/) diff --git a/spec/requests/court_dates_spec.rb b/spec/requests/court_dates_spec.rb index 1011db18d9..ddec9c15ce 100644 --- a/spec/requests/court_dates_spec.rb +++ b/spec/requests/court_dates_spec.rb @@ -260,9 +260,9 @@ end.to change(CourtDate, :count).by(0) end - it "renders a successful response (i.e. to display the 'new' template)" do + it "renders an unprocessable entity response (i.e. to display the 'new' template)" do post casa_case_court_dates_path(casa_case), params: {court_date: invalid_attributes} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expected_errors = [ "Date can't be blank", "Date is not valid. Court date must be within one year from today.", @@ -305,10 +305,10 @@ end context "with invalid parameters" do - it "renders a successful response displaying the edit template" do + it "renders an unprocessable entity response displaying the edit template" do patch casa_case_court_date_path(casa_case, court_date), params: {court_date: invalid_attributes} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) expected_errors = [ "Date can't be blank", "Date is not valid. Court date must be within one year from today.", diff --git a/spec/requests/fund_requests_spec.rb b/spec/requests/fund_requests_spec.rb index 95f3f28c93..343603d0bc 100644 --- a/spec/requests/fund_requests_spec.rb +++ b/spec/requests/fund_requests_spec.rb @@ -147,7 +147,7 @@ end end - context "with in valid params" do + context "with invalid params" do it "does not create fund request or call mailer" do volunteer = create(:volunteer, :with_casa_cases) casa_case = volunteer.casa_cases.first @@ -170,7 +170,7 @@ } }.to_not change(FundRequest, :count) - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) end end end diff --git a/spec/requests/mileage_rates_spec.rb b/spec/requests/mileage_rates_spec.rb index d76acf9290..956120aade 100644 --- a/spec/requests/mileage_rates_spec.rb +++ b/spec/requests/mileage_rates_spec.rb @@ -80,7 +80,7 @@ expect { post mileage_rates_path, params: params }.to_not change { MileageRate.count } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(:unprocessable_entity) end end @@ -104,7 +104,7 @@ expect { post mileage_rates_path, params: params }.to_not change { MileageRate.count } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(:unprocessable_entity) end end end @@ -140,7 +140,7 @@ it "does not update a mileage rate" do patch mileage_rate_path(mileage_rate), params: params - expect(response).to have_http_status(:success) + expect(response).to have_http_status(:unprocessable_entity) mileage_rate.reload expect(mileage_rate.amount).to eq(10.11) diff --git a/spec/requests/supervisors_spec.rb b/spec/requests/supervisors_spec.rb index b605193812..350e24d5fc 100644 --- a/spec/requests/supervisors_spec.rb +++ b/spec/requests/supervisors_spec.rb @@ -177,7 +177,7 @@ it "gracefully fails" do patch supervisor_path(supervisor), params: {supervisor: {email: other_supervisor.email}} - expect(response).to be_successful + expect(response).to have_http_status(:unprocessable_entity) end end end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index a00288dab2..d362f8f705 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -426,7 +426,7 @@ patch add_language_users_path(volunteer), params: { language_id: "" } - expect(response).to have_http_status(200) + expect(response).to have_http_status(:unprocessable_entity) expect(response.body).to include("Please select a language before adding.") end end @@ -449,7 +449,7 @@ end it "should notify the user that the language is already in their list" do - expect(response).to have_http_status(200) + expect(response).to have_http_status(:unprocessable_entity) expect(response.body).to include("#{language.name} is already in your languages list.") end end diff --git a/spec/requests/volunteers_spec.rb b/spec/requests/volunteers_spec.rb index 59159e68d3..88f4a1321f 100644 --- a/spec/requests/volunteers_spec.rb +++ b/spec/requests/volunteers_spec.rb @@ -218,7 +218,7 @@ post volunteers_url, params: params }.to change(Volunteer, :count).by(0) .and change(ActionMailer::Base.deliveries, :count).by(0) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(:unprocessable_entity) end end end @@ -262,7 +262,7 @@ patch volunteer_path(volunteer), params: { volunteer: {email: other_volunteer.email, display_name: "New Name", phone_number: "+15463457898"} } - expect(response).to have_http_status(:success) # Re-renders form + expect(response).to have_http_status(:unprocessable_entity) volunteer.reload expect(volunteer.display_name).to_not eq "New Name" From 12c72fcbcb084fd1d93ab46c83fdc83b72e168a9 Mon Sep 17 00:00:00 2001 From: Yuri Bocharov Date: Wed, 24 Jul 2024 19:39:53 -0400 Subject: [PATCH 12/14] fix: flaky scope spec due to order (#5942) --- spec/models/case_contact_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/case_contact_spec.rb b/spec/models/case_contact_spec.rb index 8183756ead..f5eabc0ad0 100644 --- a/spec/models/case_contact_spec.rb +++ b/spec/models/case_contact_spec.rb @@ -543,7 +543,7 @@ context "when parameter is not nil" do it "returns contacts with the given casa case ids" do - expect(described_class.with_casa_case(casa_case.id)).to eq(case_contacts) + expect(described_class.with_casa_case(casa_case.id)).to match_array(case_contacts) end end end From dbf39c361c23ac503408b7685575f91dc6e4ec8d Mon Sep 17 00:00:00 2001 From: Yuri Bocharov Date: Wed, 24 Jul 2024 19:49:34 -0400 Subject: [PATCH 13/14] feat: add warning for pg county (#5940) * feat: add warning for pg county * feat: add tests and flipper helper --- app/views/case_contacts/form/expenses.html.erb | 10 ++++++++++ spec/support/flipper_helper.rb | 5 +++++ spec/system/case_contacts/additional_expenses_spec.rb | 8 ++++++-- spec/system/case_contacts/new_spec.rb | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 spec/support/flipper_helper.rb diff --git a/app/views/case_contacts/form/expenses.html.erb b/app/views/case_contacts/form/expenses.html.erb index b1dde6c48a..6b606916dd 100644 --- a/app/views/case_contacts/form/expenses.html.erb +++ b/app/views/case_contacts/form/expenses.html.erb @@ -4,6 +4,16 @@ <%= form_with(model: @case_contact, url: wizard_path(nil, case_contact_id: @case_contact.id), local: true, id: "casa-contact-form", class: "component-validated-form") do |form| %> <%= render "/shared/error_messages", resource: @case_contact %> + <% if Flipper.enabled?(:reimbursement_warning, current_organization) %> +
+

+ Volunteers are reimbursed at the federal mileage rate. +
+ Please note that there is a $35.00 per month cap per volunteer for your mileage. + We aim to mail your reimbursement to you via check within 14-28 business days of your request for reimbursement. +
+ <% end %> +

diff --git a/spec/support/flipper_helper.rb b/spec/support/flipper_helper.rb new file mode 100644 index 0000000000..8c57d04ea4 --- /dev/null +++ b/spec/support/flipper_helper.rb @@ -0,0 +1,5 @@ +RSpec.configure do |config| + config.before(:each, :flipper) do + allow(Flipper).to receive(:enabled?) + end +end diff --git a/spec/system/case_contacts/additional_expenses_spec.rb b/spec/system/case_contacts/additional_expenses_spec.rb index 6f5e3a8da8..ee06171cf6 100644 --- a/spec/system/case_contacts/additional_expenses_spec.rb +++ b/spec/system/case_contacts/additional_expenses_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" require "action_view" -RSpec.describe "additional_expenses", type: :system do +RSpec.describe "additional_expenses", type: :system, flipper: true do let(:organization) { build(:casa_org, additional_expenses_enabled: true) } let(:volunteer) { create(:volunteer, casa_org: organization) } let(:casa_case) { create(:casa_case, casa_org: organization) } @@ -11,12 +11,14 @@ create(:case_assignment, casa_case: casa_case, volunteer: volunteer) end - it "can be set per organization", js: true do + it "additional expenses and notices can be set per organization", js: true do other_organization = build(:casa_org) other_volunteer = create(:volunteer, casa_org: other_organization) other_casa_case = create(:casa_case, casa_org: other_organization) create(:case_assignment, casa_case: other_casa_case, volunteer: other_volunteer) + allow(Flipper).to receive(:enabled?).with(:reimbursement_warning, organization).and_return(true) + sign_in volunteer visit casa_case_path(casa_case.id) click_on "New Case Contact" @@ -25,6 +27,7 @@ complete_notes_page expect(page).to have_text("Other Expenses") + expect(page).to have_text("Volunteers are eligible to be reimbursed for case-related travel") sign_in other_volunteer visit casa_case_path(other_casa_case.id) @@ -34,6 +37,7 @@ complete_notes_page expect(page).not_to have_text("Other Expenses") + expect(page).not_to have_text("Volunteers are eligible to be reimbursed for case-related travel") end context "when setting additional expenses" do diff --git a/spec/system/case_contacts/new_spec.rb b/spec/system/case_contacts/new_spec.rb index ac700d7128..e425f9876e 100644 --- a/spec/system/case_contacts/new_spec.rb +++ b/spec/system/case_contacts/new_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" require "action_view" -RSpec.describe "case_contacts/new", type: :system, js: true do +RSpec.describe "case_contacts/new", type: :system, js: true, flipper: true do include ActionView::Helpers::SanitizeHelper context "when admin" do From 15055766fa71b36c9dc0f7025974323a5b9c60fd Mon Sep 17 00:00:00 2001 From: Jeanine Soterwood Date: Wed, 24 Jul 2024 17:29:58 -0700 Subject: [PATCH 14/14] Remove littleforest from codeowners (#5943) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0b2470a206..f474b899a0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners -* @compwron @FireLemons @littleforest @elasticspoon +* @compwron @FireLemons @elasticspoon /app/javascript/ @schoork @FireLemons @elasticspoon