summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-07-02 17:43:05 -0700
committerTim Smith <tsmith84@gmail.com>2019-10-09 11:38:22 -0700
commit7c3e18aeabeafb309eab8e4e2f7f15c61f208752 (patch)
tree32bc5fb5835663a3e09c9d49a335362c49618e4d
parent543af3fd71d8b9d6e0e37bbe9c750fa31be8dfcf (diff)
downloadchef-7c3e18aeabeafb309eab8e4e2f7f15c61f208752.tar.gz
Parse day param value into stringwindows_task_fix
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 e616267fd9..f57d7c25e3 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -444,7 +444,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")
@@ -464,7 +464,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)