Skip to content

Commit

Permalink
Add date to timestamp conversion test
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 14, 2024
1 parent d3293c6 commit 82bf828
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions spec/datagrid/filters/date_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ def entry_dated(date)
end
end

it "should automatically reverse Array if first more than last" do
it "should automatically reverse if first more than last" do
report = test_report(created_at: %w[2013-01-01 2012-01-01]) do
scope { Entry }
filter(:created_at, :date, range: true)
end
expect(report.created_at).to eq([Date.new(2012, 0o1, 0o1), Date.new(2013, 0o1, 0o1)])
end
it "should automatically reverse Array if first more than last" do
it "should automatically reverse if first more than last" do
report = test_report(created_at: %w[2013-01-01 2012-01-01]) do
scope { Entry }
filter(:created_at, :date, range: true)
Expand All @@ -204,4 +204,21 @@ def entry_dated(date)
expect(report.filter_value_as_string(:created_at)).to eq("01/02/2012")
end
end

it "supports search by timestamp column" do
report = test_report(created_at: Date.today) do
scope {Entry}
filter(:created_at, :date)
end
e1 = Entry.create!(created_at: Date.yesterday + 23.hours)
e2 = Entry.create!(created_at: Date.today.to_time)
e3 = Entry.create!(created_at: Date.today + 12.hours)
e4 = Entry.create!(created_at: Date.today + 23.hours)
e5 = Entry.create!(created_at: Date.tomorrow)
expect(report.assets).to_not include(e1)
expect(report.assets).to include(e2)
expect(report.assets).to include(e3)
expect(report.assets).to include(e4)
expect(report.assets).to_not include(e5)
end
end

0 comments on commit 82bf828

Please sign in to comment.