Skip to content

Commit

Permalink
Merge pull request #731 from chef/more_actions
Browse files Browse the repository at this point in the history
Resolve another regression in CustomResourceWithAllowedActions
  • Loading branch information
tas50 authored Sep 2, 2020
2 parents c47a886 + 5f9fc76 commit b25b40a
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 b25b40a

Please sign in to comment.