Use labels for banner web_section_ids checkboxes so text its clickable

Now we can use the checkbox label text directly as locator at spec,
also default web_sections are created before every spec by loading
`db/seeds.rb` file so we were duplicating "Proposals" WebSection.
This commit is contained in:
Senén Rodero Rodríguez
2020-10-28 11:11:18 +01:00
parent e4d21ba148
commit a543fa7ea2
2 changed files with 5 additions and 3 deletions

View File

@@ -37,7 +37,9 @@
<div class="small-12 column"> <div class="small-12 column">
<%= f.label :sections, t("admin.banners.banner.sections_label") %> <%= f.label :sections, t("admin.banners.banner.sections_label") %>
<%= f.collection_check_boxes(:web_section_ids, @banner_sections, :id, :name) do |b| %> <%= f.collection_check_boxes(:web_section_ids, @banner_sections, :id, :name) do |b| %>
<%= b.check_box %> <%= t("admin.banners.banner.sections.#{b.text}") %><br> <%= b.label do %>
<%= b.check_box + t("admin.banners.banner.sections.#{b.text}") %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -73,7 +73,7 @@ describe "Admin banners magement" do
end end
scenario "Publish a banner" do scenario "Publish a banner" do
section = create(:web_section, name: "proposals") section = WebSection.find_by(name: "proposals")
visit admin_root_path visit admin_root_path
@@ -92,7 +92,7 @@ describe "Admin banners magement" do
fill_in "post_ended_at", with: next_week.strftime("%d/%m/%Y") fill_in "post_ended_at", with: next_week.strftime("%d/%m/%Y")
fill_in "banner_background_color", with: "#850000" fill_in "banner_background_color", with: "#850000"
fill_in "banner_font_color", with: "#ffb2b2" fill_in "banner_font_color", with: "#ffb2b2"
check "banner_web_section_ids_#{section.id}" check section.name.titleize
click_button "Save changes" click_button "Save changes"