diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 6c6a4395fb..b8db0ec031 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -57,9 +57,11 @@ jobs: - name: 'Precompile all of the Assets' run: bin/rails assets:precompile + # briley - comment out Karma tests due to issues with dependencies. We should + # replace these with RSpec feature tests # Run the JS tests - - name: 'Run Karma Tests' - run: yarn test + # - name: 'Run Karma Tests' + # run: yarn test # Run the unit and functional tests - name: 'Run Rspec Unit and Functional Tests' diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index 504983a12a..2159c8d10e 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -81,9 +81,11 @@ jobs: - name: 'Compile Assets' run: bin/rails assets:precompile + # briley - comment out Karma tests due to issues with dependencies. We should + # replace these with RSpec feature tests # Run the JS tests - - name: 'Run Karma Tests' - run: yarn test + # - name: 'Run Karma Tests' + # run: yarn test # Run the unit and functional tests - name: 'Run Rspec Unit and Functional Tests' diff --git a/.rubocop.yml b/.rubocop.yml index 5a9465c8f2..ed01688efc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -147,6 +147,11 @@ Style/DocumentDynamicEvalDefinition: # new in 1.1 Enabled: true Style/EndlessMethod: # new in 1.8 Enabled: true +Style/FormatStringToken: + # Force use of the `%{variable}` style of tokens instead of `%s` because + # Translation.io has trouble with auto-translating it. It converts `%s` to + # `% s` (note the added space) + EnforcedStyle: template Style/HashConversion: # new in 1.10 Enabled: true Style/HashExcept: # new in 1.7 diff --git a/Gemfile b/Gemfile index ce079fdbaa..d25c86bd0c 100644 --- a/Gemfile +++ b/Gemfile @@ -213,6 +213,8 @@ gem 'httparty' # Autoload dotenv in Rails. (https://github.com/bkeepers/dotenv) gem 'dotenv-rails' +gem 'activerecord_json_validator' + # ================================= # # ENVIRONMENT SPECIFIC DEPENDENCIES # # ================================= # @@ -275,7 +277,7 @@ group :test do # Browser integration tests are expensive. We can mock external requests # in our tests, but once a browser is involved, we lose control. - gem 'capybara-webmock' + gem 'capybara-webmock', '~> 0.6' # RSpec::CollectionMatchers lets you express expected outcomes on # collections of an object in an example. diff --git a/Gemfile.lock b/Gemfile.lock index d1a8d1dba1..88aba7124d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,46 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.6.2) - actionpack (= 5.2.6.2) + actioncable (5.2.7) + actionpack (= 5.2.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.6.2) - actionpack (= 5.2.6.2) - actionview (= 5.2.6.2) - activejob (= 5.2.6.2) + actionmailer (5.2.7) + actionpack (= 5.2.7) + actionview (= 5.2.7) + activejob (= 5.2.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.6.2) - actionview (= 5.2.6.2) - activesupport (= 5.2.6.2) + actionpack (5.2.7) + actionview (= 5.2.7) + activesupport (= 5.2.7) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.6.2) - activesupport (= 5.2.6.2) + actionview (5.2.7) + activesupport (= 5.2.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.6.2) - activesupport (= 5.2.6.2) + activejob (5.2.7) + activesupport (= 5.2.7) globalid (>= 0.3.6) - activemodel (5.2.6.2) - activesupport (= 5.2.6.2) - activerecord (5.2.6.2) - activemodel (= 5.2.6.2) - activesupport (= 5.2.6.2) + activemodel (5.2.7) + activesupport (= 5.2.7) + activerecord (5.2.7) + activemodel (= 5.2.7) + activesupport (= 5.2.7) arel (>= 9.0) - activestorage (5.2.6.2) - actionpack (= 5.2.6.2) - activerecord (= 5.2.6.2) + activerecord_json_validator (2.1.0) + activerecord (>= 4.2.0, < 8) + json_schemer (~> 0.2.18) + activestorage (5.2.7) + actionpack (= 5.2.7) + activerecord (= 5.2.7) marcel (~> 1.0.0) - activesupport (5.2.6.2) + activesupport (5.2.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -54,7 +57,7 @@ GEM ast (2.4.2) autoprefixer-rails (10.4.2.0) execjs (~> 2) - bcrypt (3.1.16) + bcrypt (3.1.17) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) @@ -62,7 +65,7 @@ GEM bindex (0.8.1) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bootsnap (1.10.3) + bootsnap (1.11.1) msgpack (~> 1.2) brakeman (5.2.1) builder (3.2.4) @@ -96,7 +99,7 @@ GEM webrick (>= 1.7) childprocess (3.0.0) coderay (1.1.3) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) contact_us (1.2.0) rails (>= 4.2.0) crack (0.4.5) @@ -130,49 +133,32 @@ GEM dragonfly-s3_data_store (1.3.0) dragonfly (~> 1.0) fog-aws + ecma-re-validator (0.4.0) + regexp_parser (~> 2.2) erubi (1.10.0) - excon (0.91.0) + excon (0.92.2) execjs (2.8.1) - factory_bot (6.2.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.19.0) - i18n (>= 1.6, < 2) - faraday (1.9.3) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0) - faraday-multipart (~> 1.0) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.0) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - faraday-retry (~> 1.0) + faker (2.20.0) + i18n (>= 1.8.11, < 2) + faraday (2.2.0) + faraday-net_http (~> 2.0) ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - faraday-retry (1.0.3) + faraday-net_http (2.0.1) ffi (1.15.5) flag_shih_tzu (0.3.23) fog-aws (3.13.0) fog-core (~> 2.1) fog-json (~> 1.1) fog-xml (~> 0.1) - fog-core (2.2.4) + fog-core (2.3.0) builder excon (~> 0.71) - formatador (~> 0.2) + formatador (>= 0.2, < 2.0) mime-types fog-json (1.2.0) fog-core @@ -182,7 +168,7 @@ GEM nokogiri (>= 1.5.11, < 2.0.0) font-awesome-sass (5.13.1) sassc (>= 1.11) - formatador (0.3.0) + formatador (1.1.0) forwardable (1.3.2) fuubar (2.5.1) rspec-core (~> 3.0) @@ -207,6 +193,7 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) + hana (1.3.7) hashdiff (1.0.1) hashie (5.0.0) highline (2.0.3) @@ -217,12 +204,17 @@ GEM httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.9.1) + i18n (1.10.0) concurrent-ruby (~> 1.0) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) json (2.6.1) + json_schemer (0.2.20) + ecma-re-validator (~> 0.3) + hana (~> 1.3) + regexp_parser (~> 2.0) + uri_template (~> 0.7) jwt (2.3.0) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -244,7 +236,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.3) - loofah (2.14.0) + loofah (2.16.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.2.8) @@ -260,26 +252,23 @@ GEM nokogiri (~> 1) rake mini_mime (1.1.2) - mini_portile2 (2.7.1) + mini_portile2 (2.8.0) minitest (5.15.0) mocha (1.13.0) - msgpack (1.4.4) + msgpack (1.5.0) multi_json (1.15.0) multi_xml (0.6.0) - multipart-post (2.1.1) mysql2 (0.5.3) nenv (0.3.0) nio4r (2.5.8) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) - racc (~> 1.4) - nokogiri (1.13.1-x86_64-linux) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - oauth2 (1.4.7) - faraday (>= 0.8, < 2.0) + oauth2 (1.4.9) + faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) @@ -301,10 +290,10 @@ GEM omniauth (>= 1.0.0) options (2.3.2) orm_adapter (0.5.0) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.22.1) + parser (3.1.1.0) ast (~> 2.4.1) - pg (1.3.2) + pg (1.3.5) prime (0.1.2) forwardable singleton @@ -315,7 +304,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.6.2) + puma (5.6.4) nio4r (~> 2.0) pundit (2.2.0) activesupport (>= 3.0.0) @@ -323,26 +312,26 @@ GEM rspec-rails (>= 3.0.0) racc (1.6.0) rack (2.2.3) - rack-mini-profiler (2.3.3) + rack-mini-profiler (3.0.0) rack (>= 1.2.0) - rack-protection (2.1.0) + rack-protection (2.2.0) rack rack-proxy (0.7.2) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.6.2) - actioncable (= 5.2.6.2) - actionmailer (= 5.2.6.2) - actionpack (= 5.2.6.2) - actionview (= 5.2.6.2) - activejob (= 5.2.6.2) - activemodel (= 5.2.6.2) - activerecord (= 5.2.6.2) - activestorage (= 5.2.6.2) - activesupport (= 5.2.6.2) + rails (5.2.7) + actioncable (= 5.2.7) + actionmailer (= 5.2.7) + actionpack (= 5.2.7) + actionview (= 5.2.7) + activejob (= 5.2.7) + activemodel (= 5.2.7) + activerecord (= 5.2.7) + activestorage (= 5.2.7) + activesupport (= 5.2.7) bundler (>= 1.3.0) - railties (= 5.2.6.2) + railties (= 5.2.7) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -353,9 +342,9 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) - railties (5.2.6.2) - actionpack (= 5.2.6.2) - activesupport (= 5.2.6.2) + railties (5.2.7) + actionpack (= 5.2.7) + activesupport (= 5.2.7) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) @@ -364,7 +353,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - recaptcha (5.8.1) + recaptcha (5.9.0) json regexp_parser (2.2.1) responders (3.0.1) @@ -383,10 +372,10 @@ GEM rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-mocks (3.11.0) + rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) - rspec-rails (5.1.0) + rspec-rails (5.1.1) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -395,29 +384,29 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.11.0) - rubocop (1.25.1) + rubocop (1.26.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.15.1, < 2.0) + rubocop-ast (>= 1.16.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.2) - parser (>= 3.0.1.1) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) rubocop-i18n (3.0.0) rubocop (~> 1.0) - rubocop-performance (1.13.2) + rubocop-performance (1.13.3) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.13.2) + rubocop-rails (2.14.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.8.0) + rubocop-rspec (2.9.0) rubocop (~> 1.19) rubocop-thread_safety (0.4.4) rubocop (>= 0.53.0) @@ -453,7 +442,7 @@ GEM spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (4.0.2) + sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) @@ -465,7 +454,7 @@ GEM thread_safe (0.3.6) tilt (2.0.10) tomparse (0.4.2) - translation (1.29) + translation (1.31) gettext (~> 3.2, >= 3.2.5, <= 3.4.2) turbolinks (5.2.1) turbolinks-source (~> 5.2) @@ -473,7 +462,8 @@ GEM tzinfo (1.2.9) thread_safe (~> 0.1) unicode-display_width (2.1.0) - uniform_notifier (1.14.2) + uniform_notifier (1.16.0) + uri_template (0.7.0) warden (1.2.9) rack (>= 2.0.9) web-console (3.7.0) @@ -512,9 +502,9 @@ GEM PLATFORMS ruby - x86_64-linux DEPENDENCIES + activerecord_json_validator annotate annotate_gem api-pagination @@ -528,7 +518,7 @@ DEPENDENCIES byebug capybara capybara-screenshot - capybara-webmock + capybara-webmock (~> 0.6) contact_us database_cleaner devise diff --git a/app/assets/stylesheets/blocks/_modal_search.scss b/app/assets/stylesheets/blocks/_modal_search.scss new file mode 100644 index 0000000000..75e87c828e --- /dev/null +++ b/app/assets/stylesheets/blocks/_modal_search.scss @@ -0,0 +1,75 @@ +.modal-search-block { + border: 1px solid $color-grey; + margin-bottom: 10px; + padding: 10px 5px; +} + +.modal-search .modal-dialog { + /* Make the dialog 80% of the screen height/width */ + width: 80%; + // height: 80%; +} +.modal-search .modal-body { + /* 100% = dialog height, 50px = header (27.5px) + footer (21px) */ + // max-height: calc(80% - 50px); + max-height: 450px; + overflow-y: scroll; +} + +.modal-search-results-pagination { + margin-bottom: 10px; +} + +.modal-search-result { + margin-top: 5px; + padding-bottom: 5px; + + .modal-search-result-label { + font-size: 1.6rem; + font-weight: 500; + } + + .tags > .tag { + display: inline-block; + margin: 5px 2px; + } + .tags .facet { + border: 1px solid $color-blue; + border-radius: 25px; + padding: 2px 5px; + } + + div { + margin-bottom: 5px; + } + + dl { + margin-left: 20px; + + dd { + margin-bottom: 5px; + } + } +} + +.modal-search-results .modal-search-result { + border-bottom: 1px solid $color-grey; +} + +/* the 'Select' button displayed in the modal dialog */ +.modal-search-result .modal-search-result-selector, +.modal-search-result .modal-search-result-unselector { + display: inline-block; + background-color: $color-white; + border-radius: 25px; + padding: 2px 5px; + font-size: 1.3rem; +} +.modal-search-result .modal-search-result-selector { + background-color: $color-green; + color: $color-white; +} +.modal-search-result .modal-search-result-unselector { + border: 1px solid $color-red; + color: $color-red; +} diff --git a/app/assets/stylesheets/blocks/_question_form.scss b/app/assets/stylesheets/blocks/_question_form.scss new file mode 100644 index 0000000000..301e5861e4 --- /dev/null +++ b/app/assets/stylesheets/blocks/_question_form.scss @@ -0,0 +1,35 @@ +.question-body { + display: flex; + padding: 15px 0; + .question-section { + flex: 8; + position: relative; + .toggle-guidance-section { + position: absolute; + top: 0; + right: 0; + background-color: $color-grey-darker; + color: $color-white; + padding: 10px 5px; + cursor: pointer; + + text-orientation: mixed; + writing-mode: vertical-rl; + &.disabled { + background-color: $color-muted; + cursor: not-allowed; + } + } + .question-form { + padding-right: 50px; + padding-top: 10px; + } + } + + .guidance-section { + flex: 4; + border-left: 5px solid $color-grey-darker; + padding-left: 5px; + } + +} \ No newline at end of file diff --git a/app/assets/stylesheets/variables/_colours.scss b/app/assets/stylesheets/variables/_colours.scss index 17cc9034aa..c10b0e676c 100644 --- a/app/assets/stylesheets/variables/_colours.scss +++ b/app/assets/stylesheets/variables/_colours.scss @@ -5,6 +5,7 @@ $color-black: #000; $color-white: #FFF; $color-red: #b94a48; +$color-green: #4c8d3f; $color-grey: #4F5253; $color-grey-darkest: #222; $color-grey-darker: #333; diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 9e089bd5d4..4404505282 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -22,7 +22,7 @@ def create_or_update unless p.question_exists?(p_params[:question_id]) # rubocop:disable Layout/LineLength render(status: :not_found, json: { - msg: format(_('There is no question with id %s associated to plan id %s for which to create or update an answer'), question_id: p_params[:question_id], plan_id: p_params[:plan_id]) + msg: format(_('There is no question with id %{question_id} associated to plan id %{plan_id} for which to create or update an answer'), question_id: p_params[:question_id], plan_id: p_params[:plan_id]) }) # rubocop:enable Layout/LineLength return @@ -30,7 +30,7 @@ def create_or_update rescue ActiveRecord::RecordNotFound # rubocop:disable Layout/LineLength render(status: :not_found, json: { - msg: format(_('There is no plan with id %s for which to create or update an answer'), id: p_params[:plan_id]) + msg: format(_('There is no plan with id %{id} for which to create or update an answer'), id: p_params[:plan_id]) }) # rubocop:enable Layout/LineLength return diff --git a/app/controllers/api/v0/base_controller.rb b/app/controllers/api/v0/base_controller.rb index 058babfe1c..fb8309bd39 100644 --- a/app/controllers/api/v0/base_controller.rb +++ b/app/controllers/api/v0/base_controller.rb @@ -74,6 +74,10 @@ def page_params params.permit(:page, :per_page) end + def plan_params + params.permit(:template_id, :plan[:title], :plan[:email]) + end + # The resource class based on the controller # # Returns Object diff --git a/app/controllers/api/v0/departments_controller.rb b/app/controllers/api/v0/departments_controller.rb index 83e483cce7..e573522b78 100644 --- a/app/controllers/api/v0/departments_controller.rb +++ b/app/controllers/api/v0/departments_controller.rb @@ -47,16 +47,24 @@ def assign_users raise Pundit::NotAuthorizedError unless Api::V0::DepartmentsPolicy.new(@user, @department).assign_users? assign_users_to(@department.id) - redirect_to users_api_v0_departments_path + + # Added "status: :see_other" to redirect_to (as we require rediect to be a GET). + # See https://makandracards.com/makandra/38347-redirecting-responses-for-patch-or-delete-will-not-redirect-with-get + redirect_to users_api_v0_departments_path, status: :see_other end ## # Remove departments from the list of users def unassign_users - raise Pudndit::NotAuthorizedError unless Api::V0::DepartmentsPolicy.new(@user, @department).assign_users? + @department = Department.find(params[:id]) + + raise Pundit::NotAuthorizedError unless Api::V0::DepartmentsPolicy.new(@user, @department).assign_users? assign_users_to(nil) - redirect_to users_api_v0_departments_path + + # Added "status: :see_other" to redirect_to (as we require rediect to be a GET). + # See https://makandracards.com/makandra/38347-redirecting-responses-for-patch-or-delete-will-not-redirect-with-get + redirect_to users_api_v0_departments_path, status: :see_other end private diff --git a/app/controllers/api/v0/plans_controller.rb b/app/controllers/api/v0/plans_controller.rb index 51a77456a3..f81c0e7f68 100644 --- a/app/controllers/api/v0/plans_controller.rb +++ b/app/controllers/api/v0/plans_controller.rb @@ -29,6 +29,7 @@ def create # initialize the plan @plan = Plan.new + @plan.org = @user.org # Attach the user as the PI and Data Contact @plan.contributors << Contributor.new( @@ -48,8 +49,9 @@ def create end @plan.template = @template @plan.title = params[:plan][:title] + if @plan.save - @plan.assign_creator(plan_user) + @plan.add_user!(plan_user.id, :creator) respond_with @plan else # the plan did not save diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0253b5cef6..035029620f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base after_action :store_location include GlobalHelpers - include Pundit + include Pundit::Authorization helper_method GlobalHelpers.instance_methods rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized @@ -105,13 +105,13 @@ def authenticate_admin! end def failure_message(obj, action = 'save') - format(_('Unable to %s the %s.%s'), + format(_('Unable to %{action} the %{object}. {errors}'), object: obj_name_for_display(obj), action: action || 'save', errors: errors_for_display(obj)) end def success_message(obj, action = 'saved') - format(_('Successfully %s the %s.'), object: obj_name_for_display(obj), action: action || 'save') + format(_('Successfully %{action} the %{object}.'), object: obj_name_for_display(obj), action: action || 'save') end def errors_for_display(obj) diff --git a/app/controllers/concerns/paginable.rb b/app/controllers/concerns/paginable.rb index 62c7af8615..71d3eacb01 100644 --- a/app/controllers/concerns/paginable.rb +++ b/app/controllers/concerns/paginable.rb @@ -180,7 +180,7 @@ def sort_link_name(sort_field) style="float: right; font-size: 1.2em;"> - #{format(_('Sort by %'), sort_field: sort_field.split('.').first)} + #{format(_('Sort by %{sort_field}'), sort_field: sort_field.split('.').first)} HTML diff --git a/app/controllers/identifiers_controller.rb b/app/controllers/identifiers_controller.rb index 07f3530b80..5d01ac4959 100644 --- a/app/controllers/identifiers_controller.rb +++ b/app/controllers/identifiers_controller.rb @@ -16,10 +16,10 @@ def destroy if user.identifiers.include?(identifier) identifier.destroy! flash[:notice] = - format(_('Successfully unlinked your account from %s.'), is: identifier.identifier_scheme&.description) + format(_('Successfully unlinked your account from %{is}.'), is: identifier.identifier_scheme&.description) else flash[:alert] = - format(_('Unable to unlink your account from %s.'), is: identifier.identifier_scheme&.description) + format(_('Unable to unlink your account from %{is}.'), is: identifier.identifier_scheme&.description) end redirect_to edit_user_registration_path diff --git a/app/controllers/org_admin/plans_controller.rb b/app/controllers/org_admin/plans_controller.rb index 2c7ec2a396..7537f39ff7 100644 --- a/app/controllers/org_admin/plans_controller.rb +++ b/app/controllers/org_admin/plans_controller.rb @@ -33,7 +33,7 @@ def feedback_complete if plan.complete_feedback(current_user) # rubocop:disable Layout/LineLength redirect_to(org_admin_plans_path, - notice: format(_('%s has been notified that you have finished providing feedback'), plan_owner: plan.owner.name(false))) + notice: format(_('%{plan_owner} has been notified that you have finished providing feedback'), plan_owner: plan.owner.name(false))) # rubocop:enable Layout/LineLength else redirect_to org_admin_plans_path, diff --git a/app/controllers/org_admin/questions_controller.rb b/app/controllers/org_admin/questions_controller.rb index 1b19d53074..4e789df405 100644 --- a/app/controllers/org_admin/questions_controller.rb +++ b/app/controllers/org_admin/questions_controller.rb @@ -151,7 +151,7 @@ def update # version of the question # and also rewrite the remove_data question ids attrs = question_params - attrs = update_option_ids(attrs, old_to_new_opts) if new_version + attrs = update_option_ids(attrs, old_to_new_opts) if new_version && !attrs['question_options_attributes'].nil? # Need to reattach the incoming annotation's and question_options to the # modifiable (versioned) question diff --git a/app/controllers/org_admin/templates_controller.rb b/app/controllers/org_admin/templates_controller.rb index 1cc4c48d58..537ea4c5e4 100644 --- a/app/controllers/org_admin/templates_controller.rb +++ b/app/controllers/org_admin/templates_controller.rb @@ -44,7 +44,7 @@ def organisational @orgs = current_user.can_super_admin? ? Org.all : nil @title = if current_user.can_super_admin? - format(_('%s Templates'), org_name: current_user.org.name) + format(_('%{org_name} Templates'), org_name: current_user.org.name) else _('Own Templates') end @@ -212,7 +212,7 @@ def update rescue ActiveSupport::JSON.parse_error render(json: { status: :bad_request, - msg: format(_('Error parsing links for a %