<%= f.label :tag_list, t("legislation.proposals.form.tags_label") %>
diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb
index b784e3ff8..5537fbba5 100644
--- a/app/views/legislation/proposals/_proposal.html.erb
+++ b/app/views/legislation/proposals/_proposal.html.erb
@@ -53,6 +53,13 @@
<%= t("shared.collective") %>
<% end %>
+
+ <% if Geozone.any? %>
+
<%= proposal.summary %>
diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb
index 0dc8654d0..a264f147f 100644
--- a/app/views/legislation/proposals/show.html.erb
+++ b/app/views/legislation/proposals/show.html.erb
@@ -94,7 +94,7 @@
<%= render "shared/tags", taggable: @proposal %>
- <%= render "shared/geozone", geozonable: @proposal %>
+ <%= render Shared::GeozoneLinkComponent.new(@proposal, legislation_process_proposals_path(@process, search: geozone_name(@proposal))) %>
<%= render "legislation/proposals/actions", proposal: @proposal %>
diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb
index 934baced9..425d75537 100644
--- a/app/views/proposals/_proposal.html.erb
+++ b/app/views/proposals/_proposal.html.erb
@@ -52,6 +52,13 @@
<%= t("shared.collective") %>
<% end %>
+
+ <% if Geozone.any? %>
+
•
+
+ <%= link_to geozone_name(proposal), proposals_path(search: geozone_name(proposal)) %>
+
+ <% end %>
<%= proposal.summary %>
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb
index 411b0d32b..57dd73dc6 100644
--- a/app/views/proposals/index.html.erb
+++ b/app/views/proposals/index.html.erb
@@ -119,7 +119,7 @@
<% if params[:retired].blank? %>
<%= render "categories" %>
<%= render "shared/tag_cloud", taggable: "Proposal" %>
- <%= render "geozones" %>
+ <%= render Proposals::GeozonesComponent.new %>
<% end %>
<%= render "retired" %>
<%= render "proposals_lists" %>
diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb
index 02dc1c38c..ea2c5e844 100644
--- a/app/views/proposals/show.html.erb
+++ b/app/views/proposals/show.html.erb
@@ -40,7 +40,7 @@
<% end %>
<%= render "proposals/info", proposal: @proposal %>
- <%= render "shared/geozone", geozonable: @proposal %>
+ <%= render Shared::GeozoneLinkComponent.new(@proposal, proposals_path(search: geozone_name(@proposal))) %>
<% unless @proposal.selected? %>
<%= render "relationable/related_content", relationable: @proposal %>
diff --git a/app/views/proposals/summary.html.erb b/app/views/proposals/summary.html.erb
index e7a86ed6d..9f74c3963 100644
--- a/app/views/proposals/summary.html.erb
+++ b/app/views/proposals/summary.html.erb
@@ -46,7 +46,7 @@
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: "button radius expand" %>
<%= render "shared/tag_cloud", taggable: "Proposal" %>
<%= render "categories" %>
- <%= render "geozones" %>
+ <%= render Proposals::GeozonesComponent.new %>
diff --git a/app/views/shared/_geozone.html.erb b/app/views/shared/_geozone.html.erb
deleted file mode 100644
index 36ce1ebea..000000000
--- a/app/views/shared/_geozone.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-
- -
- <%= link_to geozone_name(geozonable), proposals_path(search: geozone_name(geozonable)) %>
-
-
diff --git a/spec/components/proposals/geozones_component_spec.rb b/spec/components/proposals/geozones_component_spec.rb
new file mode 100644
index 000000000..af6284ff7
--- /dev/null
+++ b/spec/components/proposals/geozones_component_spec.rb
@@ -0,0 +1,19 @@
+require "rails_helper"
+
+describe Proposals::GeozonesComponent do
+ let(:component) { Proposals::GeozonesComponent.new() }
+
+ it "is not rendered when there are no geozones defined" do
+ render_inline component
+
+ expect(page).not_to have_content "Districts"
+ end
+
+ it "is rendered when there are geozones defined" do
+ create(:geozone)
+
+ render_inline component
+
+ expect(page).to have_content "Districts"
+ end
+end
diff --git a/spec/system/admin/site_customization/images_spec.rb b/spec/system/admin/site_customization/images_spec.rb
index 85f3736ee..9e0a1a142 100644
--- a/spec/system/admin/site_customization/images_spec.rb
+++ b/spec/system/admin/site_customization/images_spec.rb
@@ -31,6 +31,7 @@ describe "Admin custom images", :admin do
end
scenario "Image is replaced on front views" do
+ create(:geozone)
budget = create(:budget)
group = create(:budget_group, budget: budget)
diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb
index 80eef133f..afcbf7ef4 100644
--- a/spec/system/legislation/proposals_spec.rb
+++ b/spec/system/legislation/proposals_spec.rb
@@ -236,4 +236,72 @@ describe "Legislation Proposals" do
expect(page).to have_link("Culture")
end
+
+ scenario "Shows geozone tag as proposals filter where there are geozones defined" do
+ create(:legislation_proposal, process: process)
+ create(:legislation_proposal, process: process, geozone: create(:geozone, name: "Zone1"))
+
+ visit legislation_process_proposals_path(process)
+
+ expect(page).to have_link("Zone1", href: legislation_process_proposals_path(process, search: "Zone1"))
+ link = legislation_process_proposals_path(process, search: "All city")
+ expect(page).to have_link("All city", href: link)
+ end
+
+ scenario "Does not show the geozone tag when no geozones defined" do
+ create(:legislation_proposal, process: process)
+
+ visit legislation_process_proposals_path(process)
+
+ expect(page).not_to have_link("All city")
+ end
+
+ scenario "Can filter proposals by geozone" do
+ geozone = create(:geozone, name: "Zone1")
+ proposal = create(:legislation_proposal, title: "Proposal with geozone",
+ legislation_process_id: process.id,
+ geozone: geozone)
+ create(:legislation_proposal, title: "Proposal without geozone", legislation_process_id: process.id)
+
+ visit legislation_process_proposal_path(proposal.process, proposal)
+ click_link "Zone1"
+
+ expect(page).to have_current_path(legislation_process_proposals_path(process.id, search: "Zone1"))
+ expect(page).to have_content("Proposal with geozone")
+ expect(page).not_to have_content("Proposal without geozone")
+ end
+
+ scenario "Show link to filter by geozone where there are geozones defined" do
+ create(:geozone)
+ create(:legislation_proposal, legislation_process_id: process.id)
+
+ visit legislation_process_proposal_path(proposal.process, proposal)
+
+ expect(page).to have_link("All city")
+ end
+
+ scenario "Do not show link to geozone where there are no geozones defined" do
+ create(:legislation_proposal, legislation_process_id: process.id)
+
+ visit legislation_process_proposal_path(proposal.process, proposal)
+
+ expect(page).not_to have_link("All city")
+ end
+
+ scenario "form shows the geozone selector when there are geozones defined" do
+ create(:geozone)
+ login_as user
+
+ visit new_legislation_process_proposal_path(process)
+
+ expect(page).to have_field("Scope of operation")
+ end
+
+ scenario "form do not show geozone selector when there are no geozones defined" do
+ login_as user
+
+ visit new_legislation_process_proposal_path(process)
+
+ expect(page).not_to have_field("Scope of operation")
+ end
end
diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb
index 19d7ffa9a..bf0dcb2a9 100644
--- a/spec/system/proposals_spec.rb
+++ b/spec/system/proposals_spec.rb
@@ -540,7 +540,15 @@ describe "Proposals" do
end
context "Geozones" do
+ scenario "When there are not gezones defined it does not show the geozone link" do
+ visit proposal_path(create(:proposal))
+
+ expect(page).not_to have_selector "#geozone"
+ expect(page).not_to have_link "All city"
+ end
+
scenario "Default whole city" do
+ create(:geozone)
author = create(:user)
login_as(author)
@@ -558,6 +566,25 @@ describe "Proposals" do
end
end
+ scenario "form shows the geozone selector when there are geozones defined" do
+ create(:geozone)
+ author = create(:user)
+ login_as(author)
+
+ visit new_proposal_path
+
+ expect(page).to have_field("Scope of operation")
+ end
+
+ scenario "form do not show geozone selector when there are no geozones defined" do
+ author = create(:user)
+ login_as(author)
+
+ visit new_proposal_path
+
+ expect(page).not_to have_field("Scope of operation")
+ end
+
scenario "Specific geozone" do
create(:geozone, name: "California")
create(:geozone, name: "New York")