Commit 01620dd7 authored by Yorick Peterse's avatar Yorick Peterse

Added Event.limit_recent

This will be used to move some querying logic from the users controller
to the Event model (where it belongs).
parent fbcf3bd3
......@@ -69,6 +69,10 @@ class Event < ActiveRecord::Base
row ? row.updated_at : nil
end
def limit_recent(limit = 20, offset = nil)
recent.limit(limit).offset(offset)
end
end
def proper?
......
......@@ -85,4 +85,21 @@ describe Event do
end
end
end
describe '.limit_recent' do
let!(:event1) { create(:closed_issue_event) }
let!(:event2) { create(:closed_issue_event) }
describe 'without an explicit limit' do
subject { Event.limit_recent }
it { is_expected.to eq([event2, event1]) }
end
describe 'with an explicit limit' do
subject { Event.limit_recent(1) }
it { is_expected.to eq([event2]) }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment