diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-15 14:45:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-15 14:45:00 -0700 |
commit | ee46f1d5d2a8825de2d4973fb0301f2d85986e73 (patch) | |
tree | 23bc39bf0a63c4436ce3aadedfab9dd7cde5b909 /activerecord/test/cases/relations_test.rb | |
parent | 704bf0ecc550552f1cc5e453771917e8782b64ad (diff) | |
parent | e3e3851ed662fc55ee88c16a3cd9bb87f24e6bd6 (diff) | |
download | rails-ee46f1d5d2a8825de2d4973fb0301f2d85986e73.tar.gz rails-ee46f1d5d2a8825de2d4973fb0301f2d85986e73.tar.bz2 rails-ee46f1d5d2a8825de2d4973fb0301f2d85986e73.zip |
Merge branch 'master' into joindep
* master: (44 commits)
grammar fix (reverted in e9a1ecd)
Revert "fixed a doc bug in the CHANGELOG.md s/does no longer depend on/no longer depends on/"
Add missed require making `enable_warnings` available
Prepare generated Gemfile for Capistrano 3
Added --model-name option scaffold_controller_generator.
read the association instead of sending
we should have unique sponsorable ids in the fixtures at least
simplify populating the ordering hash
the preloader for the RHS has all the preloaded records, so ask it
only calculate offset index once. #12537
Remove size alias for length validation
Fix `singleton_class?`
Minor Refactoring to `NumberHelper#number_to_human`
`$SAFE = 4;` has been removed with Ruby 2.1
scope_chain should not be mutated for other reflections
Remove `default_primary_key_type` and extract contains of `native_database_types` to a constant since they aren't conditional now in SQLite3Adapter. Makes it more like other adapters.
cleanup changelog entry format. [ci skip]
Extract a function to determine if the default value is a function
Push default_function to superclass to avoid method check
Dump the default function when the primary key is uuid
...
Conflicts:
activerecord/lib/active_record/relation/finder_methods.rb
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index f814947ab2..ec43ded690 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -295,7 +295,7 @@ class RelationTest < ActiveRecord::TestCase def test_null_relation_calculations_methods assert_no_queries do assert_equal 0, Developer.none.count - assert_equal 0, Developer.none.calculate(:count, nil, {}) + assert_equal 0, Developer.none.calculate(:count, nil) assert_equal nil, Developer.none.calculate(:average, 'salary') end end @@ -486,6 +486,14 @@ class RelationTest < ActiveRecord::TestCase assert_equal Developer.where(name: 'David').map(&:id).sort, developers end + def test_includes_with_select + query = Post.select('comments_count AS ranking').order('ranking').includes(:comments) + .where(comments: { id: 1 }) + + assert_equal ['comments_count AS ranking'], query.select_values + assert_equal 1, query.to_a.size + end + def test_loading_with_one_association posts = Post.preload(:comments) post = posts.find { |p| p.id == 1 } @@ -626,6 +634,11 @@ class RelationTest < ActiveRecord::TestCase relation = Author.where(:id => Author.where(:id => david.id)) assert_equal [david], relation.to_a } + + assert_queries(1) { + relation = Author.where('id in (?)', Author.where(id: david).select(:id)) + assert_equal [david], relation.to_a + } end def test_find_all_using_where_with_relation_and_alternate_primary_key |