-
Notifications
You must be signed in to change notification settings - Fork 0
Automatically convert Query#start_time and #end_time to UTC #46
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
369cdf6
Automatically convert Query#start_time and #end_time to UTC
roback 9a525a7
Require "time"
roback 045f934
Make #start_time and #end_time show up in documentation
roback dd00a5f
Test that start_time and end_time is in utc (#utc?)
roback 4a19f35
Use "UTC" instead of "+00:00"
roback File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,64 @@ | |
| end | ||
| end | ||
|
|
||
| describe "#start_time=" do | ||
| before do | ||
| subject.pattern = "semla" | ||
| subject.start_time = time | ||
| end | ||
|
|
||
| context "when given time in UTC" do | ||
| let(:time) { Time.parse("2016-02-09 09:01:22 UTC") } | ||
|
|
||
| it "should not change timezone" do | ||
| expect(subject.start_time.utc?).to be(true) | ||
| expect(subject.request_parameters).to include(ts: "2016-02-09 09:01:22") | ||
| end | ||
| end | ||
|
|
||
| context "when given time not in UTC" do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to change, but "when given non-UTC time" has better flow imo :)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think so too, but I can live with this 😄 |
||
| let(:time) { Time.parse("2016-02-09 09:01:22 +05:00") } | ||
|
|
||
| it "should convert to UTC" do | ||
| expect(subject.start_time.utc?).to be(true) | ||
| expect(subject.request_parameters).to include(ts: "2016-02-09 04:01:22") | ||
| end | ||
|
|
||
| it "should not modify the given time object" do | ||
| expect(subject.start_time).not_to equal(time) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe "#end_time=" do | ||
| before do | ||
| subject.pattern = "semla" | ||
| subject.end_time = time | ||
| end | ||
|
|
||
| context "when given time in UTC" do | ||
| let(:time) { Time.parse("2016-02-09 09:01:22 UTC") } | ||
|
|
||
| it "should not change timezone" do | ||
| expect(subject.end_time.utc?).to be(true) | ||
| expect(subject.request_parameters).to include(tsTo: "2016-02-09 09:01:22") | ||
| end | ||
| end | ||
|
|
||
| context "when given time not in UTC" do | ||
| let(:time) { Time.parse("2016-02-09 09:01:22 +05:00") } | ||
|
|
||
| it "should convert to UTC" do | ||
| expect(subject.end_time.utc?).to be(true) | ||
| expect(subject.request_parameters).to include(tsTo: "2016-02-09 04:01:22") | ||
| end | ||
|
|
||
| it "should not modify the given time object" do | ||
| expect(subject.end_time).not_to equal(time) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context "with valid pattern" do | ||
| before { subject.pattern = "christmas" } | ||
|
|
||
|
|
@@ -78,18 +136,8 @@ | |
| expect(subject.request_parameters).to include(documentlang: 'en') | ||
| end | ||
|
|
||
| it "should add start_time" do | ||
| subject.start_time = Time.new(2012, 12, 28, 9, 01, 22) | ||
| expect(subject.request_parameters).to include(ts: '2012-12-28 09:01:22') | ||
| end | ||
|
|
||
| it "should add end_time" do | ||
| subject.end_time = Time.new(2013, 12, 28, 9, 01, 22) | ||
| expect(subject.request_parameters).to include(tsTo: '2013-12-28 09:01:22') | ||
| end | ||
|
|
||
| it "should encode url paramters" do | ||
| subject.end_time = Time.new(2013, 12, 28, 9, 01, 22) | ||
| subject.end_time = Time.parse("2013-12-28 09:01:22 UTC") | ||
| expect(subject.url_parameters).to include('tsTo=2013-12-28+09%3A01%3A22') | ||
| end | ||
| end | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we also include tests like this?
expect(subject.start_time.utc?).to be(true)or is it too redundant?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.
Why not. I don't think they need their own it block though. I'll add them to the "should convert to UTC" block.
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.
Sure