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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
804a2488
Commit
804a2488
authored
Feb 27, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and test User#contributed_projects_ids.
parent
47c5a2ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
app/models/user.rb
app/models/user.rb
+1
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+28
-0
No files found.
app/models/user.rb
View file @
804a2488
...
@@ -629,5 +629,6 @@ class User < ActiveRecord::Base
...
@@ -629,5 +629,6 @@ class User < ActiveRecord::Base
reorder
(
project_id: :desc
).
reorder
(
project_id: :desc
).
select
(
:project_id
).
select
(
:project_id
).
uniq
uniq
.
map
(
&
:project_id
)
end
end
end
end
spec/models/user_spec.rb
View file @
804a2488
...
@@ -505,4 +505,32 @@ describe User do
...
@@ -505,4 +505,32 @@ describe User do
expect
(
User
.
sort
(
nil
).
first
).
to
eq
(
@user
)
expect
(
User
.
sort
(
nil
).
first
).
to
eq
(
@user
)
end
end
end
end
describe
"#contributed_projects_ids"
do
subject
{
create
(
:user
)
}
let!
(
:project1
)
{
create
(
:project
)
}
let!
(
:project2
)
{
create
(
:project
,
forked_from_project:
project3
)
}
let!
(
:project3
)
{
create
(
:project
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project2
,
target_project:
project3
,
author:
subject
)
}
let!
(
:push_event
)
{
create
(
:event
,
action:
Event
::
PUSHED
,
project:
project1
,
target:
project1
,
author:
subject
)
}
let!
(
:merge_event
)
{
create
(
:event
,
action:
Event
::
CREATED
,
project:
project3
,
target:
merge_request
,
author:
subject
)
}
before
do
project1
.
team
<<
[
subject
,
:master
]
project2
.
team
<<
[
subject
,
:master
]
end
it
"includes IDs for projects the user has pushed to"
do
expect
(
subject
.
contributed_projects_ids
).
to
include
(
project1
.
id
)
end
it
"includes IDs for projects the user has had merge requests merged into"
do
expect
(
subject
.
contributed_projects_ids
).
to
include
(
project3
.
id
)
end
it
"doesn't include IDs for unrelated projects"
do
expect
(
subject
.
contributed_projects_ids
).
not_to
include
(
project2
.
id
)
end
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