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
7bd5e571
Commit
7bd5e571
authored
Jul 18, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instead of adding master, stub_not_protect_default_branch
parent
1ed6d154
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
66 additions
and
29 deletions
+66
-29
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+9
-5
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+2
-1
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
+3
-1
spec/lib/gitlab/ci/status/build/factory_spec.rb
spec/lib/gitlab/ci/status/build/factory_spec.rb
+7
-7
spec/lib/gitlab/ci/status/build/retryable_spec.rb
spec/lib/gitlab/ci/status/build/retryable_spec.rb
+3
-1
spec/lib/gitlab/ci/status/build/stop_spec.rb
spec/lib/gitlab/ci/status/build/stop_spec.rb
+3
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+6
-2
spec/serializers/job_entity_spec.rb
spec/serializers/job_entity_spec.rb
+8
-3
spec/serializers/pipeline_details_entity_spec.rb
spec/serializers/pipeline_details_entity_spec.rb
+4
-2
spec/serializers/pipeline_entity_spec.rb
spec/serializers/pipeline_entity_spec.rb
+4
-2
spec/services/ci/process_pipeline_service_spec.rb
spec/services/ci/process_pipeline_service_spec.rb
+3
-1
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+6
-2
spec/services/create_deployment_service_spec.rb
spec/services/create_deployment_service_spec.rb
+3
-1
spec/support/stub_configuration.rb
spec/support/stub_configuration.rb
+5
-0
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
7bd5e571
...
@@ -7,6 +7,10 @@ describe Projects::JobsController do
...
@@ -7,6 +7,10 @@ describe Projects::JobsController do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
stub_not_protect_default_branch
end
describe
'GET index'
do
describe
'GET index'
do
context
'when scope is pending'
do
context
'when scope is pending'
do
before
do
before
do
...
@@ -218,7 +222,7 @@ describe Projects::JobsController do
...
@@ -218,7 +222,7 @@ describe Projects::JobsController do
describe
'POST retry'
do
describe
'POST retry'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
sign_in
(
user
)
sign_in
(
user
)
post_retry
post_retry
...
@@ -250,7 +254,7 @@ describe Projects::JobsController do
...
@@ -250,7 +254,7 @@ describe Projects::JobsController do
describe
'POST play'
do
describe
'POST play'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
create
(
:protected_branch
,
:developers_can_merge
,
create
(
:protected_branch
,
:developers_can_merge
,
name:
'master'
,
project:
project
)
name:
'master'
,
project:
project
)
...
@@ -290,7 +294,7 @@ describe Projects::JobsController do
...
@@ -290,7 +294,7 @@ describe Projects::JobsController do
describe
'POST cancel'
do
describe
'POST cancel'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
sign_in
(
user
)
sign_in
(
user
)
post_cancel
post_cancel
...
@@ -326,7 +330,7 @@ describe Projects::JobsController do
...
@@ -326,7 +330,7 @@ describe Projects::JobsController do
describe
'POST cancel_all'
do
describe
'POST cancel_all'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
@@ -368,7 +372,7 @@ describe Projects::JobsController do
...
@@ -368,7 +372,7 @@ describe Projects::JobsController do
describe
'POST erase'
do
describe
'POST erase'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
sign_in
(
user
)
sign_in
(
user
)
post_erase
post_erase
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
7bd5e571
...
@@ -8,7 +8,8 @@ describe Projects::PipelinesController do
...
@@ -8,7 +8,8 @@ describe Projects::PipelinesController do
let
(
:feature
)
{
ProjectFeature
::
DISABLED
}
let
(
:feature
)
{
ProjectFeature
::
DISABLED
}
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
project
.
project_feature
.
update
(
project
.
project_feature
.
update
(
builds_access_level:
feature
)
builds_access_level:
feature
)
...
...
spec/lib/gitlab/ci/status/build/cancelable_spec.rb
View file @
7bd5e571
...
@@ -48,7 +48,9 @@ describe Gitlab::Ci::Status::Build::Cancelable do
...
@@ -48,7 +48,9 @@ describe Gitlab::Ci::Status::Build::Cancelable do
describe
'#has_action?'
do
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
context
'when user is allowed to update build'
do
before
do
before
do
build
.
project
.
add_master
(
user
)
stub_not_protect_default_branch
build
.
project
.
add_developer
(
user
)
end
end
it
{
is_expected
.
to
have_action
}
it
{
is_expected
.
to
have_action
}
...
...
spec/lib/gitlab/ci/status/build/factory_spec.rb
View file @
7bd5e571
...
@@ -7,7 +7,9 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -7,7 +7,9 @@ describe Gitlab::Ci::Status::Build::Factory do
let
(
:factory
)
{
described_class
.
new
(
build
,
user
)
}
let
(
:factory
)
{
described_class
.
new
(
build
,
user
)
}
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
context
'when build is successful'
do
context
'when build is successful'
do
...
@@ -232,11 +234,10 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -232,11 +234,10 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when user does not have ability to play action'
do
context
'when user does not have ability to play action'
do
before
do
before
do
project
.
team
.
truncate
allow
(
build
.
project
).
to
receive
(
:empty_repo?
).
and_return
(
false
)
project
.
add_developer
(
user
)
create
(
:protected_branch
,
:no_one_can_push
,
create
(
:protected_branch
,
:no_one_can_push
,
name:
build
.
ref
,
project:
project
)
name:
build
.
ref
,
project:
build
.
project
)
end
end
it
'fabricates status that has no action'
do
it
'fabricates status that has no action'
do
...
@@ -264,11 +265,10 @@ describe Gitlab::Ci::Status::Build::Factory do
...
@@ -264,11 +265,10 @@ describe Gitlab::Ci::Status::Build::Factory do
context
'when user is not allowed to execute manual action'
do
context
'when user is not allowed to execute manual action'
do
before
do
before
do
project
.
team
.
truncate
allow
(
build
.
project
).
to
receive
(
:empty_repo?
).
and_return
(
false
)
project
.
add_developer
(
user
)
create
(
:protected_branch
,
:no_one_can_push
,
create
(
:protected_branch
,
:no_one_can_push
,
name:
build
.
ref
,
project:
project
)
name:
build
.
ref
,
project:
build
.
project
)
end
end
it
'fabricates status with correct details'
do
it
'fabricates status with correct details'
do
...
...
spec/lib/gitlab/ci/status/build/retryable_spec.rb
View file @
7bd5e571
...
@@ -48,7 +48,9 @@ describe Gitlab::Ci::Status::Build::Retryable do
...
@@ -48,7 +48,9 @@ describe Gitlab::Ci::Status::Build::Retryable do
describe
'#has_action?'
do
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
context
'when user is allowed to update build'
do
before
do
before
do
build
.
project
.
add_master
(
user
)
stub_not_protect_default_branch
build
.
project
.
add_developer
(
user
)
end
end
it
{
is_expected
.
to
have_action
}
it
{
is_expected
.
to
have_action
}
...
...
spec/lib/gitlab/ci/status/build/stop_spec.rb
View file @
7bd5e571
...
@@ -20,7 +20,9 @@ describe Gitlab::Ci::Status::Build::Stop do
...
@@ -20,7 +20,9 @@ describe Gitlab::Ci::Status::Build::Stop do
describe
'#has_action?'
do
describe
'#has_action?'
do
context
'when user is allowed to update build'
do
context
'when user is allowed to update build'
do
before
do
before
do
build
.
project
.
add_master
(
user
)
stub_not_protect_default_branch
build
.
project
.
add_developer
(
user
)
end
end
it
{
is_expected
.
to
have_action
}
it
{
is_expected
.
to
have_action
}
...
...
spec/models/ci/pipeline_spec.rb
View file @
7bd5e571
...
@@ -734,8 +734,10 @@ describe Ci::Pipeline, models: true do
...
@@ -734,8 +734,10 @@ describe Ci::Pipeline, models: true do
context
'on failure and build retry'
do
context
'on failure and build retry'
do
before
do
before
do
stub_not_protect_default_branch
build
.
drop
build
.
drop
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
Ci
::
Build
.
retry
(
build
,
user
)
Ci
::
Build
.
retry
(
build
,
user
)
end
end
...
@@ -999,7 +1001,9 @@ describe Ci::Pipeline, models: true do
...
@@ -999,7 +1001,9 @@ describe Ci::Pipeline, models: true do
let
(
:latest_status
)
{
pipeline
.
statuses
.
latest
.
pluck
(
:status
)
}
let
(
:latest_status
)
{
pipeline
.
statuses
.
latest
.
pluck
(
:status
)
}
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
context
'when there is a failed build and failed external status'
do
context
'when there is a failed build and failed external status'
do
...
...
spec/serializers/job_entity_spec.rb
View file @
7bd5e571
...
@@ -7,8 +7,10 @@ describe JobEntity do
...
@@ -7,8 +7,10 @@ describe JobEntity do
let
(
:request
)
{
double
(
'request'
)
}
let
(
:request
)
{
double
(
'request'
)
}
before
do
before
do
stub_not_protect_default_branch
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
project
.
add_master
(
user
)
project
.
add_developer
(
user
)
end
end
let
(
:entity
)
do
let
(
:entity
)
do
...
@@ -77,7 +79,7 @@ describe JobEntity do
...
@@ -77,7 +79,7 @@ describe JobEntity do
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
create
(
:protected_branch
,
:developers_can_merge
,
create
(
:protected_branch
,
:developers_can_merge
,
name:
'master'
,
project:
project
)
name:
job
.
ref
,
project:
job
.
project
)
end
end
it
'contains path to play action'
do
it
'contains path to play action'
do
...
@@ -91,7 +93,10 @@ describe JobEntity do
...
@@ -91,7 +93,10 @@ describe JobEntity do
context
'when user is not allowed to trigger action'
do
context
'when user is not allowed to trigger action'
do
before
do
before
do
project
.
team
.
truncate
allow
(
job
.
project
).
to
receive
(
:empty_repo?
).
and_return
(
false
)
create
(
:protected_branch
,
:no_one_can_push
,
name:
job
.
ref
,
project:
job
.
project
)
end
end
it
'does not contain path to play action'
do
it
'does not contain path to play action'
do
...
...
spec/serializers/pipeline_details_entity_spec.rb
View file @
7bd5e571
...
@@ -9,6 +9,8 @@ describe PipelineDetailsEntity do
...
@@ -9,6 +9,8 @@ describe PipelineDetailsEntity do
end
end
before
do
before
do
stub_not_protect_default_branch
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
end
end
...
@@ -52,7 +54,7 @@ describe PipelineDetailsEntity do
...
@@ -52,7 +54,7 @@ describe PipelineDetailsEntity do
context
'user has ability to retry pipeline'
do
context
'user has ability to retry pipeline'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
end
end
it
'retryable flag is true'
do
it
'retryable flag is true'
do
...
@@ -80,7 +82,7 @@ describe PipelineDetailsEntity do
...
@@ -80,7 +82,7 @@ describe PipelineDetailsEntity do
context
'user has ability to cancel pipeline'
do
context
'user has ability to cancel pipeline'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
end
end
it
'cancelable flag is true'
do
it
'cancelable flag is true'
do
...
...
spec/serializers/pipeline_entity_spec.rb
View file @
7bd5e571
...
@@ -5,6 +5,8 @@ describe PipelineEntity do
...
@@ -5,6 +5,8 @@ describe PipelineEntity do
let
(
:request
)
{
double
(
'request'
)
}
let
(
:request
)
{
double
(
'request'
)
}
before
do
before
do
stub_not_protect_default_branch
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
end
end
...
@@ -52,7 +54,7 @@ describe PipelineEntity do
...
@@ -52,7 +54,7 @@ describe PipelineEntity do
context
'user has ability to retry pipeline'
do
context
'user has ability to retry pipeline'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
end
end
it
'contains retry path'
do
it
'contains retry path'
do
...
@@ -80,7 +82,7 @@ describe PipelineEntity do
...
@@ -80,7 +82,7 @@ describe PipelineEntity do
context
'user has ability to cancel pipeline'
do
context
'user has ability to cancel pipeline'
do
before
do
before
do
project
.
add_
mast
er
(
user
)
project
.
add_
develop
er
(
user
)
end
end
it
'contains cancel path'
do
it
'contains cancel path'
do
...
...
spec/services/ci/process_pipeline_service_spec.rb
View file @
7bd5e571
...
@@ -9,7 +9,9 @@ describe Ci::ProcessPipelineService, '#execute', :services do
...
@@ -9,7 +9,9 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end
end
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
context
'when simple pipeline is defined'
do
context
'when simple pipeline is defined'
do
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
7bd5e571
...
@@ -85,7 +85,9 @@ describe Ci::RetryBuildService, :services do
...
@@ -85,7 +85,9 @@ describe Ci::RetryBuildService, :services do
context
'when user has ability to execute build'
do
context
'when user has ability to execute build'
do
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
it_behaves_like
'build duplication'
it_behaves_like
'build duplication'
...
@@ -131,7 +133,9 @@ describe Ci::RetryBuildService, :services do
...
@@ -131,7 +133,9 @@ describe Ci::RetryBuildService, :services do
context
'when user has ability to execute build'
do
context
'when user has ability to execute build'
do
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
it_behaves_like
'build duplication'
it_behaves_like
'build duplication'
...
...
spec/services/create_deployment_service_spec.rb
View file @
7bd5e571
...
@@ -244,7 +244,9 @@ describe CreateDeploymentService, services: true do
...
@@ -244,7 +244,9 @@ describe CreateDeploymentService, services: true do
context
'when job is retried'
do
context
'when job is retried'
do
it_behaves_like
'creates deployment'
do
it_behaves_like
'creates deployment'
do
before
do
before
do
project
.
add_master
(
user
)
stub_not_protect_default_branch
project
.
add_developer
(
user
)
end
end
let
(
:deployable
)
{
Ci
::
Build
.
retry
(
job
,
user
)
}
let
(
:deployable
)
{
Ci
::
Build
.
retry
(
job
,
user
)
}
...
...
spec/support/stub_configuration.rb
View file @
7bd5e571
...
@@ -9,6 +9,11 @@ module StubConfiguration
...
@@ -9,6 +9,11 @@ module StubConfiguration
.
to
receive_messages
(
messages
)
.
to
receive_messages
(
messages
)
end
end
def
stub_not_protect_default_branch
stub_application_setting
(
default_branch_protection:
Gitlab
::
Access
::
PROTECTION_NONE
)
end
def
stub_config_setting
(
messages
)
def
stub_config_setting
(
messages
)
allow
(
Gitlab
.
config
.
gitlab
).
to
receive_messages
(
messages
)
allow
(
Gitlab
.
config
.
gitlab
).
to
receive_messages
(
messages
)
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