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
f0287186
Commit
f0287186
authored
Sep 18, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise exception when initializing unknown policy
parent
00e58f83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
10 deletions
+3
-10
lib/gitlab/ci/build/policy.rb
lib/gitlab/ci/build/policy.rb
+1
-5
spec/lib/gitlab/ci/build/policy_spec.rb
spec/lib/gitlab/ci/build/policy_spec.rb
+2
-5
No files found.
lib/gitlab/ci/build/policy.rb
View file @
f0287186
...
@@ -4,11 +4,7 @@ module Gitlab
...
@@ -4,11 +4,7 @@ module Gitlab
module
Policy
module
Policy
def
self
.
fabricate
(
specs
)
def
self
.
fabricate
(
specs
)
specifications
=
specs
.
to_h
.
map
do
|
spec
,
value
|
specifications
=
specs
.
to_h
.
map
do
|
spec
,
value
|
begin
self
.
const_get
(
spec
.
to_s
.
camelize
).
new
(
value
)
self
.
const_get
(
spec
.
to_s
.
camelize
).
new
(
value
)
rescue
NameError
next
end
end
end
specifications
.
compact
specifications
.
compact
...
...
spec/lib/gitlab/ci/build/policy_spec.rb
View file @
f0287186
...
@@ -20,11 +20,8 @@ describe Gitlab::Ci::Build::Policy do
...
@@ -20,11 +20,8 @@ describe Gitlab::Ci::Build::Policy do
context
'when some policies are not defined'
do
context
'when some policies are not defined'
do
it
'gracefully skips unknown policies'
do
it
'gracefully skips unknown policies'
do
specs
=
described_class
.
fabricate
(
something:
'first'
,
else:
'unknown'
)
expect
{
described_class
.
fabricate
(
unknown:
'first'
)
}
.
to
raise_error
(
NameError
)
expect
(
specs
).
to
be_an
Array
expect
(
specs
).
to
be_one
expect
(
policy
).
to
have_received
(
:new
).
with
(
'first'
)
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