BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
01620dd7
Commit
01620dd7
authored
Nov 18, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
event.rb
app/models/event.rb
+4
-0
event_spec.rb
spec/models/event_spec.rb
+17
-0
No files found.
app/models/event.rb
View file @
01620dd7
...
...
@@ -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?
...
...
spec/models/event_spec.rb
View file @
01620dd7
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment