Skip to content

Commit

Permalink
Resolve another regression in CustomResourceWithAllowedActions
Browse files Browse the repository at this point in the history
Make sure we trigger on actions, but not something new new_resource.actions

Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Sep 2, 2020
1 parent c47a886 commit 5f9fc76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class CustomResourceWithAllowedActions < Base
PATTERN

def on_send(node)
# avoid triggering on things like new_resource.actions
return unless node.receiver.nil?

# if the resource requires poise then bail out since we're in a poise resource where @allowed_actions is legit
return if poise_require(processed_source.ast).any? || !resource_actions?(processed_source.ast)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@
end
RUBY
end

it 'does not register an offense when calling actions method on another object' do
expect_no_offenses(<<~RUBY)
action :create do
template ::File.join(apache_dir, 'mods-available', 'actions.conf') do
source 'mods/actions.conf.erb'
cookbook 'apache2'
variables(actions: new_resource.actions)
end
end
RUBY
end
end

0 comments on commit 5f9fc76

Please sign in to comment.