Add a failing test for tinsel not being used in early December #727
Add a failing test for tinsel not being used in early December #727
Conversation
2nd December 2019 is a substitute bank holiday in Scotland for St Andrew's Day. The current implementation of `Calendar#bunting_styles` uses tinsel for all bank holidays with `"bunting": true` in December and January, but it should probably only do that for the ones for Christmas and New Year. There were substitute days for St Andrew's Day in 2013 and 2014 as well. I've used one of those in the test because for some reason the test isn't failing today when I use the 2019 date - maybe something to do with Timecop?
I pushed the branch to |
The test fails, as expected because there's currently tinsel when there shouldn't be.
|
When do people (not) want tinsel bunting to appear? Should it only be a Christmas Day/Boxing Day/New Year's Day thing? |
Possibly debatable, but I'd say so - it seems odd to have tinsel for St Andrew's Day only in the years when there's a substitute bank holiday, and for it to have different behaviour from St Patrick's Day. |
@@ -67,4 +67,12 @@ def content_id | |||
def body | |||
@data["body"] | |||
end | |||
|
|||
def christmas? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm being very pedantic, but do we think this should be christmas_or_boxing_day?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boxing Day counts as Christmas for me.
But will this even work? Do the Christmas and Boxing Day bank holidays ever get substituted for not 25th/26th?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If substituted, I think the most it could be different is two days out because of a weekend - so maybe [25, 26, 27, 28]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all the bank holidays over Christmas/new year can be substitute days if the actual day falls on a weekend - so 25-28th Dec and 1st-4th Jan can be bank holidays that should have tinsel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I pushed two extra commits to your branch that fixes the problem. Feel free to squash them. I didn't want to force-push your branch to do it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy for you to squash and force-push - don't want to write your commit messages for you @issyl0 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'm done now.
My vote is Christmas Day, Boxing Day and New Year's Day. |
d3553d4
to
2fa2f6d
Compare
- Previously, we showed tinsel on all bank holidays that fell in December and January, assuming that they were only Christmas Day, Boxing Day and New Year's Day. - This year (and presumably other years in the past/future), St Andrew's Day in Scotland was a substitute day on 2nd December. We showed tinsel, when we should have just showed normal bunting. - This also accounts for all possible substitute Christmas/New Year bank holidays.
Thank you for adding the test that made us realise this was a problem, @jennyd! 💪❤️ May there only be tinsel on legit Christmas and New Year bank holidays from now on! 🎄 |
And thank you for responding quickly and fixing it! 💥 🎉 ❤️ (I still don't know why the test passes without the fix if you change it to use 2nd December 2019 - the behaviour we were seeing yesterday clearly shouldn't pass the test 🤔 ) |
@jennyd the fixture for the tests being old maybe https://github.com/alphagov/calendars/blob/master/test/fixtures/data/bank-holidays.json |
Ah good spot @rjw1, that'll be it - I'd assumed the tests were using the real data. |
Timecop.travel(2017, 1, 1, 9, 0, 0) |
2nd December 2019 is a substitute bank holiday in Scotland for St Andrew's Day. The current implementation of
Calendar#bunting_styles
uses tinsel for all bank holidays with"bunting": true
in December and January, but it should probably only do that for the ones for Christmas and New Year:There were substitute days for St Andrew's Day in 2013 and 2014 as well. I've used one of those in the test because for some reason the test isn't failing today when I use the 2019 date - maybe something to do with Timecop?