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

always pass valid date format #14296

Merged
merged 2 commits into from
Mar 20, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def poll
private

def filter
timestamp = @last_activity ? Time.zone.parse(@last_activity.timestamp.to_s) : 1.minute.ago
{
:order_by => 'timestamp',
:timestamp__gt => @last_activity ? @last_activity.timestamp : 1.minute.ago.to_s(:db)
:timestamp__gt => timestamp.to_s(:db)
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,19 @@
end
end
end

context ".filter" do
it "converts timestamp to correct timeformat" do
# It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]
timestamps = {
'2016-01-01 01:00:00' => '2016-01-01 01:00:00',
'2017-03-10 19%3A31%3A26' => '2017-03-10 00:00:00',
Time.zone.parse('1975-12-31 01:01:01') => '1975-12-31 01:01:01',
}
timestamps.each do |input, converted|
subject.instance_variable_set(:@last_activity, OpenStruct.new(:timestamp => input))
expect(subject.send(:filter)[:timestamp__gt]).to eq(converted)
end
end
end
end