Skip to content

Commit

Permalink
Avoid raising an error on missing credential, validation should catch it
Browse files Browse the repository at this point in the history
  • Loading branch information
cantino committed Feb 14, 2016
1 parent 94edebe commit 69e224e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions app/concerns/liquid_interpolatable.rb
Expand Up @@ -299,9 +299,7 @@ def initialize(tag_name, name, tokens)
end

def render(context)
credential = context.registers[:agent].credential(@credential_name)
raise "No user credential named '#{@credential_name}' defined" if credential.nil?
credential
context.registers[:agent].credential(@credential_name)
end
end

Expand Down
7 changes: 4 additions & 3 deletions spec/support/shared_examples/liquid_interpolatable.rb
Expand Up @@ -91,10 +91,11 @@
expect(@checker.interpolate_string("{% credential aws_key %}", {})).to eq('2222222222-jane')
end

it "should raise an exception for undefined credentials" do
it "should not raise an exception for undefined credentials" do
expect {
@checker.interpolate_string("{% credential unknown %}", {})
}.to raise_error(/No user credential named/)
result = @checker.interpolate_string("{% credential unknown %}", {})
expect(result).to eq('')
}.not_to raise_error
end
end

Expand Down

0 comments on commit 69e224e

Please sign in to comment.