From 9b7afbed0b354b4cf9b16ce7c8d4329329b324ae Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Wed, 1 May 2024 17:32:53 +0100 Subject: [PATCH 01/14] GL-385: Create the first two steps of the Check Moving Requirement feature. Step1 is the /check_moving_requirements/start page Step2 is the /check_moving_requirements/edit page --- .../check_moving_requirements_controller.rb | 13 +++ app/models/check_moving_requirement.rb | 17 ++++ app/views/check_moving_requirements/edit.erb | 86 +++++++++++++++++++ .../check_moving_requirements/start.html.erb | 55 ++++++++++++ config/routes.rb | 8 ++ 5 files changed, 179 insertions(+) create mode 100644 app/controllers/check_moving_requirements_controller.rb create mode 100644 app/models/check_moving_requirement.rb create mode 100644 app/views/check_moving_requirements/edit.erb create mode 100644 app/views/check_moving_requirements/start.html.erb diff --git a/app/controllers/check_moving_requirements_controller.rb b/app/controllers/check_moving_requirements_controller.rb new file mode 100644 index 000000000..5ba088db9 --- /dev/null +++ b/app/controllers/check_moving_requirements_controller.rb @@ -0,0 +1,13 @@ +class CheckMovingRequirementsController < ApplicationController + def start + @commodity_code = params[:code] + render 'start' + end + + def edit + @commodity_code = params[:code] + + @check_moving_requirement = CheckMovingRequirement.new(commodity_code: @commodity_code) + render 'edit' + end +end diff --git a/app/models/check_moving_requirement.rb b/app/models/check_moving_requirement.rb new file mode 100644 index 000000000..18e2478a0 --- /dev/null +++ b/app/models/check_moving_requirement.rb @@ -0,0 +1,17 @@ +class CheckMovingRequirement + include ActiveModel::Model + include ActiveModel::Attributes + + attribute :commodity_code, :string + attribute :country_of_origin, :string + + attribute :day, :integer + attribute :month, :integer + attribute :years, :integer + + def validate_commodity_code + if commodity_code.lenght != 10 + errors.add(:commodity_code, :invalid_commodity_code, message: "Commodity code must have 10 digits") + end + end +end diff --git a/app/views/check_moving_requirements/edit.erb b/app/views/check_moving_requirements/edit.erb new file mode 100644 index 000000000..738463d1f --- /dev/null +++ b/app/views/check_moving_requirements/edit.erb @@ -0,0 +1,86 @@ +<% content_for :top_breadcrumbs do %> + <%= generate_breadcrumbs( + "Check measures for movements from GB to NI", + [ + [t('breadcrumb.home'), home_path], + ["Section", browse_sections_path], + ] + ) %> +<% end %> + + +<%= page_header do %> +

+ Tell us about your movement of goods +

+<% end %> + +

Details provided will help us display specific requirements for your goods.

+ +
+
+ + <%= form_with model:@check_moving_requirement, url: '/check_moving_requirement' do |f| %> + <%= f.label :commodity_code, "What is your commodity code?", class: 'govuk-heading-s' %> + +

+ Commodity codes are internationally recognised reference numbers that describe specific goods. + Search the Online Trade Tariff if you're unsure of your commodity code. +

+ + <%= f.text_field :commodity_code, class: "govuk-input", id: "commodity_code" %> + +
+ + <%= f.label :country_of_origin, "What is the origin of your goods?", class: 'govuk-heading-s' %> +

+ Origin allows for various policy measures to be implemented and for duties to be calculated. + Find out more about origin if you're unsure which country to select. +

+ + <%= f.text_field :country_of_origin, class: "govuk-input", id: "country_of_origin" %> + +
+ + <%= f.label :day, "When is the movement of goods taking place?", class: 'govuk-heading-s' %> + +

+ Requirements can change over time. If you are unsure of the date of movement and want to check requirements currently in place, enter today's date. +

+ +
+ <%= content_tag :legend, 'Enter the date for which you would like to return results', class: 'govuk-label' %> + <%= content_tag :div, 'If you leave this field blank, then today\'s date will be used', class: 'govuk-hint' %> + +
+
+
+ <%= f.label 'Day', class: 'govuk-label govuk-date-input__label', for: :day %> + <%= f.text_field :day, class: 'govuk-input govuk-input--width-2', maxlength: 2 %> +
+
+
+
+ <%= f.label 'Month', class: 'govuk-label govuk-date-input__label', for: :day %> + <%= f.text_field :month, class: 'govuk-input govuk-input--width-2', maxlength: 2 %> +
+
+
+
+ <%= f.label 'Year', class: 'govuk-label govuk-date-input__label', for: :day %> + <%= f.text_field :year, class: 'govuk-input govuk-input--width-4', maxlength: 4 %> +
+
+
+ +
+ + <%= f.submit "Continue", class: "govuk-button" %> + <% end %> + +

If you need help using this tool

+

+ Contaxt xxxxxxx ... +

+
+
diff --git a/app/views/check_moving_requirements/start.html.erb b/app/views/check_moving_requirements/start.html.erb new file mode 100644 index 000000000..7222e52f7 --- /dev/null +++ b/app/views/check_moving_requirements/start.html.erb @@ -0,0 +1,55 @@ +<% content_for :top_breadcrumbs do %> + <%= generate_breadcrumbs( + "Check measures for movements from GB to NI", + [ + [t('breadcrumb.home'), home_path], + ["Section", browse_sections_path], + ] + ) %> +<% end %> + +<%= page_header do %> +

+ Check arrangements for internal market movements +

+<% end %> + +
+
+

+ Use this tool if you are a trader moving goods from Great Britain to Northern Ireland and believe that your goods are 'not of risk' of onward movement to the EU. +

+ +

+ For eligible goods moving from Great Britain to Northern Ireland, traders can benefit from a simplified process for internal market movements. +

+ +

+ If you're based anywhere in the UK, you can join the UK Internal Market Scheme (UKIMS) to access the simplified process and benefit from reduced customs duties and checks. +

+ +

+ Use this tool to: +

    +
  • check if your goods could be eligible for the simplified process for internal market movements
  • +
  • check measures, criteria and exemptions for the movements of goods from Great Britain to Northern Ireland
  • +
  • find information required for your necessary form submissions
  • +
+ +

Before you start

+

+ You'll need to know: +

    +
  • that your goods are 'not at risk' of onward movement to the EU
  • +
  • the commodity code of the goods
  • +
  • the non-preferential origin of your goods
  • +
  • when the movement of goods is taking place
  • +
+

+ + <%= button_to "Start now", edit_check_moving_requirements_path, + method: :get, + params: { code: @commodity_code }, + class: "govuk-button" %> +
+
diff --git a/config/routes.rb b/config/routes.rb index 8da6fc326..b76ace302 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -215,6 +215,14 @@ end end + get '/check_moving_requirements/start', to: 'check_moving_requirements#start' + get '/check_moving_requirements/edit', to: 'check_moving_requirements#edit', as: :edit_check_moving_requirements + + # This solution does not work because edit action could have an empy commodity_code in the URL + # resources :check_moving_requirements, only: %i[show update edit] do + # get 'start', on: :collection + # end + get '/', to: redirect(TradeTariffFrontend.production? ? 'https://www.gov.uk/trade-tariff' : '/find_commodity', status: 302) get '/robots.:format', to: 'pages#robots' From 99105eaea1ff49d510d4ae5a59ea199003ccab29 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Fri, 3 May 2024 16:07:30 +0100 Subject: [PATCH 02/14] GL-385: Add validations for check_moving_requirements_form Improve error messages on locales/en.yml Create new initial page /result.html.erb Added missing specs for check_moving_requirements_controller --- .../check_moving_requirements_controller.rb | 22 ++++- app/forms/check_moving_requirements_form.rb | 13 +++ app/models/check_moving_requirement.rb | 17 ---- app/views/check_moving_requirements/edit.erb | 86 ------------------- .../check_moving_requirements/edit.html.erb | 65 ++++++++++++++ .../check_moving_requirements/result.html.erb | 15 ++++ config/locales/en.yml | 9 ++ config/routes.rb | 4 +- .../check_moving_requirements_form_spec.rb | 35 ++++++++ ...eck_moving_requirements_controller_spec.rb | 59 +++++++++++++ 10 files changed, 220 insertions(+), 105 deletions(-) create mode 100644 app/forms/check_moving_requirements_form.rb delete mode 100644 app/models/check_moving_requirement.rb delete mode 100644 app/views/check_moving_requirements/edit.erb create mode 100644 app/views/check_moving_requirements/edit.html.erb create mode 100644 app/views/check_moving_requirements/result.html.erb create mode 100644 spec/forms/check_moving_requirements_form_spec.rb create mode 100644 spec/requests/green_lanes/check_moving_requirements_controller_spec.rb diff --git a/app/controllers/check_moving_requirements_controller.rb b/app/controllers/check_moving_requirements_controller.rb index 5ba088db9..76b347050 100644 --- a/app/controllers/check_moving_requirements_controller.rb +++ b/app/controllers/check_moving_requirements_controller.rb @@ -6,8 +6,28 @@ def start def edit @commodity_code = params[:code] + @check_moving_requirements_form = CheckMovingRequirementsForm.new(commodity_code: @commodity_code) - @check_moving_requirement = CheckMovingRequirement.new(commodity_code: @commodity_code) render 'edit' end + + def update + @check_moving_requirements_form = CheckMovingRequirementsForm.new(check_moving_requirements_params) + + if @check_moving_requirements_form.valid? + redirect_to result_check_moving_requirements_path + else + render 'edit', status: :unprocessable_entity + end + end + + private + + def check_moving_requirements_params + params.require(:check_moving_requirements_form).permit( + :commodity_code, + :country_of_origin, + :moving_date, + ) + end end diff --git a/app/forms/check_moving_requirements_form.rb b/app/forms/check_moving_requirements_form.rb new file mode 100644 index 000000000..30d28bf2c --- /dev/null +++ b/app/forms/check_moving_requirements_form.rb @@ -0,0 +1,13 @@ +class CheckMovingRequirementsForm + include ActiveModel::Model + include ActiveModel::Attributes + include ActiveRecord::AttributeAssignment + + attribute :commodity_code, :string + attribute :country_of_origin, :string + attribute :moving_date, :date + + validates :commodity_code, length: { is: 10 } + validates :country_of_origin, presence: true + validates :moving_date, presence: true +end diff --git a/app/models/check_moving_requirement.rb b/app/models/check_moving_requirement.rb deleted file mode 100644 index 18e2478a0..000000000 --- a/app/models/check_moving_requirement.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CheckMovingRequirement - include ActiveModel::Model - include ActiveModel::Attributes - - attribute :commodity_code, :string - attribute :country_of_origin, :string - - attribute :day, :integer - attribute :month, :integer - attribute :years, :integer - - def validate_commodity_code - if commodity_code.lenght != 10 - errors.add(:commodity_code, :invalid_commodity_code, message: "Commodity code must have 10 digits") - end - end -end diff --git a/app/views/check_moving_requirements/edit.erb b/app/views/check_moving_requirements/edit.erb deleted file mode 100644 index 738463d1f..000000000 --- a/app/views/check_moving_requirements/edit.erb +++ /dev/null @@ -1,86 +0,0 @@ -<% content_for :top_breadcrumbs do %> - <%= generate_breadcrumbs( - "Check measures for movements from GB to NI", - [ - [t('breadcrumb.home'), home_path], - ["Section", browse_sections_path], - ] - ) %> -<% end %> - - -<%= page_header do %> -

- Tell us about your movement of goods -

-<% end %> - -

Details provided will help us display specific requirements for your goods.

- -
-
- - <%= form_with model:@check_moving_requirement, url: '/check_moving_requirement' do |f| %> - <%= f.label :commodity_code, "What is your commodity code?", class: 'govuk-heading-s' %> - -

- Commodity codes are internationally recognised reference numbers that describe specific goods. - Search the Online Trade Tariff if you're unsure of your commodity code. -

- - <%= f.text_field :commodity_code, class: "govuk-input", id: "commodity_code" %> - -
- - <%= f.label :country_of_origin, "What is the origin of your goods?", class: 'govuk-heading-s' %> -

- Origin allows for various policy measures to be implemented and for duties to be calculated. - Find out more about origin if you're unsure which country to select. -

- - <%= f.text_field :country_of_origin, class: "govuk-input", id: "country_of_origin" %> - -
- - <%= f.label :day, "When is the movement of goods taking place?", class: 'govuk-heading-s' %> - -

- Requirements can change over time. If you are unsure of the date of movement and want to check requirements currently in place, enter today's date. -

- -
- <%= content_tag :legend, 'Enter the date for which you would like to return results', class: 'govuk-label' %> - <%= content_tag :div, 'If you leave this field blank, then today\'s date will be used', class: 'govuk-hint' %> - -
-
-
- <%= f.label 'Day', class: 'govuk-label govuk-date-input__label', for: :day %> - <%= f.text_field :day, class: 'govuk-input govuk-input--width-2', maxlength: 2 %> -
-
-
-
- <%= f.label 'Month', class: 'govuk-label govuk-date-input__label', for: :day %> - <%= f.text_field :month, class: 'govuk-input govuk-input--width-2', maxlength: 2 %> -
-
-
-
- <%= f.label 'Year', class: 'govuk-label govuk-date-input__label', for: :day %> - <%= f.text_field :year, class: 'govuk-input govuk-input--width-4', maxlength: 4 %> -
-
-
- -
- - <%= f.submit "Continue", class: "govuk-button" %> - <% end %> - -

If you need help using this tool

-

- Contaxt xxxxxxx ... -

-
-
diff --git a/app/views/check_moving_requirements/edit.html.erb b/app/views/check_moving_requirements/edit.html.erb new file mode 100644 index 000000000..9180c5597 --- /dev/null +++ b/app/views/check_moving_requirements/edit.html.erb @@ -0,0 +1,65 @@ +<% content_for :top_breadcrumbs do %> + <%= generate_breadcrumbs( + "Check measures for movements from GB to NI", + [ + [t('breadcrumb.home'), home_path], + ["Section", browse_sections_path], + ] + ) %> +<% end %> + + +<%= page_header do %> +

+ Tell us about your movement of goods +

+<% end %> + +

Details provided will help us display specific requirements for your goods.

+ +
+
+ + <%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder, + method: :put, + url: update_check_moving_requirements_path do |f| %> + +

+ Commodity codes are internationally recognised reference numbers that describe specific goods. + Search the Online Trade Tariff if you're unsure of your commodity code. +

+ + <%= f.govuk_text_field :commodity_code, width: 'one-quarter', + label: { text: 'Commodity Code'} %> + +
+ + <%= f.label :country_of_origin, "What is the origin of your goods?", class: 'govuk-heading-s' %> +

+ Origin allows for various policy measures to be implemented and for duties to be calculated. + Find out more about origin if you're unsure which country to select. +

+ + <%= f.govuk_collection_select :country_of_origin, + GreenLanes::CategoryAssessmentSearch.country_options, + :id, + :long_description, + options: { include_blank: '' }, + label: { text: 'Select Origin' } %> + +
+ + <%= f.govuk_date_field :moving_date, + maxlength_enabled: true, + legend: { text: 'When is the movement of goods taking place?', size: 's', tag: 'h1' }, + hint: { text: "Arrangements can change over time. If you are unsure of the date of movement and want to check arrangements currently in place, enter today's date." } %> + + <%= f.submit "Continue", class: "govuk-button" %> + <% end %> + +

If you need help using this tool

+

+ Contaxt xxxxxxx ... +

+
+
diff --git a/app/views/check_moving_requirements/result.html.erb b/app/views/check_moving_requirements/result.html.erb new file mode 100644 index 000000000..3e4b6b5c9 --- /dev/null +++ b/app/views/check_moving_requirements/result.html.erb @@ -0,0 +1,15 @@ +<% content_for :top_breadcrumbs do %> + <%= generate_breadcrumbs( + "Check measures for movements from GB to NI", + [ + [t('breadcrumb.home'), home_path], + ["Section", browse_sections_path], + ] + ) %> +<% end %> + +<%= page_header do %> +

+ Requirements for your movement of goods +

+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e07774ad6..9cf8fd137 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -393,6 +393,15 @@ en: rule: inclusion: Select whether your goods meet any of these rules + check_moving_requirements_form: + attributes: + moving_date: + blank: Enter a valid date + country_of_origin: + blank: Select the country of origin + commodity_code: + wrong_length: Commodity code must have 10 digits + helpers: legend: rules_of_origin_steps_scheme: diff --git a/config/routes.rb b/config/routes.rb index b76ace302..4a91171eb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -215,8 +215,10 @@ end end - get '/check_moving_requirements/start', to: 'check_moving_requirements#start' + get '/check_moving_requirements/start', to: 'check_moving_requirements#start', as: :start_check_moving_requirements get '/check_moving_requirements/edit', to: 'check_moving_requirements#edit', as: :edit_check_moving_requirements + put '/check_moving_requirements/update', to: 'check_moving_requirements#update', as: :update_check_moving_requirements + get '/check_moving_requirements/result', to: 'check_moving_requirements#result', as: :result_check_moving_requirements # This solution does not work because edit action could have an empy commodity_code in the URL # resources :check_moving_requirements, only: %i[show update edit] do diff --git a/spec/forms/check_moving_requirements_form_spec.rb b/spec/forms/check_moving_requirements_form_spec.rb new file mode 100644 index 000000000..b03a3c8c1 --- /dev/null +++ b/spec/forms/check_moving_requirements_form_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +RSpec.describe CheckMovingRequirementsForm, type: :model do + describe 'validations' do + subject(:form) { described_class.new(params) } + + before { form.valid? } + + context 'when all the attributes are correct' do + let(:params) do + { + commodity_code: '1234567890', + country_of_origin: 'IT', + moving_date: { 1 => 1998, 2 => 12, 3 => 25 }, + } + end + + it { expect(form.errors).to be_empty } + end + + context 'when the attributes are incorrect' do + let(:params) do + { + commodity_code: '12345', + country_of_origin: '', + moving_date: { 1 => 1998, 2 => 12, 3 => nil }, + } + end + + it { expect(form.errors[:commodity_code]).to eq(['Commodity code must have 10 digits']) } + it { expect(form.errors[:country_of_origin]).to eq(['Select the country of origin']) } + it { expect(form.errors[:moving_date]).to eq(['Enter a valid date']) } + end + end +end diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb new file mode 100644 index 000000000..856daf681 --- /dev/null +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' + +RSpec.describe CheckMovingRequirementsController, type: :request do + subject { make_request && response } + + before do + allow(GreenLanes::CategoryAssessmentSearch).to receive(:country_options).and_return([]) + end + + describe 'GET #start' do + let(:make_request) do + get start_check_moving_requirements_path + end + + it { is_expected.to have_http_status :ok } + end + + describe 'GET #edit' do + let(:make_request) do + get edit_check_moving_requirements_path + end + + it { is_expected.to have_http_status :ok } + end + + describe 'PUT #update' do + context 'when all the form values are correct' do + let(:make_request) do + put update_check_moving_requirements_path, params: { + check_moving_requirements_form: { + commodity_code: '1234567890', + country_of_origin: 'IT', + 'moving_date(3i)' => '3', + 'moving_date(2i)' => '2', + 'moving_date(1i)' => '2022', + }, + } + end + + it { is_expected.to redirect_to(result_check_moving_requirements_path) } + end + + context 'when a value is missing or incorrect' do + let(:make_request) do + put update_check_moving_requirements_path, params: { + check_moving_requirements_form: { + commodity_code: '', + country_of_origin: 'IT', + 'moving_date(3i)' => '3', + 'moving_date(2i)' => '2', + 'moving_date(1i)' => '2022', + }, + } + end + + it { is_expected.to have_http_status :unprocessable_entity } + end + end +end From c40790bc9233116cbbfc36721b1a821729c654b7 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Tue, 7 May 2024 17:41:47 +0100 Subject: [PATCH 03/14] GL-385: Add feature flag to enable/disable check moving requirement pages --- .env.development | 1 + .env.test | 1 + .../check_moving_requirements_controller.rb | 8 ++++++++ lib/trade_tariff_frontend.rb | 4 ++++ .../check_moving_requirements_controller_spec.rb | 15 +++++++++++++++ 5 files changed, 29 insertions(+) diff --git a/.env.development b/.env.development index 267807510..d5756e641 100644 --- a/.env.development +++ b/.env.development @@ -10,6 +10,7 @@ BASIC_USERNAME=test BETA_SEARCH_HEADING_STATISTICS_THRESHOLD=3 BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD=5 BETA_SEARCH_SWITCHING_ENABLED=true +CHECK_MOVING_REQUIREMENTS_ENABLED=false DUTY_CALCULATOR=true DUTY_CALCULATOR_BASE_URL=http://localhost:3002/duty-calculator FRONTEND_HOST=http://localhost diff --git a/.env.test b/.env.test index a6f1f561a..1cbca582c 100644 --- a/.env.test +++ b/.env.test @@ -10,6 +10,7 @@ BASIC_USERNAME=test BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD=5 BETA_SEARCH_HEADING_STATISTICS_THRESHOLD=3 BETA_SEARCH_SWITCHING_ENABLED=true +CHECK_MOVING_REQUIREMENTS_ENABLED=false FRONTEND_HOST=http://test.host HOST=test.host NOTICE_BANNER="NOTICE|This service is currently being updated, some data might be missing." diff --git a/app/controllers/check_moving_requirements_controller.rb b/app/controllers/check_moving_requirements_controller.rb index 76b347050..1265607dd 100644 --- a/app/controllers/check_moving_requirements_controller.rb +++ b/app/controllers/check_moving_requirements_controller.rb @@ -1,4 +1,6 @@ class CheckMovingRequirementsController < ApplicationController + before_action :check_moving_requirements + def start @commodity_code = params[:code] render 'start' @@ -30,4 +32,10 @@ def check_moving_requirements_params :moving_date, ) end + + def check_moving_requirements + unless TradeTariffFrontend.check_moving_requirements_enabled? + raise TradeTariffFrontend::FeatureUnavailable + end + end end diff --git a/lib/trade_tariff_frontend.rb b/lib/trade_tariff_frontend.rb index f84437c51..60e7b3f85 100644 --- a/lib/trade_tariff_frontend.rb +++ b/lib/trade_tariff_frontend.rb @@ -169,6 +169,10 @@ def beta_search_facet_filter_display_percentage_threshold ENV['BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD'].to_i end + def check_moving_requirements_enabled? + ENV['CHECK_MOVING_REQUIREMENTS_ENABLED'] == 'true' + end + def legacy_results_to_show ENV.fetch('LEGACY_RESULTS_TO_SHOW', '5').to_i end diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb index 856daf681..def9d6dc3 100644 --- a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -5,6 +5,7 @@ before do allow(GreenLanes::CategoryAssessmentSearch).to receive(:country_options).and_return([]) + allow(TradeTariffFrontend).to receive(:check_moving_requirements_enabled?).and_return(true) end describe 'GET #start' do @@ -15,6 +16,20 @@ it { is_expected.to have_http_status :ok } end + describe 'when the feature "check moving requirements" is disabled' do + let(:make_request) do + get start_check_moving_requirements_path + end + + before do + allow(TradeTariffFrontend).to receive(:check_moving_requirements_enabled?).and_return(false) + end + + it { is_expected.to have_http_status :not_found } + + it { is_expected.to render_template 'errors/not_found' } + end + describe 'GET #edit' do let(:make_request) do get edit_check_moving_requirements_path From 79ad0b5124be03eb2d57353fa44dc66b89efe4db Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Wed, 8 May 2024 16:30:18 +0100 Subject: [PATCH 04/14] GL-385: Improve routes for check_moving_requirements --- .env.development | 2 +- app/views/check_moving_requirements/edit.html.erb | 2 +- config/routes.rb | 13 ++++--------- .../check_moving_requirements_controller_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.env.development b/.env.development index d5756e641..dde2995be 100644 --- a/.env.development +++ b/.env.development @@ -10,7 +10,7 @@ BASIC_USERNAME=test BETA_SEARCH_HEADING_STATISTICS_THRESHOLD=3 BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD=5 BETA_SEARCH_SWITCHING_ENABLED=true -CHECK_MOVING_REQUIREMENTS_ENABLED=false +GREEN_LANES_ENABLED=true DUTY_CALCULATOR=true DUTY_CALCULATOR_BASE_URL=http://localhost:3002/duty-calculator FRONTEND_HOST=http://localhost diff --git a/app/views/check_moving_requirements/edit.html.erb b/app/views/check_moving_requirements/edit.html.erb index 9180c5597..90444cc25 100644 --- a/app/views/check_moving_requirements/edit.html.erb +++ b/app/views/check_moving_requirements/edit.html.erb @@ -22,7 +22,7 @@ <%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder, method: :put, - url: update_check_moving_requirements_path do |f| %> + url: check_moving_requirements_path do |f| %>

Commodity codes are internationally recognised reference numbers that describe specific goods. diff --git a/config/routes.rb b/config/routes.rb index 4a91171eb..55d3efb0d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -215,15 +215,10 @@ end end - get '/check_moving_requirements/start', to: 'check_moving_requirements#start', as: :start_check_moving_requirements - get '/check_moving_requirements/edit', to: 'check_moving_requirements#edit', as: :edit_check_moving_requirements - put '/check_moving_requirements/update', to: 'check_moving_requirements#update', as: :update_check_moving_requirements - get '/check_moving_requirements/result', to: 'check_moving_requirements#result', as: :result_check_moving_requirements - - # This solution does not work because edit action could have an empy commodity_code in the URL - # resources :check_moving_requirements, only: %i[show update edit] do - # get 'start', on: :collection - # end + resource :check_moving_requirements, only: %i[update edit] do + get 'start' + get 'result' + end get '/', to: redirect(TradeTariffFrontend.production? ? 'https://www.gov.uk/trade-tariff' : '/find_commodity', status: 302) diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb index def9d6dc3..224ae39b1 100644 --- a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -41,7 +41,7 @@ describe 'PUT #update' do context 'when all the form values are correct' do let(:make_request) do - put update_check_moving_requirements_path, params: { + put check_moving_requirements_path, params: { check_moving_requirements_form: { commodity_code: '1234567890', country_of_origin: 'IT', @@ -57,7 +57,7 @@ context 'when a value is missing or incorrect' do let(:make_request) do - put update_check_moving_requirements_path, params: { + put check_moving_requirements_path, params: { check_moving_requirements_form: { commodity_code: '', country_of_origin: 'IT', From 05b19791424acf75bed6a163c5c25ce928832ebc Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Thu, 9 May 2024 11:31:39 +0100 Subject: [PATCH 05/14] GL-385: Rename Green Lanes feature flag. This PR renames and reuses the existing feature flag (to follow the current convention) ALLOW_GREEN_LANE -> GREEN_LANE_ENABLED --- .env.development | 3 +-- .env.test | 1 - app/controllers/check_moving_requirements_controller.rb | 2 +- .../green_lanes/category_assessments_controller.rb | 2 +- lib/trade_tariff_frontend.rb | 8 ++------ .../green_lanes/category_assessments_controller_spec.rb | 4 ++-- .../check_moving_requirements_controller_spec.rb | 4 ++-- terraform/README.md | 2 +- terraform/config_development.tfvars | 2 +- terraform/config_staging.tfvars | 2 +- terraform/main.tf | 4 ++-- terraform/variables.tf | 2 +- 12 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.env.development b/.env.development index dde2995be..a361d7b33 100644 --- a/.env.development +++ b/.env.development @@ -10,10 +10,10 @@ BASIC_USERNAME=test BETA_SEARCH_HEADING_STATISTICS_THRESHOLD=3 BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD=5 BETA_SEARCH_SWITCHING_ENABLED=true -GREEN_LANES_ENABLED=true DUTY_CALCULATOR=true DUTY_CALCULATOR_BASE_URL=http://localhost:3002/duty-calculator FRONTEND_HOST=http://localhost +GREEN_LANES_ENABLED=true HTTPARTY_READ_TIMEOUT=661 PERMUTATIONS=true PORT=3001 @@ -29,4 +29,3 @@ TARIFF_SUPPORT_EMAIL=support@example.com UPDATED_NAVIGATION=true WEBCHAT_URL='test-online-services-helpdesk' WELSH=true -ALLOW_GREEN_LANE=true diff --git a/.env.test b/.env.test index 1cbca582c..a6f1f561a 100644 --- a/.env.test +++ b/.env.test @@ -10,7 +10,6 @@ BASIC_USERNAME=test BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD=5 BETA_SEARCH_HEADING_STATISTICS_THRESHOLD=3 BETA_SEARCH_SWITCHING_ENABLED=true -CHECK_MOVING_REQUIREMENTS_ENABLED=false FRONTEND_HOST=http://test.host HOST=test.host NOTICE_BANNER="NOTICE|This service is currently being updated, some data might be missing." diff --git a/app/controllers/check_moving_requirements_controller.rb b/app/controllers/check_moving_requirements_controller.rb index 1265607dd..1aec21b3a 100644 --- a/app/controllers/check_moving_requirements_controller.rb +++ b/app/controllers/check_moving_requirements_controller.rb @@ -34,7 +34,7 @@ def check_moving_requirements_params end def check_moving_requirements - unless TradeTariffFrontend.check_moving_requirements_enabled? + unless TradeTariffFrontend.green_lanes_enabled? raise TradeTariffFrontend::FeatureUnavailable end end diff --git a/app/controllers/green_lanes/category_assessments_controller.rb b/app/controllers/green_lanes/category_assessments_controller.rb index a71d0366a..9dddea14a 100644 --- a/app/controllers/green_lanes/category_assessments_controller.rb +++ b/app/controllers/green_lanes/category_assessments_controller.rb @@ -31,7 +31,7 @@ def ca_search_params end def check_allowed - raise TradeTariffFrontend::FeatureUnavailable unless TradeTariffFrontend.green_lane_allowed? + raise TradeTariffFrontend::FeatureUnavailable unless TradeTariffFrontend.green_lanes_enabled? end end end diff --git a/lib/trade_tariff_frontend.rb b/lib/trade_tariff_frontend.rb index 60e7b3f85..7f6856045 100644 --- a/lib/trade_tariff_frontend.rb +++ b/lib/trade_tariff_frontend.rb @@ -169,16 +169,12 @@ def beta_search_facet_filter_display_percentage_threshold ENV['BETA_SEARCH_FACET_FILTER_DISPLAY_PERCENTAGE_THRESHOLD'].to_i end - def check_moving_requirements_enabled? - ENV['CHECK_MOVING_REQUIREMENTS_ENABLED'] == 'true' - end - def legacy_results_to_show ENV.fetch('LEGACY_RESULTS_TO_SHOW', '5').to_i end - def green_lane_allowed? - ENV['ALLOW_GREEN_LANE'].to_s == 'true' + def green_lanes_enabled? + ENV['GREEN_LANES_ENABLED'].to_s == 'true' end def green_lanes_api_token diff --git a/spec/requests/green_lanes/category_assessments_controller_spec.rb b/spec/requests/green_lanes/category_assessments_controller_spec.rb index 720402a21..3e74ffe87 100644 --- a/spec/requests/green_lanes/category_assessments_controller_spec.rb +++ b/spec/requests/green_lanes/category_assessments_controller_spec.rb @@ -4,7 +4,7 @@ subject { make_request && response } before do - allow(TradeTariffFrontend).to receive(:green_lane_allowed?).and_return true + allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return true allow(TradeTariffFrontend).to receive(:green_lanes_api_token).and_return '' allow(GeographicalArea).to receive(:all).and_return countries end @@ -94,7 +94,7 @@ context 'when green lanes is not allowed' do before do - allow(TradeTariffFrontend).to receive(:green_lane_allowed?).and_return false + allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return false end let(:make_request) { get green_lanes_category_assessments_path } diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb index 224ae39b1..94dfb8c86 100644 --- a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -5,7 +5,7 @@ before do allow(GreenLanes::CategoryAssessmentSearch).to receive(:country_options).and_return([]) - allow(TradeTariffFrontend).to receive(:check_moving_requirements_enabled?).and_return(true) + allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return(true) end describe 'GET #start' do @@ -22,7 +22,7 @@ end before do - allow(TradeTariffFrontend).to receive(:check_moving_requirements_enabled?).and_return(false) + allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return(false) end it { is_expected.to have_http_status :not_found } diff --git a/terraform/README.md b/terraform/README.md index 04d8c70c7..dac986878 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -46,7 +46,7 @@ Terraform to deploy the service into AWS. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [allow\_green\_lanes](#input\_allow\_green\_lanes) | Enable green lanes api UI in front end | `bool` | `false` | no | +| [allow\_green\_lanes](#input\_allow\_green\_lanes) | Enable green lanes api UI in front end | `bool` | `false` | no | | [base\_domain](#input\_base\_domain) | URL of the service. | `string` | n/a | yes | | [cpu](#input\_cpu) | CPU units to use. | `number` | n/a | yes | | [docker\_tag](#input\_docker\_tag) | Image tag to use. | `string` | n/a | yes | diff --git a/terraform/config_development.tfvars b/terraform/config_development.tfvars index 6bf9e6127..58b8dcfe5 100644 --- a/terraform/config_development.tfvars +++ b/terraform/config_development.tfvars @@ -4,4 +4,4 @@ base_domain = "dev.trade-tariff.service.gov.uk" cpu = 1024 memory = 2048 tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" -allow_green_lanes = true +green_lanes_enabled = true diff --git a/terraform/config_staging.tfvars b/terraform/config_staging.tfvars index aef140a4a..87a660c5b 100644 --- a/terraform/config_staging.tfvars +++ b/terraform/config_staging.tfvars @@ -7,4 +7,4 @@ service_count = 4 min_capacity = 2 max_capacity = 8 tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" -allow_green_lanes = true +green_lanes_enabled = true diff --git a/terraform/main.tf b/terraform/main.tf index 2e129ba8f..3561074b5 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -150,8 +150,8 @@ module "service" { value = var.environment }, { - name = "ALLOW_GREEN_LANE" - value = var.allow_green_lanes + name = "GREEN_LANES_ENABLED" + value = var.green_lanes_enabled }, ] diff --git a/terraform/variables.tf b/terraform/variables.tf index 29c72c723..d4c62da4c 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -51,7 +51,7 @@ variable "tariff_email_to" { type = string } -variable "allow_green_lanes" { +variable "green_lanes_enabled" { description = "Enable green lanes api UI in front end" type = bool default = false From 158a5f13641cdce95e571c356860345b4bd54591 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Thu, 9 May 2024 12:44:12 +0100 Subject: [PATCH 06/14] GL-385: move check_moving_requirements into GreenLane module --- .../check_moving_requirements_controller.rb | 41 ------------------ .../check_moving_requirements_controller.rb | 43 +++++++++++++++++++ .../check_moving_requirements/edit.html.erb | 2 +- .../check_moving_requirements/result.html.erb | 0 .../check_moving_requirements/start.html.erb | 2 +- config/routes.rb | 10 ++--- ...eck_moving_requirements_controller_spec.rb | 15 ++++--- 7 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 app/controllers/check_moving_requirements_controller.rb create mode 100644 app/controllers/green_lanes/check_moving_requirements_controller.rb rename app/views/{ => green_lanes}/check_moving_requirements/edit.html.erb (97%) rename app/views/{ => green_lanes}/check_moving_requirements/result.html.erb (100%) rename app/views/{ => green_lanes}/check_moving_requirements/start.html.erb (95%) diff --git a/app/controllers/check_moving_requirements_controller.rb b/app/controllers/check_moving_requirements_controller.rb deleted file mode 100644 index 1aec21b3a..000000000 --- a/app/controllers/check_moving_requirements_controller.rb +++ /dev/null @@ -1,41 +0,0 @@ -class CheckMovingRequirementsController < ApplicationController - before_action :check_moving_requirements - - def start - @commodity_code = params[:code] - render 'start' - end - - def edit - @commodity_code = params[:code] - @check_moving_requirements_form = CheckMovingRequirementsForm.new(commodity_code: @commodity_code) - - render 'edit' - end - - def update - @check_moving_requirements_form = CheckMovingRequirementsForm.new(check_moving_requirements_params) - - if @check_moving_requirements_form.valid? - redirect_to result_check_moving_requirements_path - else - render 'edit', status: :unprocessable_entity - end - end - - private - - def check_moving_requirements_params - params.require(:check_moving_requirements_form).permit( - :commodity_code, - :country_of_origin, - :moving_date, - ) - end - - def check_moving_requirements - unless TradeTariffFrontend.green_lanes_enabled? - raise TradeTariffFrontend::FeatureUnavailable - end - end -end diff --git a/app/controllers/green_lanes/check_moving_requirements_controller.rb b/app/controllers/green_lanes/check_moving_requirements_controller.rb new file mode 100644 index 000000000..1fc1a2bf1 --- /dev/null +++ b/app/controllers/green_lanes/check_moving_requirements_controller.rb @@ -0,0 +1,43 @@ +module GreenLanes + class CheckMovingRequirementsController < ApplicationController + before_action :check_moving_requirements + + def start + @commodity_code = params[:code] + render 'start' + end + + def edit + @commodity_code = params[:code] + @check_moving_requirements_form = CheckMovingRequirementsForm.new(commodity_code: @commodity_code) + + render 'edit' + end + + def update + @check_moving_requirements_form = CheckMovingRequirementsForm.new(check_moving_requirements_params) + + if @check_moving_requirements_form.valid? + redirect_to result_green_lanes_check_moving_requirements_path + else + render 'edit', status: :unprocessable_entity + end + end + + private + + def check_moving_requirements_params + params.require(:check_moving_requirements_form).permit( + :commodity_code, + :country_of_origin, + :moving_date, + ) + end + + def check_moving_requirements + unless TradeTariffFrontend.green_lanes_enabled? + raise TradeTariffFrontend::FeatureUnavailable + end + end + end +end diff --git a/app/views/check_moving_requirements/edit.html.erb b/app/views/green_lanes/check_moving_requirements/edit.html.erb similarity index 97% rename from app/views/check_moving_requirements/edit.html.erb rename to app/views/green_lanes/check_moving_requirements/edit.html.erb index 90444cc25..f8cfbea74 100644 --- a/app/views/check_moving_requirements/edit.html.erb +++ b/app/views/green_lanes/check_moving_requirements/edit.html.erb @@ -22,7 +22,7 @@ <%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder, method: :put, - url: check_moving_requirements_path do |f| %> + url: green_lanes_check_moving_requirements_path do |f| %>

Commodity codes are internationally recognised reference numbers that describe specific goods. diff --git a/app/views/check_moving_requirements/result.html.erb b/app/views/green_lanes/check_moving_requirements/result.html.erb similarity index 100% rename from app/views/check_moving_requirements/result.html.erb rename to app/views/green_lanes/check_moving_requirements/result.html.erb diff --git a/app/views/check_moving_requirements/start.html.erb b/app/views/green_lanes/check_moving_requirements/start.html.erb similarity index 95% rename from app/views/check_moving_requirements/start.html.erb rename to app/views/green_lanes/check_moving_requirements/start.html.erb index 7222e52f7..fc96f8ef2 100644 --- a/app/views/check_moving_requirements/start.html.erb +++ b/app/views/green_lanes/check_moving_requirements/start.html.erb @@ -47,7 +47,7 @@

- <%= button_to "Start now", edit_check_moving_requirements_path, + <%= button_to "Start now", edit_green_lanes_check_moving_requirements_path, method: :get, params: { code: @commodity_code }, class: "govuk-button" %> diff --git a/config/routes.rb b/config/routes.rb index 55d3efb0d..e7b0c8c2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,6 +110,11 @@ scope constraints: ->(_req) { TradeTariffFrontend::ServiceChooser.uk? } do namespace :green_lanes do resource :category_assessments, only: %i[create show] + + resource :check_moving_requirements, only: %i[update edit] do + get 'start' + get 'result' + end end end @@ -215,11 +220,6 @@ end end - resource :check_moving_requirements, only: %i[update edit] do - get 'start' - get 'result' - end - get '/', to: redirect(TradeTariffFrontend.production? ? 'https://www.gov.uk/trade-tariff' : '/find_commodity', status: 302) get '/robots.:format', to: 'pages#robots' diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb index 94dfb8c86..c7bce05bf 100644 --- a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe CheckMovingRequirementsController, type: :request do +RSpec.describe GreenLanes::CheckMovingRequirementsController, type: :request do subject { make_request && response } before do @@ -10,7 +10,7 @@ describe 'GET #start' do let(:make_request) do - get start_check_moving_requirements_path + get start_green_lanes_check_moving_requirements_path end it { is_expected.to have_http_status :ok } @@ -18,7 +18,7 @@ describe 'when the feature "check moving requirements" is disabled' do let(:make_request) do - get start_check_moving_requirements_path + get start_green_lanes_check_moving_requirements_path end before do @@ -32,8 +32,9 @@ describe 'GET #edit' do let(:make_request) do - get edit_check_moving_requirements_path + get edit_green_lanes_check_moving_requirements_path end + it { is_expected.to have_http_status :ok } end @@ -41,7 +42,7 @@ describe 'PUT #update' do context 'when all the form values are correct' do let(:make_request) do - put check_moving_requirements_path, params: { + put green_lanes_check_moving_requirements_path, params: { check_moving_requirements_form: { commodity_code: '1234567890', country_of_origin: 'IT', @@ -52,12 +53,12 @@ } end - it { is_expected.to redirect_to(result_check_moving_requirements_path) } + it { is_expected.to redirect_to(result_green_lanes_check_moving_requirements_path) } end context 'when a value is missing or incorrect' do let(:make_request) do - put check_moving_requirements_path, params: { + put green_lanes_check_moving_requirements_path, params: { check_moving_requirements_form: { commodity_code: '', country_of_origin: 'IT', From 3507360d0b744bc87781f8a59efdce36d1b62bf2 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Thu, 9 May 2024 12:57:05 +0100 Subject: [PATCH 07/14] GL-385: Fix string too long. --- .../green_lanes/check_moving_requirements/edit.html.erb | 8 +++++--- config/routes.rb | 4 ++-- .../check_moving_requirements_controller_spec.rb | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/green_lanes/check_moving_requirements/edit.html.erb b/app/views/green_lanes/check_moving_requirements/edit.html.erb index f8cfbea74..5f1cedf86 100644 --- a/app/views/green_lanes/check_moving_requirements/edit.html.erb +++ b/app/views/green_lanes/check_moving_requirements/edit.html.erb @@ -29,8 +29,7 @@ Search the Online Trade Tariff if you're unsure of your commodity code.

- <%= f.govuk_text_field :commodity_code, width: 'one-quarter', - label: { text: 'Commodity Code'} %> + <%= f.govuk_text_field :commodity_code, width: 'one-quarter', label: { text: 'Commodity Code'} %>
@@ -52,7 +51,10 @@ <%= f.govuk_date_field :moving_date, maxlength_enabled: true, legend: { text: 'When is the movement of goods taking place?', size: 's', tag: 'h1' }, - hint: { text: "Arrangements can change over time. If you are unsure of the date of movement and want to check arrangements currently in place, enter today's date." } %> + hint: { text: "Arrangements can change over time. If you are unsure of the date of " \ + "movement and want to check arrangements currently in place, enter today's date." + } + %> <%= f.submit "Continue", class: "govuk-button" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index e7b0c8c2f..87e31c8e0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,11 +110,11 @@ scope constraints: ->(_req) { TradeTariffFrontend::ServiceChooser.uk? } do namespace :green_lanes do resource :category_assessments, only: %i[create show] - + resource :check_moving_requirements, only: %i[update edit] do get 'start' get 'result' - end + end end end diff --git a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb index c7bce05bf..075a032cd 100644 --- a/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb +++ b/spec/requests/green_lanes/check_moving_requirements_controller_spec.rb @@ -34,7 +34,6 @@ let(:make_request) do get edit_green_lanes_check_moving_requirements_path end - it { is_expected.to have_http_status :ok } end From 5d627fc9edec9c587f0501e57c076cd15c3abb30 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Thu, 9 May 2024 15:40:10 +0100 Subject: [PATCH 08/14] Fix a terraform variable --- terraform/config_development.tfvars | 12 ++++++------ terraform/config_staging.tfvars | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/terraform/config_development.tfvars b/terraform/config_development.tfvars index 58b8dcfe5..d0c82e0dc 100644 --- a/terraform/config_development.tfvars +++ b/terraform/config_development.tfvars @@ -1,7 +1,7 @@ -region = "eu-west-2" -environment = "development" -base_domain = "dev.trade-tariff.service.gov.uk" -cpu = 1024 -memory = 2048 -tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" +region = "eu-west-2" +environment = "development" +base_domain = "dev.trade-tariff.service.gov.uk" +cpu = 1024 +memory = 2048 +tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" green_lanes_enabled = true diff --git a/terraform/config_staging.tfvars b/terraform/config_staging.tfvars index 87a660c5b..7eb10d83a 100644 --- a/terraform/config_staging.tfvars +++ b/terraform/config_staging.tfvars @@ -1,10 +1,10 @@ -region = "eu-west-2" -environment = "staging" -base_domain = "staging.trade-tariff.service.gov.uk" -cpu = 1024 -memory = 2048 -service_count = 4 -min_capacity = 2 -max_capacity = 8 -tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" +region = "eu-west-2" +environment = "staging" +base_domain = "staging.trade-tariff.service.gov.uk" +cpu = 1024 +memory = 2048 +service_count = 4 +min_capacity = 2 +max_capacity = 8 +tariff_email_to = "hmrc-trade-tariff-support-g@digital.hmrc.gov.uk" green_lanes_enabled = true From d02612c7e7a393cf73de4a1a9dfb0977855b43b9 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Thu, 9 May 2024 15:40:37 +0100 Subject: [PATCH 09/14] GL-385: refactor: move check_moving_requirements_form under green_lanes module --- app/forms/check_moving_requirements_form.rb | 13 ------------- .../green_lanes/check_moving_requirements_form.rb | 15 +++++++++++++++ config/locales/en.yml | 2 +- .../check_moving_requirements_form_spec.rb | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) delete mode 100644 app/forms/check_moving_requirements_form.rb create mode 100644 app/forms/green_lanes/check_moving_requirements_form.rb rename spec/forms/{ => green_lanes}/check_moving_requirements_form_spec.rb (92%) diff --git a/app/forms/check_moving_requirements_form.rb b/app/forms/check_moving_requirements_form.rb deleted file mode 100644 index 30d28bf2c..000000000 --- a/app/forms/check_moving_requirements_form.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CheckMovingRequirementsForm - include ActiveModel::Model - include ActiveModel::Attributes - include ActiveRecord::AttributeAssignment - - attribute :commodity_code, :string - attribute :country_of_origin, :string - attribute :moving_date, :date - - validates :commodity_code, length: { is: 10 } - validates :country_of_origin, presence: true - validates :moving_date, presence: true -end diff --git a/app/forms/green_lanes/check_moving_requirements_form.rb b/app/forms/green_lanes/check_moving_requirements_form.rb new file mode 100644 index 000000000..3543e5841 --- /dev/null +++ b/app/forms/green_lanes/check_moving_requirements_form.rb @@ -0,0 +1,15 @@ +module GreenLanes + class CheckMovingRequirementsForm + include ActiveModel::Model + include ActiveModel::Attributes + include ActiveRecord::AttributeAssignment + + attribute :commodity_code, :string + attribute :country_of_origin, :string + attribute :moving_date, :date + + validates :commodity_code, length: { is: 10 } + validates :country_of_origin, presence: true + validates :moving_date, presence: true + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9cf8fd137..bfd1cdaea 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -393,7 +393,7 @@ en: rule: inclusion: Select whether your goods meet any of these rules - check_moving_requirements_form: + green_lanes/check_moving_requirements_form: attributes: moving_date: blank: Enter a valid date diff --git a/spec/forms/check_moving_requirements_form_spec.rb b/spec/forms/green_lanes/check_moving_requirements_form_spec.rb similarity index 92% rename from spec/forms/check_moving_requirements_form_spec.rb rename to spec/forms/green_lanes/check_moving_requirements_form_spec.rb index b03a3c8c1..5d1af6798 100644 --- a/spec/forms/check_moving_requirements_form_spec.rb +++ b/spec/forms/green_lanes/check_moving_requirements_form_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -RSpec.describe CheckMovingRequirementsForm, type: :model do +RSpec.describe GreenLanes::CheckMovingRequirementsForm, type: :model do describe 'validations' do subject(:form) { described_class.new(params) } From 7b46c1473887abed4441fe3d85fe460aa0917744 Mon Sep 17 00:00:00 2001 From: Alexdesi Date: Mon, 13 May 2024 17:16:41 +0100 Subject: [PATCH 10/14] GL-385: Various design improvement on check_moving_requirements/start and check_moving_requirements/edit pages. --- .../check_moving_requirements_controller.rb | 5 +- .../check_moving_requirements/edit.html.erb | 83 ++++++++++--------- .../check_moving_requirements/start.html.erb | 59 +++++++++---- .../meursing_lookup/steps/_start.html.erb | 4 +- .../shared/_feedback_useful_banner.html.erb | 2 +- app/views/shared/_start_arrow.html.erb | 3 + 6 files changed, 92 insertions(+), 64 deletions(-) create mode 100644 app/views/shared/_start_arrow.html.erb diff --git a/app/controllers/green_lanes/check_moving_requirements_controller.rb b/app/controllers/green_lanes/check_moving_requirements_controller.rb index 1fc1a2bf1..115771a8d 100644 --- a/app/controllers/green_lanes/check_moving_requirements_controller.rb +++ b/app/controllers/green_lanes/check_moving_requirements_controller.rb @@ -1,6 +1,7 @@ module GreenLanes class CheckMovingRequirementsController < ApplicationController - before_action :check_moving_requirements + before_action :check_moving_requirements, + :disable_switch_service_banner def start @commodity_code = params[:code] @@ -27,7 +28,7 @@ def update private def check_moving_requirements_params - params.require(:check_moving_requirements_form).permit( + params.require(:green_lanes_check_moving_requirements_form).permit( :commodity_code, :country_of_origin, :moving_date, diff --git a/app/views/green_lanes/check_moving_requirements/edit.html.erb b/app/views/green_lanes/check_moving_requirements/edit.html.erb index 5f1cedf86..c3e7d76b9 100644 --- a/app/views/green_lanes/check_moving_requirements/edit.html.erb +++ b/app/views/green_lanes/check_moving_requirements/edit.html.erb @@ -1,67 +1,68 @@ -<% content_for :top_breadcrumbs do %> - <%= generate_breadcrumbs( - "Check measures for movements from GB to NI", - [ - [t('breadcrumb.home'), home_path], - ["Section", browse_sections_path], - ] - ) %> -<% end %> - - -<%= page_header do %> -

- Tell us about your movement of goods -

-<% end %> - -

Details provided will help us display specific requirements for your goods.

+<%= back_link start_green_lanes_check_moving_requirements_path %>
- <%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder, - method: :put, - url: green_lanes_check_moving_requirements_path do |f| %> +
+ + Check arrangements for internal market movements + -

- Commodity codes are internationally recognised reference numbers that describe specific goods. - Search the Online Trade Tariff if you're unsure of your commodity code. -

+

+ Tell us about your movement of goods +

+
- <%= f.govuk_text_field :commodity_code, width: 'one-quarter', label: { text: 'Commodity Code'} %> + <%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder, + method: :put, + url: green_lanes_check_moving_requirements_path do |f| %> -
+ <%= f.govuk_error_summary %> - <%= f.label :country_of_origin, "What is the origin of your goods?", class: 'govuk-heading-s' %> -

- Origin allows for various policy measures to be implemented and for duties to be calculated. - Find out more about origin if you're unsure which country to select. -

+

Details provided will help us display specific requirements for your goods.

+ + <%= f.govuk_text_field :commodity_code, maxlength: 10, + label: { text: "What is your commodity code?", size: 's'}, + hint: { text: "Commodity codes are internationally recognised reference numbers that describe specific goods." \ + "Search the Online Trade Tariff if you're unsure of your commodity code.", + }, + style: "width:330px" + %> <%= f.govuk_collection_select :country_of_origin, GreenLanes::CategoryAssessmentSearch.country_options, :id, :long_description, options: { include_blank: '' }, - label: { text: 'Select Origin' } %> + label: { text: "What is the origin of your goods?", size: 's' }, + hint: { text: "Origin allows for various policy measures to be implemented and for duties" \ + "to be calculated. Find out more about origin if you're unsure which country to select.", + }, + style: "width:330px" + %> -
+ <%= f.label :commodity_code, "When is the movement of goods taking place?", class: 'govuk-heading-s', + for: 'green_lanes_check_moving_requirements_form_moving_date_3i' %> <%= f.govuk_date_field :moving_date, maxlength_enabled: true, - legend: { text: 'When is the movement of goods taking place?', size: 's', tag: 'h1' }, hint: { text: "Arrangements can change over time. If you are unsure of the date of " \ - "movement and want to check arrangements currently in place, enter today's date." - } - %> + "movement and want to check arrangements currently in place, enter today's date.", + class: 'govuk-body-l' + }, + legend: nil %> - <%= f.submit "Continue", class: "govuk-button" %> + <%= f.submit "Continue", class: "govuk-button" %> <% end %> -

If you need help using this tool

+

If you need help using this tool

- Contaxt xxxxxxx ... + Contact xxxxxxx ...

+
    +
  • aaaaa +
  • bbbbb +
  • ccccc +
diff --git a/app/views/green_lanes/check_moving_requirements/start.html.erb b/app/views/green_lanes/check_moving_requirements/start.html.erb index fc96f8ef2..994e090ae 100644 --- a/app/views/green_lanes/check_moving_requirements/start.html.erb +++ b/app/views/green_lanes/check_moving_requirements/start.html.erb @@ -1,21 +1,13 @@ -<% content_for :top_breadcrumbs do %> - <%= generate_breadcrumbs( - "Check measures for movements from GB to NI", - [ - [t('breadcrumb.home'), home_path], - ["Section", browse_sections_path], - ] - ) %> -<% end %> - -<%= page_header do %> -

- Check arrangements for internal market movements -

-<% end %> +<%= back_link home_path %>
+
+

+ Check arrangements for internal market movements +

+
+

Use this tool if you are a trader moving goods from Great Britain to Northern Ireland and believe that your goods are 'not of risk' of onward movement to the EU.

@@ -47,9 +39,42 @@

- <%= button_to "Start now", edit_green_lanes_check_moving_requirements_path, + <%= button_to edit_green_lanes_check_moving_requirements_path, method: :get, params: { code: @commodity_code }, - class: "govuk-button" %> + class: "govuk-button govuk-button--start" do %> + + Start now + <%= render 'shared/start_arrow' %> + <% end %> + +

If you need help using this tool

+

+ Contact xxxxxxx ... +

+
    +
  • aaaaa +
  • bbbbb +
  • ccccc +
+
+ +
+
diff --git a/app/views/meursing_lookup/steps/_start.html.erb b/app/views/meursing_lookup/steps/_start.html.erb index 5b8977a78..6e1578170 100644 --- a/app/views/meursing_lookup/steps/_start.html.erb +++ b/app/views/meursing_lookup/steps/_start.html.erb @@ -36,9 +36,7 @@ role="button" draggable="false" class="govuk-button govuk-!-margin-top-2 govuk-!-margin-bottom-8 govuk-button--start" data-module="govuk-button"> Start now - + <%= render 'shared/start_arrow' %>

Documents to download

diff --git a/app/views/shared/_feedback_useful_banner.html.erb b/app/views/shared/_feedback_useful_banner.html.erb index 7d5a4a498..4e95da354 100644 --- a/app/views/shared/_feedback_useful_banner.html.erb +++ b/app/views/shared/_feedback_useful_banner.html.erb @@ -2,7 +2,7 @@