summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2018-01-12 15:18:05 +0530
committerdheerajd-msys <dheeraj.dubey@msystechnologies.com>2018-01-16 16:13:49 +0530
commit7e0b00834bb4a866bdb4de01fc12a2cba55b6cbb (patch)
tree96e56247e927a653d2ee1eb69de11fe0d6088d95
parent0f71e2d0a67357fa069607dd3ef3554e436bf646 (diff)
downloadchef-7e0b00834bb4a866bdb4de01fc12a2cba55b6cbb.tar.gz
Fix rspecs
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r--lib/chef/resource/windows_task.rb3
-rw-r--r--spec/unit/resource/windows_task_spec.rb4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index c2439797df..43232813de 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -61,6 +61,7 @@ class Chef
attr_accessor :exists, :status, :enabled
def after_created
+
if random_delay
validate_random_delay(random_delay, frequency)
duration = sec_to_dur(random_delay)
@@ -82,7 +83,7 @@ class Chef
validate_create_frequency_modifier(frequency, frequency_modifier)
validate_create_day(day, frequency) if day
validate_create_months(months, frequency) if months
- validate_idle_time(idle_time, frequency) if idle_time.nil? || !(idle_time > 0 && idle_time <= 999)
+ validate_idle_time(idle_time, frequency) if (idle_time.nil? || !(idle_time > 0 && idle_time <= 999)) && !([:minute, :hourly, :daily, :weekly, :monthly].include? frequency)
end
private
diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb
index 18a4960d90..102a5e8874 100644
--- a/spec/unit/resource/windows_task_spec.rb
+++ b/spec/unit/resource/windows_task_spec.rb
@@ -111,6 +111,10 @@ describe Chef::Resource::WindowsTask do
resource.after_created
expect(resource.random_delay).to eq("PT60S")
end
+
+ it "raises error that random_delay is not supported" do
+ expect { resource.send(:validate_random_delay, 60, :on_idle) }.to raise_error(ArgumentError, "`random_delay` property is supported only for frequency :minute, :hourly, :daily, :weekly and :monthly")
+ end
end
context "when execution_time_limit isn't specified" do