Do not show the geozone selector where there are no geozones defined

This commit is contained in:
Senén Rodero Rodríguez
2023-06-12 15:25:51 +02:00
parent 9003c460d5
commit 1bc2a68856
4 changed files with 47 additions and 7 deletions

View File

@@ -49,10 +49,12 @@
</div> </div>
<% end %> <% end %>
<div> <% if Geozone.any? %>
<%= f.select :geozone_id, geozone_select_options, <div>
include_blank: t("geozones.none") %> <%= f.select :geozone_id, geozone_select_options,
</div> include_blank: t("geozones.none") %>
</div>
<% end %>
<% if feature?(:map) %> <% if feature?(:map) %>
<div> <div>

View File

@@ -36,9 +36,11 @@
<%= render "documents/nested_documents", f: f %> <%= render "documents/nested_documents", f: f %>
</div> </div>
<div class="small-12 medium-6 column"> <% if Geozone.any? %>
<%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %> <div class="small-12 medium-6 column">
</div> <%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %>
</div>
<% end %>
<div class="small-12 column"> <div class="small-12 column">
<%= f.label :tag_list, t("legislation.proposals.form.tags_label") %> <%= f.label :tag_list, t("legislation.proposals.form.tags_label") %>

View File

@@ -268,4 +268,21 @@ describe "Legislation Proposals" do
expect(page).not_to have_link("All city") expect(page).not_to have_link("All city")
end 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 end

View File

@@ -566,6 +566,25 @@ describe "Proposals" do
end end
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 scenario "Specific geozone" do
create(:geozone, name: "California") create(:geozone, name: "California")
create(:geozone, name: "New York") create(:geozone, name: "New York")