diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-25 07:56:07 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-25 07:56:07 -0800 |
commit | d8dd965764ac6647a8f9befa279c468f67703a3a (patch) | |
tree | 70f2bbdd782970e85571cde3c84609ba04f879df /activerecord/test/cases | |
parent | 2eb89627d844dec2a4ba420ca903bb139b860e43 (diff) | |
parent | ec9aa3ca892fbda77c2fe628acf4db46ba095090 (diff) | |
download | rails-d8dd965764ac6647a8f9befa279c468f67703a3a.tar.gz rails-d8dd965764ac6647a8f9befa279c468f67703a3a.tar.bz2 rails-d8dd965764ac6647a8f9befa279c468f67703a3a.zip |
Merge pull request #9197 from yaotti/fix/overriden-attr-on-dup
Fix: Overriding attributes on `dup` by default scopes
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/dup_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb index eca500f7e4..fe105b9d22 100644 --- a/activerecord/test/cases/dup_test.rb +++ b/activerecord/test/cases/dup_test.rb @@ -123,5 +123,14 @@ module ActiveRecord assert duped.valid? end end + + def test_dup_with_default_scope + prev_default_scopes = Topic.default_scopes + Topic.default_scopes = [Topic.where(:approved => true)] + topic = Topic.new(:approved => false) + assert !topic.dup.approved?, "should not be overriden by default scopes" + ensure + Topic.default_scopes = prev_default_scopes + end end end |