Send current tab reference when filtering with search form

This commit is contained in:
Senén Rodero Rodríguez
2020-12-22 13:39:18 +01:00
parent c6407d82e3
commit 3ad14f4acb
2 changed files with 33 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
<%= component.select_tag :target_code, target_options, <%= component.select_tag :target_code, target_options,
include_blank: target_blank_option, include_blank: target_blank_option,
"aria-label": target_label %> "aria-label": target_label %>
<%= component.hidden_field_tag :filter, current_filter %>
<% end %> <% end %>
<%= render "shared/filter_subnav", i18n_namespace: "sdg_management.relations.index" %> <%= render "shared/filter_subnav", i18n_namespace: "sdg_management.relations.index" %>

View File

@@ -138,6 +138,7 @@ describe "SDG Relations", :js do
expect(page).to have_content "Internet speech freedom" expect(page).to have_content "Internet speech freedom"
expect(page).not_to have_content "SDG interest" expect(page).not_to have_content "SDG interest"
expect(page).to have_css "li.is-active h2", exact_text: "Pending"
end end
scenario "goal filter" do scenario "goal filter" do
@@ -150,19 +151,41 @@ describe "SDG Relations", :js do
expect(page).to have_content "School" expect(page).to have_content "School"
expect(page).not_to have_content "Hospital" expect(page).not_to have_content "Hospital"
expect(page).to have_css "li.is-active h2", exact_text: "Pending"
end end
end
scenario "target filter" do scenario "target filter" do
create(:budget_investment, title: "School", sdg_targets: [SDG::Target[4.1]]) create(:budget_investment, title: "School", sdg_targets: [SDG::Target[4.1]])
create(:budget_investment, title: "Preschool", sdg_targets: [SDG::Target[4.2]]) create(:budget_investment, title: "Preschool", sdg_targets: [SDG::Target[4.2]])
visit sdg_management_budget_investments_path visit sdg_management_budget_investments_path
select "4.1", from: "target_code" select "4.1", from: "target_code"
click_button "Search" click_button "Search"
expect(page).to have_content "School" expect(page).to have_content "School"
expect(page).not_to have_content "Preschool" expect(page).not_to have_content "Preschool"
expect(page).to have_css "li.is-active h2", exact_text: "Pending"
end
scenario "search within current tab" do
visit sdg_management_proposals_path(filter: "pending_sdg_review")
click_button "Search"
expect(page).to have_css "li.is-active h2", exact_text: "Pending"
visit sdg_management_proposals_path(filter: "sdg_reviewed")
click_button "Search"
expect(page).to have_css "li.is-active h2", exact_text: "Marked as reviewed"
visit sdg_management_proposals_path(filter: "all")
click_button "Search"
expect(page).to have_css "li.is-active h2", exact_text: "All"
end
end end
end end