diff --git a/app/components/proposals/form_component.html.erb b/app/components/proposals/form_component.html.erb index 88d7a2cf7..658ca2f90 100644 --- a/app/components/proposals/form_component.html.erb +++ b/app/components/proposals/form_component.html.erb @@ -49,10 +49,12 @@ <% end %> -
- <%= f.select :geozone_id, geozone_select_options, - include_blank: t("geozones.none") %> -
+ <% if Geozone.any? %> +
+ <%= f.select :geozone_id, geozone_select_options, + include_blank: t("geozones.none") %> +
+ <% end %> <% if feature?(:map) %>
diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb index 6e65c5ff1..23e645d3b 100644 --- a/app/views/legislation/proposals/_form.html.erb +++ b/app/views/legislation/proposals/_form.html.erb @@ -36,9 +36,11 @@ <%= render "documents/nested_documents", f: f %>
-
- <%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %> -
+ <% if Geozone.any? %> +
+ <%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %> +
+ <% end %>
<%= f.label :tag_list, t("legislation.proposals.form.tags_label") %> diff --git a/spec/system/legislation/proposals_spec.rb b/spec/system/legislation/proposals_spec.rb index d270d8839..b2747ca50 100644 --- a/spec/system/legislation/proposals_spec.rb +++ b/spec/system/legislation/proposals_spec.rb @@ -268,4 +268,21 @@ describe "Legislation Proposals" do 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 dcf046b07..bf0dcb2a9 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -566,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")