Skip to content

Commit

Permalink
Remove "disable autocomplete" feature flag
Browse files Browse the repository at this point in the history
We are centralising the enabling/disabling of autocomplete in Search API
v2 so we don't need individual feature flags across several apps.

- Use search_with_autocomplete component directly
- Remove ApplicationHelper#search_component
  • Loading branch information
csutter committed Jan 8, 2025
1 parent cb655be commit 8d2395a
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 69 deletions.
6 changes: 0 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ module ApplicationHelper
def absolute_url_for(path)
URI.join(Plek.new.website_root, path)
end

def search_component
use_autocomplete = true unless ENV["GOVUK_DISABLE_SEARCH_AUTOCOMPLETE"]

use_autocomplete ? "search_with_autocomplete" : "search"
end
end
2 changes: 1 addition & 1 deletion app/views/finders/show_all_content_finder.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<div id="keywords" role="search" aria-label="Sitewide">
<%= render "govuk_publishing_components/components/#{search_component}", {
<%= render "govuk_publishing_components/components/search_with_autocomplete", {
id: "finder-keyword-search",
name: "keywords",
type: 'search',
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_search_field.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
} %>
<% end %>

<%= render "govuk_publishing_components/components/#{search_component}", {
<%= render "govuk_publishing_components/components/search_with_autocomplete", {
inline_label: false,
label_text: label_text,
size: "large",
Expand Down
19 changes: 0 additions & 19 deletions spec/controllers/finders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,6 @@
expect(response.status).to eq(200)
expect(response).to render_template("finders/show_all_content_finder")
end

describe "search autocomplete" do
it "renders the search autocomplete when enabled" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: nil do
get :show, params: { slug: "search/all", keywords: "hello" }

expect(response.body).to include("gem-c-search-with-autocomplete")
end
end

it "does not render the autocomplete when disabled" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: "1" do
get :show, params: { slug: "search/all", keywords: "hello" }

expect(response.body).not_to include("gem-c-search-with-autocomplete")
expect(response.body).to include("gem-c-search")
end
end
end
end
end

Expand Down
21 changes: 0 additions & 21 deletions spec/controllers/search_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,5 @@
expect(response).to redirect_to(destination)
end
end

context "when GOVUK_DISABLE_SEARCH_AUTOCOMPLETE is not set" do
it "renders the search autocomplete component" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: nil do
get :index

expect(response.body).to include("gem-c-search-with-autocomplete")
end
end
end

context "when GOVUK_DISABLE_SEARCH_AUTOCOMPLETE is set" do
it "renders the search component instead of the autocomplete component" do
ClimateControl.modify GOVUK_DISABLE_SEARCH_AUTOCOMPLETE: "1" do
get :index

expect(response.body).not_to include("gem-c-search-with-autocomplete")
expect(response.body).to include("gem-c-search")
end
end
end
end
end
21 changes: 0 additions & 21 deletions spec/helpers/application_helper_spec.rb

This file was deleted.

0 comments on commit 8d2395a

Please sign in to comment.