diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-06-28 17:17:56 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-29 01:18:20 +0200 |
commit | 40e87ac66912b06c31c98b057a49c64f5555dd99 (patch) | |
tree | ba71118993dfb0043d3ab0a75b661bc76ab5ee99 /activerecord/test | |
parent | f8011e67b002990e1c25550c161ab0af6af6620f (diff) | |
download | rails-40e87ac66912b06c31c98b057a49c64f5555dd99.tar.gz rails-40e87ac66912b06c31c98b057a49c64f5555dd99.tar.bz2 rails-40e87ac66912b06c31c98b057a49c64f5555dd99.zip |
with_exclusive_scope does not work properly if ARel is passed. It does work nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope.
[#3838 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/method_scoping_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/developer.rb | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index 6cd42ff936..178562eb9b 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -283,6 +283,12 @@ class NestedScopingTest < ActiveRecord::TestCase end end + def test_with_exclusive_scope_with_relation + assert_raise(ArgumentError) do + Developer.all_johns + end + end + def test_append_conditions Developer.send(:with_scope, :find => { :conditions => "name = 'David'" }) do Developer.send(:with_scope, :find => { :conditions => 'salary = 80000' }) do diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb index e35de3b9b0..de68fd7f24 100644 --- a/activerecord/test/models/developer.rb +++ b/activerecord/test/models/developer.rb @@ -55,6 +55,12 @@ class Developer < ActiveRecord::Base def log=(message) audit_logs.build :message => message end + + def self.all_johns + self.with_exclusive_scope :find => where(:name => 'John') do + self.all + end + end end class AuditLog < ActiveRecord::Base @@ -103,4 +109,4 @@ end class PoorDeveloperCalledJamis < ActiveRecord::Base self.table_name = 'developers' default_scope :conditions => { :name => 'Jamis', :salary => 50000 } -end
\ No newline at end of file +end |