Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic DatePicker value isn't being set correctly #18523

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/dialog_field_date_control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def normalize_automate_values(automate_hash)

return default_time if automate_hash["value"].blank?
begin
return DateTime.parse(automate_hash["value"]).iso8601
return DateTime.parse(automate_hash["value"].to_s).iso8601
rescue
return default_time
end
Expand Down
12 changes: 11 additions & 1 deletion spec/models/dialog_field_date_control_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
end

context "when the automate hash has a value" do
context "when the value is a date format" do
context "when the value is a string" do
let(:value) { "01/02/2015" }

it_behaves_like "DialogFieldDateControl#normalize_automate_values"
Expand All @@ -95,6 +95,16 @@
end
end

context "when the value is a date object" do
let(:value) { Time.utc(2015, 1, 2) }

it_behaves_like "DialogFieldDateControl#normalize_automate_values"

it "returns the value in iso format" do
expect(dialog_field.normalize_automate_values(automate_hash)).to eq("2015-01-02T00:00:00+00:00")
end
end

context "when the value is not a proper date format" do
let(:value) { "not a date" }

Expand Down