Skip to content

Commit

Permalink
Add a spec for the change
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Apr 19, 2017
1 parent cabc715 commit be16c50
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/models/event_spec.rb
Expand Up @@ -118,6 +118,20 @@
Event.cleanup_expired!
expect(Event.find_by_id(event.id)).not_to be_nil
end

it "always keeps the latest Event regardless of its expires_at value only if the database is MySQL" do
Event.delete_all
event1 = agents(:jane_weather_agent).create_event expires_at: 1.minute.ago
event2 = agents(:bob_weather_agent).create_event expires_at: 1.minute.ago

Event.cleanup_expired!
case ActiveRecord::Base.connection
when ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
expect(Event.all.pluck(:id)).to eq([event2.id])
else
expect(Event.all.pluck(:id)).to be_empty
end
end
end

describe "after destroy" do
Expand Down

0 comments on commit be16c50

Please sign in to comment.