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
e533d43a
Commit
e533d43a
authored
Apr 06, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs related to new manual actions permissions
parent
f647ad8f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
14 deletions
+54
-14
spec/factories/environments.rb
spec/factories/environments.rb
+3
-1
spec/features/projects/environments/environment_spec.rb
spec/features/projects/environments/environment_spec.rb
+4
-0
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+40
-13
spec/services/ci/process_pipeline_service_spec.rb
spec/services/ci/process_pipeline_service_spec.rb
+7
-0
No files found.
spec/factories/environments.rb
View file @
e533d43a
...
@@ -18,6 +18,8 @@ FactoryGirl.define do
...
@@ -18,6 +18,8 @@ FactoryGirl.define do
# interconnected objects to simulate a review app.
# interconnected objects to simulate a review app.
#
#
after
(
:create
)
do
|
environment
,
evaluator
|
after
(
:create
)
do
|
environment
,
evaluator
|
pipeline
=
create
(
:ci_pipeline
,
project:
environment
.
project
)
deployment
=
create
(
:deployment
,
deployment
=
create
(
:deployment
,
environment:
environment
,
environment:
environment
,
project:
environment
.
project
,
project:
environment
.
project
,
...
@@ -26,7 +28,7 @@ FactoryGirl.define do
...
@@ -26,7 +28,7 @@ FactoryGirl.define do
teardown_build
=
create
(
:ci_build
,
:manual
,
teardown_build
=
create
(
:ci_build
,
:manual
,
name:
"
#{
deployment
.
environment
.
name
}
:teardown"
,
name:
"
#{
deployment
.
environment
.
name
}
:teardown"
,
pipeline:
deployment
.
deployable
.
pipeline
)
pipeline:
pipeline
)
deployment
.
update_column
(
:on_stop
,
teardown_build
.
name
)
deployment
.
update_column
(
:on_stop
,
teardown_build
.
name
)
environment
.
update_attribute
(
:deployments
,
[
deployment
])
environment
.
update_attribute
(
:deployments
,
[
deployment
])
...
...
spec/features/projects/environments/environment_spec.rb
View file @
e533d43a
...
@@ -62,6 +62,8 @@ feature 'Environment', :feature do
...
@@ -62,6 +62,8 @@ feature 'Environment', :feature do
name:
'deploy to production'
)
name:
'deploy to production'
)
end
end
given
(
:role
)
{
:master
}
scenario
'does show a play button'
do
scenario
'does show a play button'
do
expect
(
page
).
to
have_link
(
action
.
name
.
humanize
)
expect
(
page
).
to
have_link
(
action
.
name
.
humanize
)
end
end
...
@@ -132,6 +134,8 @@ feature 'Environment', :feature do
...
@@ -132,6 +134,8 @@ feature 'Environment', :feature do
on_stop:
'close_app'
)
on_stop:
'close_app'
)
end
end
given
(
:role
)
{
:master
}
scenario
'does allow to stop environment'
do
scenario
'does allow to stop environment'
do
click_link
(
'Stop'
)
click_link
(
'Stop'
)
...
...
spec/models/environment_spec.rb
View file @
e533d43a
...
@@ -191,11 +191,34 @@ describe Environment, models: true do
...
@@ -191,11 +191,34 @@ describe Environment, models: true do
end
end
context
'when matching action is defined'
do
context
'when matching action is defined'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
deployable:
build
,
on_stop:
'close_app'
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
deployable:
build
,
on_stop:
'close_app'
)
end
context
'when user is not allowed to stop environment'
do
let!
(
:close_action
)
do
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'close_app'
)
end
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Access
::
AccessDeniedError
)
end
end
context
'when user is allowed to stop environment'
do
before
do
project
.
add_master
(
user
)
end
context
'when action did not yet finish'
do
context
'when action did not yet finish'
do
let!
(
:close_action
)
{
create
(
:ci_build
,
:manual
,
pipeline:
build
.
pipeline
,
name:
'close_app'
)
}
let!
(
:close_action
)
do
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
,
name:
'close_app'
)
end
it
'returns the same action'
do
it
'returns the same action'
do
expect
(
subject
).
to
eq
(
close_action
)
expect
(
subject
).
to
eq
(
close_action
)
...
@@ -204,16 +227,20 @@ describe Environment, models: true do
...
@@ -204,16 +227,20 @@ describe Environment, models: true do
end
end
context
'if action did finish'
do
context
'if action did finish'
do
let!
(
:close_action
)
{
create
(
:ci_build
,
:manual
,
:success
,
pipeline:
build
.
pipeline
,
name:
'close_app'
)
}
let!
(
:close_action
)
do
create
(
:ci_build
,
:manual
,
:success
,
pipeline:
pipeline
,
name:
'close_app'
)
end
it
'returns a new action of the same type'
do
it
'returns a new action of the same type'
do
is_expected
.
to
be_persisted
expect
(
subject
)
.
to
be_persisted
expect
(
subject
.
name
).
to
eq
(
close_action
.
name
)
expect
(
subject
.
name
).
to
eq
(
close_action
.
name
)
expect
(
subject
.
user
).
to
eq
(
user
)
expect
(
subject
.
user
).
to
eq
(
user
)
end
end
end
end
end
end
end
end
end
describe
'recently_updated_on_branch?'
do
describe
'recently_updated_on_branch?'
do
subject
{
environment
.
recently_updated_on_branch?
(
'feature'
)
}
subject
{
environment
.
recently_updated_on_branch?
(
'feature'
)
}
...
...
spec/services/ci/process_pipeline_service_spec.rb
View file @
e533d43a
...
@@ -314,6 +314,13 @@ describe Ci::ProcessPipelineService, '#execute', :services do
...
@@ -314,6 +314,13 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end
end
context
'when pipeline is promoted sequentially up to the end'
do
context
'when pipeline is promoted sequentially up to the end'
do
before
do
# We are using create(:empty_project), and users has to be master in
# order to execute manual action when repository does not exist.
#
project
.
add_master
(
user
)
end
it
'properly processes entire pipeline'
do
it
'properly processes entire pipeline'
do
process_pipeline
process_pipeline
...
...
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