While this bug was already present in the general admin search, the combination of both search and filters was very uncommon. I've only found this combinations in the users section, where you've got the "erased" filter, but in this case searching for erased users doesn't really make sense since their username and email have been deleted and so there's nothing to find. So the hidden content seemed to be the only affected section. However, we're adding the field to every section so we don't have to make sure we add it when we need it (like we did in the SDGManagement section).
32 lines
1.1 KiB
Ruby
32 lines
1.1 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Admin::SearchComponent do
|
|
describe "#hidden_current_filter_tag" do
|
|
context "controller responds to current_filter", controller: ApplicationController do
|
|
it "is present when the controller has a current filter" do
|
|
allow(controller).to receive(:current_filter).and_return("all")
|
|
|
|
render_inline Admin::SearchComponent.new(label: "Search")
|
|
|
|
expect(page).to have_field "filter", type: :hidden, with: "all"
|
|
end
|
|
|
|
it "is not present when the controller has no current filter" do
|
|
render_inline Admin::SearchComponent.new(label: "Search")
|
|
|
|
expect(page).not_to have_field "filter", type: :hidden
|
|
expect(page).not_to have_field "filter"
|
|
end
|
|
end
|
|
|
|
context "controller does not respond to current_filter", controller: ActionController::Base do
|
|
it "is not present" do
|
|
render_inline Admin::SearchComponent.new(label: "Search")
|
|
|
|
expect(page).not_to have_field "filter", type: :hidden
|
|
expect(page).not_to have_field "filter"
|
|
end
|
|
end
|
|
end
|
|
end
|