summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/windows_task.rb4
-rw-r--r--spec/unit/provider/windows_task_spec.rb7
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 83347b764a..49f67d680d 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -446,7 +446,7 @@ class Chef
def days_of_month
days_of_month = []
if new_resource.day
- days = new_resource.day.split(",")
+ days = new_resource.day.to_s.split(",")
days.map! { |day| day.to_s.strip.upcase }
days.delete("LAST") if days.include?("LAST")
days.delete("LASTDAY") if days.include?("LASTDAY")
@@ -466,7 +466,7 @@ class Chef
if new_resource.day
# this line of code is just to support backward compatibility of wild card *
new_resource.day = "mon, tue, wed, thu, fri, sat, sun" if new_resource.day == "*" && new_resource.frequency == :weekly
- days = new_resource.day.split(",")
+ days = new_resource.day.to_s.split(",")
days.map! { |day| day.to_s.strip.upcase }
weeks_days = get_binary_values_from_constants(days, DAYS_OF_WEEK)
else
diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb
index 3565da1ca3..8cce861f2a 100644
--- a/spec/unit/provider/windows_task_spec.rb
+++ b/spec/unit/provider/windows_task_spec.rb
@@ -265,11 +265,16 @@ describe Chef::Provider::WindowsTask, :windows_only do
# REF: https://msdn.microsoft.com/en-us/library/windows/desktop/aa382063(v=vs.85).aspx
describe "#days_of_month" do
- it "returns the binary value 1 if day is set as 1" do
+ it "returns the binary value 1 if day is set as string 1" do
new_resource.day "1"
expect(provider.send(:days_of_month)).to eq(1)
end
+ it "returns the binary value 1 if day is set as integer 1" do
+ new_resource.day 1
+ expect(provider.send(:days_of_month)).to eq(1)
+ end
+
it "returns the binary value 2 if day is set as 2" do
new_resource.day "2"
expect(provider.send(:days_of_month)).to eq(2)