working_hours
working_hours copied to clipboard
sorts week config hash on setter
Discovered accidentally that, if the working_hours hash config has many "ins" and "outs", the algorithm does not calculate working hours successfully. to avoid failure on the algorithm, working_hours setter sorts the hash. rspec included on this commit.
Hi ! Thanks !
Several things :
- You don't seem to need rspec-api-matchers anymore
- It needs a spec testing behavior, that failed before, for example, set an unsorted config and expect 1.working.hour.ago to work correctly
- can you use
mapin the sort method instead of doing it manually ?
Cheers !
I'll work on that! But I don't think that testing the behavior after sorting is a nice strategy if the algorithm already expects a sorted hash. Aren't all methods like 1.working.hour.ago covered already?
It's more of a regression test.
Your current test asserts the config is sorted, but does not ensure that everything still works. If later the code is changed and someone messes up and the precompiled config is not sorted, your test will still pass but the error will still be here.
Thanks for your contribution,
You're right about the order issue, but the fix should be in #precompiled IMO:
We don't care if the config definition hash is sorted, and sorting in the setter can be dangerous if the hash is modified after calling the setter. The sort needs to be in #precompiled when generating the real hash used for computation.
And as @Intrepidd said, your spec shoud verify the problem, not the solution. It should use a badly ordered hash and verify a computation that fails without the sort.
@jarthod - you're right. I'll check on #precompiled and try to fix it!
Hey, happy new year !
Are you still planning on working on this ?
YES! But I’m on vacation. I’ll be back on jan 10th!
Thomás Sieczkowski http://www.thomashs.com.br [email protected]
- 55 51 9182 4581
Em 03/01/2015, à(s) 09:33, Adrien [email protected] escreveu:
Hey, happy new year !
Are you still planning on working on this ?
— Reply to this email directly or view it on GitHub.
Great :)
On Sat, Jan 3, 2015, 19:21 Thomás Sieczkowski [email protected] wrote:
YES! But I’m on vacation. I’ll be back on jan 10th!
Thomás Sieczkowski http://www.thomashs.com.br [email protected]
- 55 51 9182 4581
Em 03/01/2015, à(s) 09:33, Adrien [email protected] escreveu:
Hey, happy new year !
Are you still planning on working on this ?
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub https://github.com/Intrepidd/working_hours/pull/14#issuecomment-68604115 .
Closing as stale, 10 years later ;)