diff --git a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/filter_options_component.html.erb b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/filter_options_component.html.erb index 0ffbc4c57ab..c78062adba4 100644 --- a/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/filter_options_component.html.erb +++ b/lib/engines/content_block_manager/app/components/content_block_manager/content_block/document/index/filter_options_component.html.erb @@ -60,8 +60,15 @@ ], } %> - <%= render "govuk_publishing_components/components/button", { - text: "View results", - margin_bottom: 4, - } %> +
+ <% end %> diff --git a/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/documents_controller.rb b/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/documents_controller.rb index 05b3788a504..a03c96e1d93 100644 --- a/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/documents_controller.rb +++ b/lib/engines/content_block_manager/app/controllers/content_block_manager/content_block/documents_controller.rb @@ -5,7 +5,7 @@ def index @filters = params_filters @content_block_documents = ContentBlockManager::ContentBlock::Document::DocumentFilter.new(@filters).documents render :index - elsif session_filters.any? + elsif params[:reset_fields].blank? && session_filters.any? redirect_to content_block_manager.content_block_manager_root_path(session_filters) else redirect_to content_block_manager.content_block_manager_root_path(default_filters) diff --git a/lib/engines/content_block_manager/test/components/content_block/document/index/filter_options_component_test.rb b/lib/engines/content_block_manager/test/components/content_block/document/index/filter_options_component_test.rb index c062f3f0410..31bd7ed1678 100644 --- a/lib/engines/content_block_manager/test/components/content_block/document/index/filter_options_component_test.rb +++ b/lib/engines/content_block_manager/test/components/content_block/document/index/filter_options_component_test.rb @@ -9,6 +9,7 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent.any_instance.stubs(:helpers).returns(helper_mock) helper_mock.stubs(:content_block_manager).returns(helper_mock) helper_mock.stubs(:content_block_manager_content_block_documents_path).returns("path") + helper_mock.stubs(:content_block_manager_root_path).returns("path") helper_mock.stubs(:taggable_organisations_container).returns( [["Department of Placeholder", 1], ["Ministry of Example", 2]], diff --git a/lib/engines/content_block_manager/test/integration/content_block/documents_test.rb b/lib/engines/content_block_manager/test/integration/content_block/documents_test.rb index 0464c42cf96..e0889cf50cc 100644 --- a/lib/engines/content_block_manager/test/integration/content_block/documents_test.rb +++ b/lib/engines/content_block_manager/test/integration/content_block/documents_test.rb @@ -69,12 +69,21 @@ class ContentBlockManager::ContentBlock::DocumentsTest < ActionDispatch::Integra end describe "when there are session filters" do - it "adds them to the params by default the next time user visits" do + before do visit content_block_manager.content_block_manager_content_block_documents_path({ keyword: "something" }) + end + + it "adds them to the params by default the next time user visits" do visit content_block_manager.content_block_manager_content_block_documents_path assert_current_path content_block_manager.content_block_manager_root_path({ keyword: "something" }) end + + it "resets the filters when reset_fields is set" do + visit content_block_manager.content_block_manager_content_block_documents_path({ reset_fields: true }) + + assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: @organisation.id.to_s }) + end end end