Skip to content

Commit

Permalink
Merge pull request #341 from dgmstuart/dgms/years-in-event-dates-on-show
Browse files Browse the repository at this point in the history
Display years in first/last date on event/show
  • Loading branch information
dgmstuart authored Apr 3, 2024
2 parents 4275a1c + 48d4258 commit 2706a29
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion app/presenters/show_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def to_model

def format_date(date)
return unless date
return "(archived)" if date == Date.new

I18n.l(date, format: :listing_date)
I18n.l(date)
end
end
12 changes: 10 additions & 2 deletions spec/presenters/show_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
it "formats the date" do
event = instance_double("Event", first_date: Date.new(2011, 5, 14))

expect(described_class.new(event).first_date).to eq "Saturday 14th May"
expect(described_class.new(event).first_date).to eq "14/05/2011"
end

context "when there is no first date" do
Expand Down Expand Up @@ -176,7 +176,7 @@
it "formats the date" do
event = instance_double("Event", last_date: Date.new(2011, 5, 14))

expect(described_class.new(event).last_date).to eq "Saturday 14th May"
expect(described_class.new(event).last_date).to eq "14/05/2011"
end

context "when there is no last date" do
Expand All @@ -186,6 +186,14 @@
expect(described_class.new(event).last_date).to be_nil
end
end

context "when the event has been archived" do
it "displays (archived)" do
event = instance_double("Event", last_date: Date.new)

expect(described_class.new(event).last_date).to eq "(archived)"
end
end
end

describe "#title" do
Expand Down
8 changes: 4 additions & 4 deletions spec/system/editors_can_archive_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

click_show

expect(page).to have_content("Last date: Sunday 2nd January")
expect(page).to have_content("Last date: 02/01/2000") # the previous Sunday
end

it "with an occasional event" do
Expand All @@ -31,7 +31,7 @@

click_show

expect(page).to have_content("Last date: Sunday 2nd January")
expect(page).to have_content("Last date: 02/01/2000")
end

it "with an event with no dates" do
Expand All @@ -44,7 +44,7 @@

click_show

expect(page).to have_content("Last date: Monday 1st January") # earliest possible Date
expect(page).to have_content("Last date: (archived)")
end

context "when the event is already archived" do
Expand All @@ -62,7 +62,7 @@

click_show

expect(page).to have_content("Last date: Saturday 1st January")
expect(page).to have_content("Last date: 01/01/2000")
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/system/editors_can_create_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
.and have_content("Frequency:\nMonthly or occasionally")
.and have_content("Dates:\n12/12/2012, 19/12/2012")
.and have_content("Cancelled:\n12/12/2012")
.and have_content("First date:\nWednesday 12th December")
.and have_content("Last date:\nWednesday 19th December")
.and have_content("First date:\n12/12/2012")
.and have_content("Last date:\n19/12/2012")
.and have_content("Url:\nhttp://www.lsds.co.uk/stompin")

expect(page).to have_content("Last updated by Al Minns (12345678901234567) on Monday 2nd January 2012 at 23:17:16")
Expand Down Expand Up @@ -100,8 +100,8 @@
.and have_content("Social")
.and have_content("Frequency:\nMonthly or occasionally")
.and have_content("Dates:\n12/12/2012, 30/04/2013")
.and have_content("First date:\nWednesday 12th December")
.and have_content("Last date:\nTuesday 30th April")
.and have_content("First date:\n12/12/2012")
.and have_content("Last date:\n30/04/2013")
.and have_content("Url:\nhttp://www.lsds.co.uk/stompin")
end

Expand Down Expand Up @@ -219,8 +219,8 @@
.and have_content("Class")
.and have_content("Frequency:\nWeekly on Wednesdays")
.and have_content("Cancelled:\nNone")
.and have_content("First date:\nWednesday 15th February")
.and have_content("Last date:\nWednesday 13th February")
.and have_content("First date:\n15/02/2012")
.and have_content("Last date:\n13/02/2013")
.and have_content("Url:\nhttps://sunshineswing.uk/events")

expect(page).to have_content("Last updated by Leon James (12345678901234567) on Monday 2nd January 2012 at 23:17:16")
Expand Down
4 changes: 2 additions & 2 deletions spec/system/editors_can_edit_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
.and have_content("Frequency:\nMonthly or occasionally")
.and have_content("Dates:\n10/10/2010, 10/11/2010, 02/12/2011")
.and have_content("Cancelled:\n02/12/2011")
.and have_content("First date:\nSunday 10th October")
.and have_content("Last date:\nFriday 2nd December")
.and have_content("First date:\n10/10/2010")
.and have_content("Last date:\n02/12/2011")
.and have_content("Url:\nhttp://www.lsds.co.uk/stompin")

expect(page).to have_content("Last updated by Al Minns (12345678901234567) on Saturday 2nd January 2010 at 23:17:16")
Expand Down

0 comments on commit 2706a29

Please sign in to comment.