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
bab44bd9
Commit
bab44bd9
authored
Jul 19, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix job merge request link to a forked source project
parent
9e5c8e5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
18 deletions
+67
-18
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-1
spec/serializers/build_details_entity_spec.rb
spec/serializers/build_details_entity_spec.rb
+66
-17
No files found.
app/serializers/build_details_entity.rb
View file @
bab44bd9
...
...
@@ -16,7 +16,7 @@ class BuildDetailsEntity < JobEntity
end
expose
:path
do
|
build
|
project_merge_request_path
(
project
,
build
.
merge_request
)
project_merge_request_path
(
build
.
project
,
build
.
merge_request
)
end
end
...
...
spec/serializers/build_details_entity_spec.rb
View file @
bab44bd9
...
...
@@ -9,37 +9,86 @@ describe BuildDetailsEntity do
describe
'#as_json'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:failed
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
:failed
,
pipeline:
pipeline
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:entity
)
{
described_class
.
new
(
build
,
request:
request
,
current_user:
user
,
project:
project
)
}
let
(
:entity
)
do
described_class
.
new
(
build
,
request:
request
,
current_user:
user
,
project:
project
)
end
subject
{
entity
.
as_json
}
before
do
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
end
it
'contains the needed key value pairs'
do
expect
(
subject
).
to
include
(
:coverage
,
:erased_at
,
:duration
)
expect
(
subject
).
to
include
(
:runner
,
:pipeline
)
expect
(
subject
).
to
include
(
:raw_path
,
:new_issue_path
)
end
context
'when the user has access to issues and merge requests'
do
let!
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
build
.
ref
)
end
context
'when merge request orginates from the same project'
do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
source_branch:
build
.
ref
)
end
before
do
allow
(
build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
before
do
allow
(
build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
it
'contains the needed key value pairs'
do
expect
(
subject
).
to
include
(
:merge_request
)
expect
(
subject
).
to
include
(
:new_issue_path
)
end
it
'exposes details of the merge request'
do
expect
(
subject
[
:merge_request
]).
to
include
(
:iid
,
:path
)
end
it
'contains the needed key value pairs'
do
expect
(
subject
).
to
include
(
:coverage
,
:erased_at
,
:duration
)
expect
(
subject
).
to
include
(
:runner
,
:pipeline
)
expect
(
subject
).
to
include
(
:raw_path
,
:merge_request
)
expect
(
subject
).
to
include
(
:new_issue_path
)
it
'has a correct merge request path'
do
expect
(
subject
[
:merge_request
][
:path
]).
to
include
project
.
full_path
end
end
it
'exposes details of the merge request'
do
expect
(
subject
[
:merge_request
]).
to
include
(
:iid
,
:path
)
context
'when merge request is from a fork'
do
let
(
:fork_project
)
do
create
(
:empty_project
,
forked_from_project:
project
)
end
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
fork_project
)
}
before
do
allow
(
build
).
to
receive
(
:merge_request
).
and_return
(
merge_request
)
end
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
fork_project
,
target_project:
project
,
source_branch:
build
.
ref
)
end
it
'contains the needed key value pairs'
do
expect
(
subject
).
to
include
(
:merge_request
)
expect
(
subject
).
to
include
(
:new_issue_path
)
end
it
'exposes details of the merge request'
do
expect
(
subject
[
:merge_request
]).
to
include
(
:iid
,
:path
)
end
it
'has a correct merge request path'
do
expect
(
subject
[
:merge_request
][
:path
])
.
to
include
fork_project
.
full_path
end
end
context
'when the build has been erased'
do
let
!
(
:build
)
{
create
(
:ci_build
,
:erasable
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
:erasable
,
project:
project
)
}
it
'exposes the user whom erased the build'
do
expect
(
subject
).
to
include
(
:erase_path
)
...
...
@@ -47,7 +96,7 @@ describe BuildDetailsEntity do
end
context
'when the build has been erased'
do
let
!
(
:build
)
{
create
(
:ci_build
,
erased_at:
Time
.
now
,
project:
project
,
erased_by:
user
)
}
let
(
:build
)
{
create
(
:ci_build
,
erased_at:
Time
.
now
,
project:
project
,
erased_by:
user
)
}
it
'exposes the user whom erased the build'
do
expect
(
subject
).
to
include
(
:erased_by
)
...
...
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