diff --git a/app/assets/javascripts/admin/poll/shifts/form.js b/app/assets/javascripts/admin/poll/shifts/form.js index ee37951f9..f6a695de3 100644 --- a/app/assets/javascripts/admin/poll/shifts/form.js +++ b/app/assets/javascripts/admin/poll/shifts/form.js @@ -6,12 +6,12 @@ change: function() { switch ($(this).val()) { case "vote_collection": - $("select[class='js-shift-vote-collection-dates']").show(); - $("select[class='js-shift-recount-scrutiny-dates']").hide(); + $(".js-shift-vote-collection-dates").show(); + $(".js-shift-recount-scrutiny-dates").hide(); break; case "recount_scrutiny": - $("select[class='js-shift-recount-scrutiny-dates']").show(); - $("select[class='js-shift-vote-collection-dates']").hide(); + $(".js-shift-recount-scrutiny-dates").show(); + $(".js-shift-vote-collection-dates").hide(); } } }); diff --git a/app/components/admin/poll/shifts/form_component.html.erb b/app/components/admin/poll/shifts/form_component.html.erb index 8c0ad752a..74ac8105e 100644 --- a/app/components/admin/poll/shifts/form_component.html.erb +++ b/app/components/admin/poll/shifts/form_component.html.erb @@ -20,11 +20,18 @@
- + <%= label_tag :shift_date_vote_collection_date, + t("admin.poll_shifts.new.date"), + class: "js-shift-vote-collection-dates" %> <%= select "shift[date]", "vote_collection_date", options_for_select(shift_vote_collection_dates), { prompt: voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days") }, class: "js-shift-vote-collection-dates" %> + + <%= label_tag :shift_date_recount_scrutiny_date, + t("admin.poll_shifts.new.date"), + class: "js-shift-recount-scrutiny-dates", + hidden: "hidden" %> <%= select "shift[date]", "recount_scrutiny_date", options_for_select(shift_recount_scrutiny_dates), { prompt: t("admin.poll_shifts.new.select_date") }, diff --git a/spec/system/admin/poll/shifts_spec.rb b/spec/system/admin/poll/shifts_spec.rb index ad55359f8..841002c3d 100644 --- a/spec/system/admin/poll/shifts_spec.rb +++ b/spec/system/admin/poll/shifts_spec.rb @@ -53,10 +53,10 @@ describe "Admin shifts", :admin do click_button "Search" click_link "Edit shifts" - expect(page).to have_select("shift_date_vote_collection_date", - options: ["Select day", *vote_collection_dates]) - expect(page).not_to have_select("shift_date_recount_scrutiny_date") - select I18n.l(Date.current, format: :long), from: "shift_date_vote_collection_date" + expect(page).to have_select "Date", options: ["Select day", *vote_collection_dates] + expect(page).not_to have_select with_options: recount_scrutiny_dates + + select I18n.l(Date.current, format: :long), from: "Date" click_button "Add shift" expect(page).to have_content "Shift added" @@ -82,10 +82,9 @@ describe "Admin shifts", :admin do select "Recount & Scrutiny", from: "shift_task" - expect(page).to have_select("shift_date_recount_scrutiny_date", - options: ["Select day", *recount_scrutiny_dates]) - expect(page).not_to have_select("shift_date_vote_collection_date") - select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: "shift_date_recount_scrutiny_date" + expect(page).to have_select "Date", options: ["Select day", *recount_scrutiny_dates] + expect(page).not_to have_select with_options: vote_collection_dates + select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: "Date" click_button "Add shift" expect(page).to have_content "Shift added" @@ -126,11 +125,9 @@ describe "Admin shifts", :admin do click_button "Search" click_link "Edit shifts" - expect(page).to have_select("shift_date_vote_collection_date", - options: ["Select day", *vote_collection_dates]) + expect(page).to have_select "Date", options: ["Select day", *vote_collection_dates] select "Recount & Scrutiny", from: "shift_task" - expect(page).to have_select("shift_date_recount_scrutiny_date", - options: ["Select day", *recount_scrutiny_dates]) + expect(page).to have_select "Date", options: ["Select day", *recount_scrutiny_dates] end scenario "Change option from Recount & Scrutinity to Collect Votes" do @@ -144,11 +141,11 @@ describe "Admin shifts", :admin do select "Recount & Scrutiny", from: "shift_task" - expect(page).to have_select("shift_date_recount_scrutiny_date", options: ["Select day"]) + expect(page).to have_select "Date", options: ["Select day"] select "Collect Votes", from: "shift_task" - expect(page).to have_select("shift_date_vote_collection_date", options: ["Voting days ended"]) + expect(page).to have_select "Date", options: ["Voting days ended"] end scenario "Error on create" do