Merge pull request #49409 from stevepolitodesign/sp-datetime-local-scaffold

Ensure system test scaffold supports `datetime` and `time` attributes
This commit is contained in:
Eileen M. Uchitelle 2023-09-28 09:34:53 -04:00 committed by GitHub
commit 9cb6f443d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

@ -63,6 +63,16 @@ def virtual?(name)
attribute = attributes.find { |attr| attr.name == name }
attribute&.virtual?
end
def datetime?(name)
attribute = attributes.find { |attr| attr.name == name }
attribute&.type == :datetime
end
def time?(name)
attribute = attributes.find { |attr| attr.name == name }
attribute&.type == :time
end
end
end
end

@ -35,6 +35,8 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
<%- attributes_hash.each do |attr, value| -%>
<%- if boolean?(attr) -%>
check "<%= attr.humanize %>" if <%= value %>
<%- elsif datetime?(attr) || time?(attr) -%>
fill_in "<%= attr.humanize %>", with: <%= value %>.to_s
<%- else -%>
fill_in "<%= attr.humanize %>", with: <%= value %>
<%- end -%>