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
Léo-Paul Géneau
gitlab-ce
Commits
8e3485d8
Commit
8e3485d8
authored
Mar 09, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-git-push-service-specs' into 'master'
Fixed the GitPushService specs See merge request !3139
parents
fdfcc1ac
53719ecb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
app/models/ability.rb
app/models/ability.rb
+5
-0
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+8
-7
No files found.
app/models/ability.rb
View file @
8e3485d8
...
@@ -9,6 +9,7 @@ class Ability
...
@@ -9,6 +9,7 @@ class Ability
when
CommitStatus
then
commit_status_abilities
(
user
,
subject
)
when
CommitStatus
then
commit_status_abilities
(
user
,
subject
)
when
Project
then
project_abilities
(
user
,
subject
)
when
Project
then
project_abilities
(
user
,
subject
)
when
Issue
then
issue_abilities
(
user
,
subject
)
when
Issue
then
issue_abilities
(
user
,
subject
)
when
ExternalIssue
then
external_issue_abilities
(
user
,
subject
)
when
Note
then
note_abilities
(
user
,
subject
)
when
Note
then
note_abilities
(
user
,
subject
)
when
ProjectSnippet
then
project_snippet_abilities
(
user
,
subject
)
when
ProjectSnippet
then
project_snippet_abilities
(
user
,
subject
)
when
PersonalSnippet
then
personal_snippet_abilities
(
user
,
subject
)
when
PersonalSnippet
then
personal_snippet_abilities
(
user
,
subject
)
...
@@ -424,6 +425,10 @@ class Ability
...
@@ -424,6 +425,10 @@ class Ability
end
end
end
end
def
external_issue_abilities
(
user
,
subject
)
project_abilities
(
user
,
subject
.
project
)
end
private
private
def
named_abilities
(
name
)
def
named_abilities
(
name
)
...
...
spec/services/git_push_service_spec.rb
View file @
8e3485d8
...
@@ -271,22 +271,24 @@ describe GitPushService, services: true do
...
@@ -271,22 +271,24 @@ describe GitPushService, services: true do
allow
(
project
.
repository
).
to
receive
(
:commits_between
).
allow
(
project
.
repository
).
to
receive
(
:commits_between
).
and_return
([
closing_commit
])
and_return
([
closing_commit
])
project
.
team
<<
[
commit_author
,
:master
]
end
end
context
"to default branches"
do
context
"to default branches"
do
it
"closes issues"
do
it
"closes issues"
do
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
@ref
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
@ref
)
expect
(
Issue
.
find
(
issue
.
id
)).
to
be_closed
expect
(
Issue
.
find
(
issue
.
id
)).
to
be_closed
end
end
it
"adds a note indicating that the issue is now closed"
do
it
"adds a note indicating that the issue is now closed"
do
expect
(
SystemNoteService
).
to
receive
(
:change_status
).
with
(
issue
,
project
,
commit_author
,
"closed"
,
closing_commit
)
expect
(
SystemNoteService
).
to
receive
(
:change_status
).
with
(
issue
,
project
,
commit_author
,
"closed"
,
closing_commit
)
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
@ref
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
@ref
)
end
end
it
"doesn't create additional cross-reference notes"
do
it
"doesn't create additional cross-reference notes"
do
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
expect
(
SystemNoteService
).
not_to
receive
(
:cross_reference
)
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
@ref
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
@ref
)
end
end
it
"doesn't close issues when external issue tracker is in use"
do
it
"doesn't close issues when external issue tracker is in use"
do
...
@@ -294,7 +296,7 @@ describe GitPushService, services: true do
...
@@ -294,7 +296,7 @@ describe GitPushService, services: true do
# The push still shouldn't create cross-reference notes.
# The push still shouldn't create cross-reference notes.
expect
do
expect
do
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
'refs/heads/hurf'
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
'refs/heads/hurf'
)
end
.
not_to
change
{
Note
.
where
(
project_id:
project
.
id
,
system:
true
).
count
}
end
.
not_to
change
{
Note
.
where
(
project_id:
project
.
id
,
system:
true
).
count
}
end
end
end
end
...
@@ -316,7 +318,6 @@ describe GitPushService, services: true do
...
@@ -316,7 +318,6 @@ describe GitPushService, services: true do
end
end
end
end
# EE-only tests
context
"for jira issue tracker"
do
context
"for jira issue tracker"
do
include
JiraServiceHelper
include
JiraServiceHelper
...
@@ -366,7 +367,7 @@ describe GitPushService, services: true do
...
@@ -366,7 +367,7 @@ describe GitPushService, services: true do
}
}
}.
to_json
}.
to_json
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
@ref
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
@ref
)
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_transition_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_transition_url
).
with
(
body:
transition_body
body:
transition_body
).
once
).
once
...
@@ -377,7 +378,7 @@ describe GitPushService, services: true do
...
@@ -377,7 +378,7 @@ describe GitPushService, services: true do
body:
"Issue solved with [
#{
closing_commit
.
id
}
|http://localhost/
#{
project
.
path_with_namespace
}
/commit/
#{
closing_commit
.
id
}
]."
body:
"Issue solved with [
#{
closing_commit
.
id
}
|http://localhost/
#{
project
.
path_with_namespace
}
/commit/
#{
closing_commit
.
id
}
]."
}.
to_json
}.
to_json
execute_service
(
project
,
use
r
,
@oldrev
,
@newrev
,
@ref
)
execute_service
(
project
,
commit_autho
r
,
@oldrev
,
@newrev
,
@ref
)
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_comment_url
).
with
(
expect
(
WebMock
).
to
have_requested
(
:post
,
jira_api_comment_url
).
with
(
body:
comment_body
body:
comment_body
).
once
).
once
...
...
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