Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds 2021 holidays and tests against GOV.UK. Relates to #8 #13

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/ndr_support/concerns/working_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ module WorkingDays
'2020-08-31', # Monday - Summer bank holiday
'2020-12-25', # Friday - Christmas Day
'2020-12-28', # Monday - Boxing Day (substitute day)
# 2021
'2021-01-01', # Friday - New Year’s Day
'2021-04-02', # Friday - Good Friday
'2021-04-05', # Monday - Easter Monday
'2021-05-03', # Monday - Early May bank holiday
'2021-05-31', # Monday - Spring bank holiday
'2021-08-30', # Monday - Summer bank holiday
'2021-12-27', # Monday - Christmas Day
'2021-12-28', # Tuesday - Boxing Day
].map { |str| Date.parse(str) }

def self.check_lookup
Expand Down
18 changes: 18 additions & 0 deletions test/concerns/working_days_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,22 @@ def setup
assert_equal 253, @normal_time.working_days_until(@normal_time + 1.year)
assert_equal 253, @normal_date_time.working_days_until(@normal_date_time + 1.year)
end

test 'against GOV.UK holidays' do
require 'net/http'
require 'json'

url = 'https://www.gov.uk/bank-holidays/england-and-wales.json'
response = Net::HTTP.get(URI(url))

events = JSON.parse(response)['events']
events.each do |event|
event_date = event['date']
parsed_date = Date.parse(event_date)

assert parsed_date.public_holiday?, "#{event_date} should be a public holiday"
# next if parsed_date.public_holiday?
# puts "'#{event_date}', # #{parsed_date.strftime('%A')} - #{event['title']}"
end
end
end