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
956a4cb8
Commit
956a4cb8
authored
May 15, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Spec optimization] Joining one-line 'it' blocks
parent
1df30f45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
30 deletions
+46
-30
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+8
-6
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+9
-5
spec/services/merge_requests/create_service_spec.rb
spec/services/merge_requests/create_service_spec.rb
+6
-4
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+23
-15
No files found.
spec/services/ci/create_pipeline_service_spec.rb
View file @
956a4cb8
...
...
@@ -27,12 +27,14 @@ describe Ci::CreatePipelineService, services: true do
)
end
it
{
expect
(
pipeline
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
pipeline
).
to
be_valid
}
it
{
expect
(
pipeline
).
to
eq
(
project
.
pipelines
.
last
)
}
it
{
expect
(
pipeline
).
to
have_attributes
(
user:
user
)
}
it
{
expect
(
pipeline
).
to
have_attributes
(
status:
'pending'
)
}
it
{
expect
(
pipeline
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
'creates a pipeline'
do
expect
(
pipeline
).
to
be_kind_of
(
Ci
::
Pipeline
)
expect
(
pipeline
).
to
be_valid
expect
(
pipeline
).
to
eq
(
project
.
pipelines
.
last
)
expect
(
pipeline
).
to
have_attributes
(
user:
user
)
expect
(
pipeline
).
to
have_attributes
(
status:
'pending'
)
expect
(
pipeline
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
end
context
'auto-cancel enabled'
do
before
do
...
...
spec/services/issues/close_service_spec.rb
View file @
956a4cb8
...
...
@@ -51,8 +51,10 @@ describe Issues::CloseService, services: true do
end
end
it
{
expect
(
issue
).
to
be_valid
}
it
{
expect
(
issue
).
to
be_closed
}
it
'closes the issue'
do
expect
(
issue
).
to
be_valid
expect
(
issue
).
to
be_closed
end
it
'sends email to user2 about assign of new issue'
do
email
=
ActionMailer
::
Base
.
deliveries
.
last
...
...
@@ -96,9 +98,11 @@ describe Issues::CloseService, services: true do
described_class
.
new
(
project
,
user
).
close_issue
(
issue
)
end
it
{
expect
(
issue
).
to
be_valid
}
it
{
expect
(
issue
).
to
be_opened
}
it
{
expect
(
todo
.
reload
).
to
be_pending
}
it
'closes the issue'
do
expect
(
issue
).
to
be_valid
expect
(
issue
).
to
be_opened
expect
(
todo
.
reload
).
to
be_pending
end
end
end
end
spec/services/merge_requests/create_service_spec.rb
View file @
956a4cb8
...
...
@@ -27,10 +27,12 @@ describe MergeRequests::CreateService, services: true do
@merge_request
=
service
.
execute
end
it
{
expect
(
@merge_request
).
to
be_valid
}
it
{
expect
(
@merge_request
.
title
).
to
eq
(
'Awesome merge_request'
)
}
it
{
expect
(
@merge_request
.
assignee
).
to
be_nil
}
it
{
expect
(
@merge_request
.
merge_params
[
'force_remove_source_branch'
]).
to
eq
(
'1'
)
}
it
'creates an MR'
do
expect
(
@merge_request
).
to
be_valid
expect
(
@merge_request
.
title
).
to
eq
(
'Awesome merge_request'
)
expect
(
@merge_request
.
assignee
).
to
be_nil
expect
(
@merge_request
.
merge_params
[
'force_remove_source_branch'
]).
to
eq
(
'1'
)
end
it
'executes hooks with default action'
do
expect
(
service
).
to
have_received
(
:execute_hooks
).
with
(
@merge_request
)
...
...
spec/services/merge_requests/update_service_spec.rb
View file @
956a4cb8
...
...
@@ -59,14 +59,16 @@ describe MergeRequests::UpdateService, services: true do
end
end
it
{
expect
(
@merge_request
).
to
be_valid
}
it
{
expect
(
@merge_request
.
title
).
to
eq
(
'New title'
)
}
it
{
expect
(
@merge_request
.
assignee
).
to
eq
(
user2
)
}
it
{
expect
(
@merge_request
).
to
be_closed
}
it
{
expect
(
@merge_request
.
labels
.
count
).
to
eq
(
1
)
}
it
{
expect
(
@merge_request
.
labels
.
first
.
title
).
to
eq
(
label
.
name
)
}
it
{
expect
(
@merge_request
.
target_branch
).
to
eq
(
'target'
)
}
it
{
expect
(
@merge_request
.
merge_params
[
'force_remove_source_branch'
]).
to
eq
(
'1'
)
}
it
'mathces base expectations'
do
expect
(
@merge_request
).
to
be_valid
expect
(
@merge_request
.
title
).
to
eq
(
'New title'
)
expect
(
@merge_request
.
assignee
).
to
eq
(
user2
)
expect
(
@merge_request
).
to
be_closed
expect
(
@merge_request
.
labels
.
count
).
to
eq
(
1
)
expect
(
@merge_request
.
labels
.
first
.
title
).
to
eq
(
label
.
name
)
expect
(
@merge_request
.
target_branch
).
to
eq
(
'target'
)
expect
(
@merge_request
.
merge_params
[
'force_remove_source_branch'
]).
to
eq
(
'1'
)
end
it
'executes hooks with update action'
do
expect
(
service
).
to
have_received
(
:execute_hooks
).
...
...
@@ -148,9 +150,11 @@ describe MergeRequests::UpdateService, services: true do
end
end
it
{
expect
(
@merge_request
).
to
be_valid
}
it
{
expect
(
@merge_request
.
state
).
to
eq
(
'merged'
)
}
it
{
expect
(
@merge_request
.
merge_error
).
to
be_nil
}
it
'merges the MR'
do
expect
(
@merge_request
).
to
be_valid
expect
(
@merge_request
.
state
).
to
eq
(
'merged'
)
expect
(
@merge_request
.
merge_error
).
to
be_nil
end
end
context
'with finished pipeline'
do
...
...
@@ -167,8 +171,10 @@ describe MergeRequests::UpdateService, services: true do
end
end
it
{
expect
(
@merge_request
).
to
be_valid
}
it
{
expect
(
@merge_request
.
state
).
to
eq
(
'merged'
)
}
it
'merges the MR'
do
expect
(
@merge_request
).
to
be_valid
expect
(
@merge_request
.
state
).
to
eq
(
'merged'
)
end
end
context
'with active pipeline'
do
...
...
@@ -200,8 +206,10 @@ describe MergeRequests::UpdateService, services: true do
end
end
it
{
expect
(
@merge_request
.
state
).
to
eq
(
'opened'
)
}
it
{
expect
(
@merge_request
.
merge_error
).
not_to
be_nil
}
it
'does not merge the MR'
do
expect
(
@merge_request
.
state
).
to
eq
(
'opened'
)
expect
(
@merge_request
.
merge_error
).
not_to
be_nil
end
end
context
'MR can not be merged when note sha != MR sha'
do
...
...
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