From 686e8fb52e00b24bd3a334cd7748df950914bfbf Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 10 Jun 2017 19:13:30 +0900 Subject: `Relation#locked?` should not build arel --- activerecord/test/cases/relations_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 86f3b0b962..5f36e4ec5d 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -2001,6 +2001,12 @@ class RelationTest < ActiveRecord::TestCase assert_equal binds, merged.bound_attributes end + def test_locked_should_not_build_arel + posts = Post.lock + assert posts.locked? + assert_nothing_raised { posts.lock!(false) } + end + def test_relation_join_method assert_equal "Thank you for the welcome,Thank you again for the welcome", Post.first.comments.join(",") end -- cgit v1.2.3 From 425f2cacafc522bb0aa426a0a4bc92c1237160aa Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 29 Jun 2017 02:11:28 +0900 Subject: Remove delegating to arel in a relation The delegation was needed since passing `relation` with `relation.bound_attributes`. It should use `relation.arel` in that case. --- activerecord/test/cases/relations_test.rb | 2 +- activerecord/test/models/post.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 5f36e4ec5d..84ccfbf5d5 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -2002,7 +2002,7 @@ class RelationTest < ActiveRecord::TestCase end def test_locked_should_not_build_arel - posts = Post.lock + posts = Post.locked assert posts.locked? assert_nothing_raised { posts.lock!(false) } end diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 4c913b3b72..ed64e0ee52 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -22,6 +22,7 @@ class Post < ActiveRecord::Base scope :ranked_by_comments, -> { order("comments_count DESC") } scope :limit_by, lambda { |l| limit(l) } + scope :locked, -> { lock } belongs_to :author belongs_to :readonly_author, -> { readonly }, class_name: "Author", foreign_key: :author_id -- cgit v1.2.3