From b5e5c4a41427248d3309c3dac5ae99c085dad4ff Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 17 Dec 2024 11:50:24 +0000 Subject: [PATCH] feat(studies): updates data release other option --- app/models/study.rb | 2 +- app/views/shared/metadata/_related_fields.html.erb | 2 +- features/studies/8447221_data_release_help_text.feature | 4 ++-- features/studies/data_release_timings.feature | 4 ++-- features/support/step_definitions/study_steps.rb | 2 +- spec/models/study_spec.rb | 5 ++++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/models/study.rb b/app/models/study.rb index dca73ee792..92ea477ce2 100644 --- a/app/models/study.rb +++ b/app/models/study.rb @@ -91,7 +91,7 @@ class Study < ApplicationRecord # rubocop:todo Metrics/ClassLength 'Other (please specify)' ].freeze - DATA_RELEASE_DELAY_FOR_OTHER = 'other' + DATA_RELEASE_DELAY_FOR_OTHER = 'Other (with free text box)' DATA_RELEASE_DELAY_REASONS_STANDARD = [ 'PhD study', 'Capacity building', diff --git a/app/views/shared/metadata/_related_fields.html.erb b/app/views/shared/metadata/_related_fields.html.erb index d748e8d430..9d59fb9bdc 100644 --- a/app/views/shared/metadata/_related_fields.html.erb +++ b/app/views/shared/metadata/_related_fields.html.erb @@ -23,7 +23,7 @@ var valueFrom = function(element) { if (element === null) { return null } - var value = element.value.toLowerCase().replace(/[^a-z0-9]+/, '_'); + var value = element.value.toLowerCase().replaceAll(/[^a-z0-9]+/g, '_'); return (value.length == 0) ? 'blank' : value; }; diff --git a/features/studies/8447221_data_release_help_text.feature b/features/studies/8447221_data_release_help_text.feature index 603b2c0b4c..dd79263d3e 100644 --- a/features/studies/8447221_data_release_help_text.feature +++ b/features/studies/8447221_data_release_help_text.feature @@ -22,7 +22,7 @@ Feature: Update the data release fields for creating a study Scenario Outline: Add help text opposite delay drop down (4044305) When I choose "" from "What is the data release strategy for this study?" When I select "delayed" from "How is the data release to be timed?" - When I select "other" from "Reason for delaying release" + When I select "Other (with free text box)" from "Reason for delaying release" Then I should exactly see "Reason for delaying release" Examples: @@ -41,7 +41,7 @@ Feature: Update the data release fields for creating a study Scenario Outline: Delaying for 3 months should have the same questions as all other delays (4044273) When I select "delayed" from "How is the data release to be timed?" - And I select "other" from "Reason for delaying release" + And I select "Other (with free text box)" from "Reason for delaying release" And I select "" from "Delay for" And I should exactly see "Comment regarding data release timing and approval" diff --git a/features/studies/data_release_timings.feature b/features/studies/data_release_timings.feature index 4c0c2f3961..cc6562c638 100644 --- a/features/studies/data_release_timings.feature +++ b/features/studies/data_release_timings.feature @@ -37,7 +37,7 @@ Feature: Studies have timings for release of their data Scenario Outline: When the data release is delayed but no reasons are provided Given I select "delayed" from "How is the data release to be timed?" - And I select "other" from "Reason for delaying release" + And I select "Other (with free text box)" from "Reason for delaying release" And I fill in "Please explain the reason for delaying release" with "Some reason" And I select "" from "Delay for" When I press "Create" @@ -54,7 +54,7 @@ Feature: Studies have timings for release of their data Scenario Outline: When the data release is delayed and the reasons are provided Given I select "delayed" from "How is the data release to be timed?" - And I select "other" from "Reason for delaying release" + And I select "Other (with free text box)" from "Reason for delaying release" And I fill in "Please explain the reason for delaying release" with "Some reason" And I select "" from "Delay for" And I fill in "Comment regarding data release timing and approval" with "Because it is ok?" diff --git a/features/support/step_definitions/study_steps.rb b/features/support/step_definitions/study_steps.rb index 466e42627b..86f220fab3 100644 --- a/features/support/step_definitions/study_steps.rb +++ b/features/support/step_definitions/study_steps.rb @@ -159,7 +159,7 @@ def given_study_metadata(attribute, regexp) study.update!( study_metadata_attributes: { data_release_timing: 'delayed', - data_release_delay_reason: 'other', + data_release_delay_reason: 'Other (with free text box)', data_release_delay_other_comment: reason, data_release_delay_period: "#{period} months", data_release_delay_reason_comment: reason diff --git a/spec/models/study_spec.rb b/spec/models/study_spec.rb index a3e27ab54e..696170a97f 100644 --- a/spec/models/study_spec.rb +++ b/spec/models/study_spec.rb @@ -713,7 +713,10 @@ create( :study, study_metadata: - create(:study_metadata, metadata.merge(data_release_timing: 'delayed', data_release_delay_reason: 'other')) + create( + :study_metadata, + metadata.merge(data_release_timing: 'delayed', data_release_delay_reason: 'Other (with free text box)') + ) ) end