+
<% def date_picker_template(start_date = Date.current, end_date = Date.current)
start_picker = text_field_tag "event[date_ranges_attributes][][start_date]", (I18n.l start_date),
class: 'form-control', :"data-enable-datepicker" => 'true'
diff --git a/spec/features/event_spec.rb b/spec/features/event_spec.rb
index e84af04d..59c69393 100644
--- a/spec/features/event_spec.rb
+++ b/spec/features/event_spec.rb
@@ -97,6 +97,29 @@
expect(page).to have_text("Bewerbungsschluss muss vor Beginn der Veranstaltung liegen")
end
+
+ it "should not display errors on date ranges twice", js: true do
+ visit new_event_path
+
+ fill_in "Maximale Teilnehmerzahl", :with => 25
+
+ within page.find("#event-date-pickers").all("div")[0] do
+ fill_in "event[date_ranges_attributes][][start_date]", with: I18n.l(Date.current.prev_day(7))
+ fill_in "event[date_ranges_attributes][][end_date]", with: I18n.l(Date.yesterday.prev_day(7))
+ end
+
+ click_link "Zeitspanne hinzufügen"
+
+ within page.find("#event-date-pickers").all("div")[1] do
+ fill_in "event[date_ranges_attributes][][start_date]", with: I18n.l(Date.current)
+ fill_in "event[date_ranges_attributes][][end_date]", with: I18n.l(Date.yesterday)
+ end
+
+ click_button I18n.t(".events.form.publish")
+
+ expect(page).to have_css("div.has-error")
+ expect(page).to have_content("kann nicht vor Start-Datum liegen", count: 1)
+ end
end
describe "show page" do