diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-04-24 16:16:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 16:16:00 -0400 |
commit | d4d145a6795ee7f461ef86a07e73a1f13fdb8574 (patch) | |
tree | ed4780a32c4e78d9890db43e02499e1b2e25d907 /actionview | |
parent | 9834be65655e8552d25633b7376ab0654a23875d (diff) | |
parent | 5e24c333505c3bab3c85d834ac985281f141709f (diff) | |
download | rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.tar.gz rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.tar.bz2 rails-d4d145a6795ee7f461ef86a07e73a1f13fdb8574.zip |
Merge pull request #32313 from lulalala/model_error_as_object
Model error as object
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/test/template/active_model_helper_test.rb | 10 | ||||
-rw-r--r-- | actionview/test/template/form_options_helper_test.rb | 14 |
2 files changed, 17 insertions, 7 deletions
diff --git a/actionview/test/template/active_model_helper_test.rb b/actionview/test/template/active_model_helper_test.rb index 36afed6dd6..c6a3c9064f 100644 --- a/actionview/test/template/active_model_helper_test.rb +++ b/actionview/test/template/active_model_helper_test.rb @@ -20,11 +20,11 @@ class ActiveModelHelperTest < ActionView::TestCase super @post = Post.new - @post.errors[:author_name] << "can't be empty" - @post.errors[:body] << "foo" - @post.errors[:category] << "must exist" - @post.errors[:published] << "must be accepted" - @post.errors[:updated_at] << "bar" + assert_deprecated { @post.errors[:author_name] << "can't be empty" } + assert_deprecated { @post.errors[:body] << "foo" } + assert_deprecated { @post.errors[:category] << "must exist" } + assert_deprecated { @post.errors[:published] << "must be accepted" } + assert_deprecated { @post.errors[:updated_at] << "bar" } @post.author_name = "" @post.body = "Back to the hill and over it again!" diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 4ccd3ae336..c9c36917d6 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -29,10 +29,20 @@ class FormOptionsHelperTest < ActionView::TestCase end Continent = Struct.new("Continent", :continent_name, :countries) Country = Struct.new("Country", :country_id, :country_name) - Firm = Struct.new("Firm", :time_zone) Album = Struct.new("Album", :id, :title, :genre) end + class Firm + include ActiveModel::Validations + extend ActiveModel::Naming + + attr_accessor :time_zone + + def initialize(time_zone = nil) + @time_zone = time_zone + end + end + module FakeZones FakeZone = Struct.new(:name) do def to_s; name; end @@ -1294,7 +1304,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_time_zone_select_with_priority_zones_and_errors @firm = Firm.new("D") @firm.extend ActiveModel::Validations - @firm.errors[:time_zone] << "invalid" + assert_deprecated { @firm.errors[:time_zone] << "invalid" } zones = [ ActiveSupport::TimeZone.new("A"), ActiveSupport::TimeZone.new("D") ] html = time_zone_select("firm", "time_zone", zones) assert_dom_equal "<div class=\"field_with_errors\">" \ |