poise 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 805b189d8f29b6d7fcdcd5e189a24e525a755f96
4
- data.tar.gz: ae33e8ec60d4d947811f35211ce3eecc69712dd8
3
+ metadata.gz: 07fe35f3e4e7b7f5761c1c1225a0dccd578d3a78
4
+ data.tar.gz: d0b820b837c47bedf72a1cb095e9249d4a415fb3
5
5
  SHA512:
6
- metadata.gz: eb2351eab975e312a23c039dd12c3b18dd4fc76307cb08c92d10702e317d935fa515d7928e0733188b03be2157779d1be8adf74c62f7f13f766927e96db726c8
7
- data.tar.gz: dedd4fe5fdb0f15f0eb50402309ad51513b9663fd38c13dddbdb4891cbb62396d0d04c25201571769531aa638dc87ab7527dbd7a13e05bc2acc6f68f1601dd48
6
+ metadata.gz: 73711a21746f13d0bcbfd2042596fc2829c28a8e089608368839b632b5bf19306843fed59162764f18fa624cf84d485c8ee43522f9eb42d97bf8c7b58ecfdb91
7
+ data.tar.gz: e937e4a3c327f7be9395fd6497b0d1f2f0fc9af3094242858db89ad85cdd1afa6094e7328e0b543e6615321417a827805368582f4c274cd3023dd519dbc03c2a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.2.1
4
+
5
+ * Fixed delayed notifications inside `notifying_block`.
6
+ * Default actions as expected within LWRPs.
7
+
3
8
  ## v2.2.0
4
9
 
5
10
  * Compatibility with Chef 12.4.1 and Chefspec 4.3.0.
@@ -62,7 +62,15 @@ module Poise
62
62
  @default_action = name
63
63
  actions(*name)
64
64
  end
65
- @default_action || ( respond_to?(:superclass) && superclass != Chef::Resource && superclass.respond_to?(:default_action) && superclass.default_action ) || (actions.first && [actions.first]) || [:nothing]
65
+ if @default_action
66
+ @default_action
67
+ elsif respond_to?(:superclass) && superclass != Chef::Resource && superclass.respond_to?(:default_action) && Array(superclass.default_action) != %i{nothing}
68
+ superclass.default_action
69
+ elsif first_non_nothing = actions.find {|action| action != :nothing }
70
+ [first_non_nothing]
71
+ else
72
+ %i{nothing}
73
+ end
66
74
  end
67
75
 
68
76
  # @overload actions()
@@ -43,6 +43,8 @@ module Poise
43
43
  end
44
44
  # Create the subcollection.
45
45
  sub_run_context.resource_collection = Poise::Subcontext::ResourceCollection.new(parent_context.resource_collection)
46
+ # Create an accessor for the parent run context.
47
+ sub_run_context.define_singleton_method(:parent_run_context) { parent_context }
46
48
 
47
49
  # Declare sub-resources within the sub-run-context. Since they
48
50
  # are declared here, they do not pollute the parent run-context.
@@ -36,8 +36,8 @@ module Poise
36
36
  # ever fire because the superclass re-raises if there is an error.
37
37
  return super if error
38
38
  delayed_actions.each do |notification|
39
- notifications = run_context.delayed_notifications(@resource)
40
- if run_context.delayed_notifications(@resource).any? { |existing_notification| existing_notification.duplicates?(notification) }
39
+ notifications = run_context.parent_run_context.delayed_notifications(@resource)
40
+ if notifications.any? { |existing_notification| existing_notification.duplicates?(notification) }
41
41
  Chef::Log.info( "#{@resource} not queuing delayed action #{notification.action} on #{notification.resource}"\
42
42
  " (delayed), as it's already been queued")
43
43
  else
data/lib/poise/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module Poise
19
- VERSION = '2.2.0'
19
+ VERSION = '2.2.1'
20
20
  end
@@ -15,6 +15,8 @@
15
15
  #
16
16
 
17
17
  require 'spec_helper'
18
+ require 'chef/provider/lwrp_base'
19
+ require 'chef/resource/lwrp_base'
18
20
 
19
21
  describe Poise::Helpers::LWRPPolyfill do
20
22
  describe Poise::Helpers::LWRPPolyfill::Resource do
@@ -156,4 +158,20 @@ describe Poise::Helpers::LWRPPolyfill do
156
158
  it { is_expected.to run_ruby_block('test') }
157
159
  end # /describe Chef::DSL::Recipe include
158
160
  end # /describe Poise::Helpers::LWRPPolyfill::Provider
161
+
162
+ context 'inside LWRPBase' do
163
+ resource(:poise_test, parent: Chef::Resource::LWRPBase, auto: false) do
164
+ include described_class
165
+ actions(:run)
166
+ end
167
+ provider(:poise_test, parent: Chef::Provider::LWRPBase, auto: false) do
168
+ include described_class
169
+ action(:run) { }
170
+ end
171
+
172
+ describe '#default_action' do
173
+ subject { resource(:poise_test).default_action }
174
+ it { is_expected.to eq %i{run} }
175
+ end # /describe #default_action
176
+ end # /context inside LWRPBase
159
177
  end
@@ -123,4 +123,35 @@ describe Poise::Helpers::NotifyingBlock do
123
123
 
124
124
  it { is_expected.to_not run_ruby_block('test') }
125
125
  end # /describe regression test for picking up sibling notifications outside the subcontext for resources with matching name
126
+
127
+ describe 'delayed notifications' do
128
+ provider(:poise_test) do
129
+ include Poise::Helpers::LWRPPolyfill
130
+ include described_class
131
+
132
+ def action_run
133
+ notifying_block do
134
+ ruby_block 'one' do
135
+ action :nothing
136
+ block { node.run_state[:things] << 'one' }
137
+ end
138
+
139
+ ruby_block 'two' do
140
+ block { node.run_state[:things] << 'two' }
141
+ notifies :run, 'ruby_block[one]'
142
+ end
143
+ end
144
+ end
145
+ end
146
+ recipe(subject: false) do
147
+ node.run_state[:things] = []
148
+ poise_test 'test'
149
+ end
150
+ subject { chef_run.node.run_state[:things] }
151
+
152
+ # The important test.
153
+ it { is_expected.to include 'one' }
154
+ # Sanity check for my harness.
155
+ it { is_expected.to include 'two' }
156
+ end # /describe delayed notifications
126
157
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz