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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2f3f6828
Commit
2f3f6828
authored
May 11, 2020
by
Vasilii Iakliushin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `let_it_be` for create_service_spec
parent
b276cc04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
spec/services/branches/create_service_spec.rb
spec/services/branches/create_service_spec.rb
+8
-13
No files found.
spec/services/branches/create_service_spec.rb
View file @
2f3f6828
...
...
@@ -3,30 +3,27 @@
require
'spec_helper'
describe
Branches
::
CreateService
do
let
(
:user
)
{
create
(
:user
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
let_it_be
(
:project
)
{
create
(
:project_empty_repo
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
describe
'#execute'
do
context
'when repository is empty'
do
let
(
:project
)
{
create
(
:project_empty_repo
)
}
it
'creates master branch'
do
service
.
execute
(
'my-feature'
,
'master'
)
expect
(
project
.
repository
.
branch_exists?
(
'master'
)).
to
be_truthy
end
it
'creates
my
-feature branch'
do
service
.
execute
(
'
my
-feature'
,
'master'
)
it
'creates
another
-feature branch'
do
service
.
execute
(
'
another
-feature'
,
'master'
)
expect
(
project
.
repository
.
branch_exists?
(
'
my
-feature'
)).
to
be_truthy
expect
(
project
.
repository
.
branch_exists?
(
'
another
-feature'
)).
to
be_truthy
end
end
context
'when branch already exists'
do
let
(
:project
)
{
create
(
:project_empty_repo
)
}
it
'returns an error'
do
result
=
service
.
execute
(
'master'
,
'master'
)
...
...
@@ -36,14 +33,12 @@ describe Branches::CreateService do
end
context
'when incorrect reference is provided'
do
let
(
:project
)
{
create
(
:project_empty_repo
)
}
before
do
allow
(
project
.
repository
).
to
receive
(
:add_branch
).
and_return
(
false
)
end
it
'returns an error with reference name'
do
result
=
service
.
execute
(
'
my
-feature'
,
'unknown'
)
it
'returns an error with
a
reference name'
do
result
=
service
.
execute
(
'
new
-feature'
,
'unknown'
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
'Invalid reference name: unknown'
)
...
...
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