aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/calculations_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-06-17 10:47:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-06-17 10:47:08 -0700
commit252d11321f8ca0c47111304ffe37d9bf69cad77b (patch)
tree301a28faa688f421a353df15cc16f1ae558e8deb /activerecord/test/cases/calculations_test.rb
parent89c9ff8d8b70bb5b0bc56576be94f27f87996bbe (diff)
parentad707a1f16dea6a93f37feed711ec0b51c2d3ab6 (diff)
downloadrails-252d11321f8ca0c47111304ffe37d9bf69cad77b.tar.gz
rails-252d11321f8ca0c47111304ffe37d9bf69cad77b.tar.bz2
rails-252d11321f8ca0c47111304ffe37d9bf69cad77b.zip
Merge branch 'master' into mrbrdo-fixserialization
* master: (142 commits) Use Colspan in th Tags Added test for link_to_unless to make sure the result consistency. Escape the string even when the condition of link_to_unless is not satisfied. Add CHANGELOG entry for #10969 Use a case insensitive URI Regexp for #asset_path collection tags accept html attributes as the last element of collection Rewind StringIO instances before be parsed again Use xml instead already parsed xml Updated the doc for const_regexp [ci skip] Make test name descriptive and add reference to original regression commit fixture setup does not rely on `AR::Base.configurations`. regression test + mysql2 adapter raises correct error if conn is closed. cleanup, remove trailing whitespace from AR changelog 'json' gem is no more required under JRuby fix typos Fix AS changelog [ci skip] Update the HTML boolean attributes per the HTML 5.1 spec Changing const_regexp to check for constant name. valid_app_const? -> valid_const? Add CHANGELOG entry for #10740 ...
Diffstat (limited to 'activerecord/test/cases/calculations_test.rb')
-rw-r--r--activerecord/test/cases/calculations_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 095b78c6c8..0f3f9aecfc 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -6,6 +6,7 @@ require 'models/edge'
require 'models/organization'
require 'models/possession'
require 'models/topic'
+require 'models/reply'
require 'models/minivan'
require 'models/speedometer'
require 'models/ship_part'
@@ -166,6 +167,15 @@ class CalculationsTest < ActiveRecord::TestCase
assert_no_match(/OFFSET/, queries.first)
end
+ def test_count_on_invalid_columns_raises
+ e = assert_raises(ActiveRecord::StatementInvalid) {
+ Account.select("credit_limit, firm_name").count
+ }
+
+ assert_match "accounts", e.message
+ assert_match "credit_limit, firm_name", e.message
+ end
+
def test_should_group_by_summed_field_having_condition
c = Account.group(:firm_id).having('sum(credit_limit) > 50').sum(:credit_limit)
assert_nil c[1]
@@ -472,6 +482,11 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal [1,2,3,4], Topic.order(:id).pluck(:id)
end
+ def test_pluck_without_column_names
+ assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, ""]],
+ Company.order(:id).limit(1).pluck
+ end
+
def test_pluck_type_cast
topic = topics(:first)
relation = Topic.where(:id => topic.id)
@@ -533,6 +548,11 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal Company.all.map(&:id).sort, Company.ids.sort
end
+ def test_pluck_with_includes_limit_and_empty_result
+ assert_equal [], Topic.includes(:replies).limit(0).pluck(:id)
+ assert_equal [], Topic.includes(:replies).limit(1).where('0 = 1').pluck(:id)
+ end
+
def test_pluck_not_auto_table_name_prefix_if_column_included
Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)])
ids = Company.includes(:contracts).pluck(:developer_id)