This project is archived and is in readonly mode.

#4598 open
David Chelimsky

default_scope treats hashes and relations inconsistently when overwriting

Reported by David Chelimsky | May 14th, 2010 @ 10:41 PM | in 3.1

In working on #4583, Brian and I discovered some inconsistent behavior. Here are a couple of tests that should both behave the same way, but one passes and one fails:

require "cases/helper"
require 'models/developer'

class ArelBugTest < ActiveRecord::TestCase
  fixtures :developers

  # We would expect both to pass or both to fail, but one passes and one fails.

  # fails
  def test_default_scope_called_twice_with_relations
    klass =
    klass.class_eval do 
      default_scope where(:name => 'David')
      default_scope where(:name => 'Jamis')
    assert_equal ["Jamis"],
  # passes
  def test_default_scope_called_twice_with_hashes
    klass =
    klass.class_eval do 
      default_scope :conditions => { :name => 'David' }
      default_scope :conditions => { :name => 'Jamis' }
    assert_equal ["Jamis"],

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by