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
92aa4028
Commit
92aa4028
authored
Nov 05, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test to make sure hooks are fire only once
when updating a file to a different branch.
parent
4b20cb5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
spec/services/files/update_service_spec.rb
spec/services/files/update_service_spec.rb
+15
-14
No files found.
spec/services/files/update_service_spec.rb
View file @
92aa4028
...
...
@@ -6,7 +6,10 @@ describe Files::UpdateService do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:file_path
)
{
'files/ruby/popen.rb'
}
let
(
:new_contents
)
{
"New Content"
}
let
(
:new_contents
)
{
'New Content'
}
let
(
:target_branch
)
{
project
.
default_branch
}
let
(
:last_commit_sha
)
{
nil
}
let
(
:commit_params
)
do
{
file_path:
file_path
,
...
...
@@ -16,7 +19,7 @@ describe Files::UpdateService do
last_commit_sha:
last_commit_sha
,
source_project:
project
,
source_branch:
project
.
default_branch
,
target_branch:
project
.
default_branch
,
target_branch:
target_branch
}
end
...
...
@@ -54,18 +57,6 @@ describe Files::UpdateService do
end
context
"when the last_commit_sha is not supplied"
do
let
(
:commit_params
)
do
{
file_path:
file_path
,
commit_message:
"Update File"
,
file_content:
new_contents
,
file_content_encoding:
"text"
,
source_project:
project
,
source_branch:
project
.
default_branch
,
target_branch:
project
.
default_branch
,
}
end
it
"returns a hash with the :success status "
do
results
=
subject
.
execute
...
...
@@ -80,5 +71,15 @@ describe Files::UpdateService do
expect
(
results
.
data
).
to
eq
(
new_contents
)
end
end
context
'when target branch is different than source branch'
do
let
(
:target_branch
)
{
"
#{
project
.
default_branch
}
-new"
}
it
'fires hooks only once'
do
expect
(
GitHooksService
).
to
receive
(
:new
).
once
.
and_call_original
subject
.
execute
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