summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-07-02 17:43:05 -0700
committerVivek Singh <vivek.singh@msystechnologies.com>2019-07-02 17:43:05 -0700
commit4e864bb502c553d73c89b3667a6b9b3e8db1846a (patch)
treef8cfda7fc860a6ba196d199209d4c2ad8eed5cf8
parentdae77fc75b5646490d9a69a5d36bf87326f18047 (diff)
downloadchef-4e864bb502c553d73c89b3667a6b9b3e8db1846a.tar.gz
Parse day param value into string
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-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)