Anonymous avatar Anonymous committed 8e74e43 Merge

Merge branch 'master' of https://github.com/rails/rails

Comments (0)

Files changed (3)

activerecord/CHANGELOG.md

 ## Rails 4.0.0.beta1 (February 25, 2013) ##
 
+*   Fix overriding of attributes by default_scope on `ActiveRecord::Base#dup`.
+
+    *Hiroshige UMINO*
+
 *   Fixing issue #8345. Now throwing an error when one attempts to touch a
     new object that has not yet been persisted. For instance:
 

activerecord/lib/active_record/core.rb

       @new_record  = true
 
       ensure_proper_type
-      populate_with_current_scope_attributes
       super
     end
 

activerecord/test/cases/dup_test.rb

         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.