aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-11 16:14:51 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-11 16:14:51 -0700
commit85f3a57a57b3c6d105e35936bf3ee972dc652902 (patch)
treebff7790eaeb0c336d24ebca1af93e9b3a9e33788 /activerecord/test
parentdbc8c0ee36ddda7c27a375c78bbdb989fd30c298 (diff)
downloadrails-85f3a57a57b3c6d105e35936bf3ee972dc652902.tar.gz
rails-85f3a57a57b3c6d105e35936bf3ee972dc652902.tar.bz2
rails-85f3a57a57b3c6d105e35936bf3ee972dc652902.zip
propogate bind values collected in arel to SQL generation
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/relations_test.rb8
-rw-r--r--activerecord/test/models/post.rb2
2 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 662e374ddd..dc196f4432 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -864,6 +864,14 @@ class RelationTest < ActiveRecord::TestCase
assert_equal 11, posts.distinct(false).select(:comments_count).count
end
+ def test_update_all_with_scope
+ tag = Tag.first
+ Post.tagged_with(tag.id).update_all title: "rofl"
+ list = Post.tagged_with(tag.id).all.to_a
+ assert_operator list.length, :>, 0
+ list.each { |post| assert_equal 'rofl', post.title }
+ end
+
def test_count_explicit_columns
Post.update_all(:comments_count => nil)
posts = Post.all
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 099e039255..d9ecaee1d9 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -40,6 +40,8 @@ class Post < ActiveRecord::Base
scope :with_comments, -> { preload(:comments) }
scope :with_tags, -> { preload(:taggings) }
+ scope :tagged_with, ->(id) { joins(:taggings).where(taggings: { tag_id: id }) }
+
has_many :comments do
def find_most_recent
order("id DESC").first