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
3d378065
Commit
3d378065
authored
Jun 22, 2021
by
Mark Lapierre
Committed by
Nikola Milojevic
Jun 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for predicate methods
parent
a0d81c52
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
0 deletions
+96
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+24
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+36
-0
spec/support/shared_examples/models/project_ci_cd_settings_shared_examples.rb
...examples/models/project_ci_cd_settings_shared_examples.rb
+36
-0
No files found.
ee/spec/models/project_spec.rb
View file @
3d378065
...
...
@@ -64,6 +64,30 @@ RSpec.describe Project do
include_examples
'ci_cd_settings delegation'
describe
'#merge_pipelines_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:merge_pipelines_enabled?
}
end
end
describe
'#merge_pipelines_were_disabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:merge_pipelines_were_disabled?
}
end
end
describe
'#merge_trains_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:merge_trains_enabled?
}
end
end
describe
'#auto_rollback_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:auto_rollback_enabled?
}
end
end
describe
'#jira_vulnerabilities_integration_enabled?'
do
context
'when project lacks a jira_integration relation'
do
it
'returns false'
do
...
...
spec/models/project_spec.rb
View file @
3d378065
...
...
@@ -660,6 +660,42 @@ RSpec.describe Project, factory_default: :keep do
include_examples
'ci_cd_settings delegation'
describe
'#ci_forward_deployment_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
,
prefix:
'ci_'
do
let
(
:delegated_method
)
{
:forward_deployment_enabled?
}
end
end
describe
'#ci_job_token_scope_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
,
prefix:
'ci_'
do
let
(
:delegated_method
)
{
:job_token_scope_enabled?
}
end
end
describe
'#restrict_user_defined_variables?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:restrict_user_defined_variables?
}
end
end
describe
'#keep_latest_artifacts_available?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:keep_latest_artifacts_available?
}
end
end
describe
'#keep_latest_artifact?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:keep_latest_artifact?
}
end
end
describe
'#group_runners_enabled?'
do
it_behaves_like
'a ci_cd_settings predicate method'
do
let
(
:delegated_method
)
{
:group_runners_enabled?
}
end
end
context
'when read_container_registry_access_level is disabled'
do
before
do
stub_feature_flags
(
read_container_registry_access_level:
false
)
...
...
spec/support/shared_examples/models/project_ci_cd_settings_shared_examples.rb
View file @
3d378065
...
...
@@ -14,3 +14,39 @@ RSpec.shared_examples 'ci_cd_settings delegation' do
end
end
end
RSpec
.
shared_examples
'a ci_cd_settings predicate method'
do
|
prefix:
''
|
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:project
)
{
create
(
:project
)
}
context
'when ci_cd_settings is nil'
do
before
do
allow
(
project
).
to
receive
(
:ci_cd_settings
).
and_return
(
nil
)
end
it
'returns false'
do
expect
(
project
.
send
(
"
#{
prefix
}#{
delegated_method
}
"
)).
to
be
(
false
)
end
end
context
'when ci_cd_settings is not nil'
do
where
(
:delegated_method_return
,
:subject_return
)
do
true
|
true
false
|
false
end
with_them
do
let
(
:ci_cd_settings_double
)
{
double
(
'ProjectCiCdSetting'
)
}
before
do
allow
(
project
).
to
receive
(
:ci_cd_settings
).
and_return
(
ci_cd_settings_double
)
allow
(
ci_cd_settings_double
).
to
receive
(
delegated_method
).
and_return
(
delegated_method_return
)
end
it
'returns the expected boolean value'
do
expect
(
project
.
send
(
"
#{
prefix
}#{
delegated_method
}
"
)).
to
be
(
subject_return
)
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