holidays / holidays

A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test out `:any` regions

ppeble opened this issue · comments

This is probably not in my best interest but I'll write it down anyway: we should test what happens when we pass in :any as a region instead of a 'valid' region. I have a gut feeling that it's not doing what we expect. We should use this issue to document what it is doing today and then discuss whether that is what we expect/want.

This is a good initial issue for first-timers! All you have to is respond with what comes back with the command below. Then we can talk about whether that is correct and what we can do about it.

Example test:

Holidays.on(Date.civil(2016, 1, 1), :any)

In this case we would expect all holidays for ANY region in our system.

Hello!
I get a blank line while using :any without using any region before it.
After using :au region I get,
{:date=>#<Date:2016-01-01 ((2457389j,0s,0n),+0s,2299161j)>, :name
=>"New Year's Day", :regions=>[:au]}

After using :au, :ca,
{:date=>#<Date:2016-01-01 ((2457389j,0s,0n),+0s,2299161j)>, :name
=>"New Year's Day", :regions=>[:au, :ca]}

@Anjana-arun Hello! Thank you for the feedback, I appreciate it!

This is...not ideal. In my mind if you send in :any it should all regions that have a holiday on that date. Does that match up with how everyone else sees it?

I think I know what it happening. I believe it's related to #251 and how we lazy-load regions. All of the issues are surrounding the same part of the code...

Anyway, thank you! I am going to leave this open because I think this is a problem that we need to solve.

@ppeble, I do believe what you are saying is right. The expected output must be the list of all regions having a holiday on the specified date.
Its a great pleasure to be of help.Infact, this was my first comment replying to an issue.

Thanks again @Anjana-arun! Glad that you decided to contribute. 👍

About this issue: I think that this is a bug. I don't think :any does what we expect it to do at all. For example:

% make console
bundle exec rake console
irb -rubygems -I lib -r holidays.rb
irb(main):001:0> Holidays.on(Date.civil(2016, 1, 1), :any)
=> []

Don't we expect this to return every single region that has a holiday on 2016/1/1? What else would :any mean in this case? Based on what @Anjana-arun said above, as a new user of the gem you would expect this to be the behavior.

@ttwo32 Do you have an opinion?

@jonathanpike @ghiculescu @adamlyons2 I'm tagging you because you've been involved in recent discussions and I would like some outside viewpoints if you have time. ❤️

@ppeble I would expect that :any returns a list of all holidays for any region that has a holiday on the specified date, as you mentioned.

Yep I agree it's not working right, and also that it probably relates to lazy loading

@ppeble Sorry for late response.
I agree . :)
It should return a list of all holidays for any region.

Thanks everyone! This will be addressed with the fix for #251. I should have a PR soon.

This was addressed in #271.