Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a7aaad96
Commit
a7aaad96
authored
Dec 21, 2018
by
Alessio Caiazza
Committed by
Shinya Maeda
Dec 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReleasesFinder will always return a relation
parent
b9aac409
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
10 deletions
+9
-10
app/finders/releases_finder.rb
app/finders/releases_finder.rb
+2
-4
app/models/release.rb
app/models/release.rb
+2
-0
lib/api/releases.rb
lib/api/releases.rb
+1
-1
spec/finders/releases_finder_spec.rb
spec/finders/releases_finder_spec.rb
+4
-5
No files found.
app/finders/releases_finder.rb
View file @
a7aaad96
...
...
@@ -6,11 +6,9 @@ class ReleasesFinder
@current_user
=
current_user
end
# rubocop: disable CodeReuse/ActiveRecord
def
execute
return
[]
unless
Ability
.
allowed?
(
@current_user
,
:read_release
,
@project
)
return
Release
.
none
unless
Ability
.
allowed?
(
@current_user
,
:read_release
,
@project
)
@project
.
releases
.
order
(
'created_at DESC'
)
@project
.
releases
.
sorted
end
# rubocop: enable CodeReuse/ActiveRecord
end
app/models/release.rb
View file @
a7aaad96
...
...
@@ -11,6 +11,8 @@ class Release < ActiveRecord::Base
validates
:description
,
:project
,
:tag
,
presence:
true
scope
:sorted
,
->
{
order
(
created_at: :desc
)
}
delegate
:repository
,
to: :project
def
commit
...
...
lib/api/releases.rb
View file @
a7aaad96
...
...
@@ -21,7 +21,7 @@ module API
use
:pagination
end
get
':id/releases'
do
releases
=
::
Kaminari
.
paginate_array
(
::
ReleasesFinder
.
new
(
user_project
,
current_user
).
execute
)
releases
=
::
ReleasesFinder
.
new
(
user_project
,
current_user
).
execute
present
paginate
(
releases
),
with:
Entities
::
Release
end
...
...
spec/finders/releases_finder_spec.rb
View file @
a7aaad96
...
...
@@ -6,15 +6,14 @@ describe ReleasesFinder do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:v1_0_0
)
{
create
(
:release
,
project:
project
,
tag:
'v1.0.0'
)}
let
(
:v1_1_0
)
{
create
(
:release
,
project:
project
,
tag:
'v1.1.0'
)}
let
(
:v1_0_0
)
{
create
(
:release
,
project:
project
,
tag:
'v1.0.0'
)
}
let
(
:v1_1_0
)
{
create
(
:release
,
project:
project
,
tag:
'v1.1.0'
)
}
subject
{
described_class
.
new
(
project
,
user
)}
before
do
now
=
Time
.
now
v1_0_0
.
update_attribute
(
:created_at
,
now
-
2
.
days
)
v1_1_0
.
update_attribute
(
:created_at
,
now
-
1
.
day
)
v1_0_0
.
update_attribute
(
:created_at
,
2
.
days
.
ago
)
v1_1_0
.
update_attribute
(
:created_at
,
1
.
day
.
ago
)
end
describe
'#execute'
do
...
...
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