diff --git a/app/controllers/green_lanes/category_assessments_controller.rb b/app/controllers/green_lanes/category_assessments_controller.rb index 091bf871..0cae517f 100644 --- a/app/controllers/green_lanes/category_assessments_controller.rb +++ b/app/controllers/green_lanes/category_assessments_controller.rb @@ -5,7 +5,7 @@ class CategoryAssessmentsController < AuthenticatedController before_action :disable_service_switching! before_action :check_service def index - @category_assessments = GreenLanes::CategoryAssessment.all(page: current_page).fetch + @category_assessments = GreenLanes::CategoryAssessment.all(query: { exemption_code: params[:exemption_code], page: current_page}).fetch end def new diff --git a/app/views/green_lanes/category_assessments/index.html.erb b/app/views/green_lanes/category_assessments/index.html.erb index 24ea9cbf..931671df 100644 --- a/app/views/green_lanes/category_assessments/index.html.erb +++ b/app/views/green_lanes/category_assessments/index.html.erb @@ -4,6 +4,22 @@ <%= link_to 'Add a Category Assessment', new_green_lanes_category_assessment_path, class: 'govuk-button' %> +<%= form_with url: green_lanes_category_assessments_path, method: :get, class: "govuk-form-group" do |form| %> +
+ + Search Category Assessments + +
+ <%= form.label :exemption_code, "Green Lanes Exemption Code", class: "govuk-label" %> + <%= form.text_field :exemption_code, class: "govuk-input govuk-!-width-one-third", id: "search-term", width: 'one-third'%> +
+ +
+ <%= form.submit "Search", class: "govuk-button" %> +
+
+<% end %> + <% if @category_assessments.any? %> diff --git a/spec/requests/green_lanes/category_assessments_controller_spec.rb b/spec/requests/green_lanes/category_assessments_controller_spec.rb index 3e1399c9..74dd878c 100644 --- a/spec/requests/green_lanes/category_assessments_controller_spec.rb +++ b/spec/requests/green_lanes/category_assessments_controller_spec.rb @@ -14,7 +14,7 @@ describe 'GET #index' do before do - stub_api_request('/admin/green_lanes/category_assessments?page=1', backend: 'xi').and_return \ + stub_api_request('/admin/green_lanes/category_assessments?query[exemption_code]&query[page]=1', backend: 'xi').and_return \ jsonapi_response :category_assessments, attributes_for_list(:category_assessment, 3, :with_theme) end