diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-06-28 16:43:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 16:43:28 -0400 |
commit | 8c65abe5f804522bcbf0d6f4327e7dfad0603941 (patch) | |
tree | d5ccbfd4eb67d82ff4ccd02c4d0b6f067d71fcd6 /activerecord/test | |
parent | 97d276bf8a6b9d79dc50fcbc8a45f6071da0fcef (diff) | |
parent | 425f2cacafc522bb0aa426a0a4bc92c1237160aa (diff) | |
download | rails-8c65abe5f804522bcbf0d6f4327e7dfad0603941.tar.gz rails-8c65abe5f804522bcbf0d6f4327e7dfad0603941.tar.bz2 rails-8c65abe5f804522bcbf0d6f4327e7dfad0603941.zip |
Merge pull request #29405 from kamipo/locked_should_not_build_arel
`Relation#locked?` should not build arel
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index dc81f13fe9..5767dec315 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -2007,6 +2007,12 @@ class RelationTest < ActiveRecord::TestCase assert_equal binds, merged.bound_attributes end + def test_locked_should_not_build_arel + posts = Post.locked + 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 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 |