Skip to content

Instantly share code, notes, and snippets.

@e1senh0rn
Created February 20, 2012 13:39
Show Gist options
  • Select an option

  • Save e1senh0rn/1869232 to your computer and use it in GitHub Desktop.

Select an option

Save e1senh0rn/1869232 to your computer and use it in GitHub Desktop.
~/Projects/tmp/rails/activerecord git:(master*) (ruby-1.9.3-p0@rails32)» ruby -Itest test/cases/relations_test.rb -n test_except
Using sqlite3 with Identity Map off
Run options: -n test_except --seed 29142
# Running tests:
F
Finished tests in 0.250804s, 3.9872 tests/s, 15.9487 assertions/s.
1) Failure:
test_except(RelationTest) [test/cases/relations_test.rb:1021]:
--- expected
+++ actual
@@ -1 +1 @@
-"SELECT \"posts\".* FROM \"posts\" "
+"SELECT \"posts\".* FROM \"posts\" ORDER BY title"
1 tests, 4 assertions, 1 failures, 0 errors, 0 skips
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 7b1d65c..2705db5 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1015,6 +1015,10 @@ class RelationTest < ActiveRecord::TestCase
all_posts = relation.except(:where, :order, :limit)
assert_equal Post.all, all_posts.all
+
+ unscoped_sql = PostWithDefaultScope.unscoped.to_sql
+ except_sql = PostWithDefaultScope.except(:order).to_sql
+ assert_equal unscoped_sql, except_sql
end
def test_extensions_with_except
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment