diff options
Diffstat (limited to 'activerecord/test/cases/relation/where_test.rb')
-rw-r--r-- | activerecord/test/cases/relation/where_test.rb | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb index 56a2b5b8c6..ce4e041793 100644 --- a/activerecord/test/cases/relation/where_test.rb +++ b/activerecord/test/cases/relation/where_test.rb @@ -19,7 +19,7 @@ module ActiveRecord def test_where_copies_bind_params author = authors(:david) - posts = author.posts.where('posts.id != 1') + posts = author.posts.where("posts.id != 1") joined = Post.where(id: posts) assert_operator joined.length, :>, 0 @@ -49,7 +49,7 @@ module ActiveRecord end def test_rewhere_on_root - assert_equal posts(:welcome), Post.rewhere(title: 'Welcome to the weblog').first + assert_equal posts(:welcome), Post.rewhere(title: "Welcome to the weblog").first end def test_belongs_to_shallow_where @@ -97,7 +97,7 @@ module ActiveRecord treasure = Treasure.new treasure.id = 1 - expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: 1) + expected = PriceEstimate.where(estimate_of_type: "Treasure", estimate_of_id: 1) actual = PriceEstimate.where(estimate_of: treasure) assert_equal expected.to_sql, actual.to_sql @@ -109,7 +109,7 @@ module ActiveRecord hidden = HiddenTreasure.new hidden.id = 2 - expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: [treasure, hidden]) + expected = PriceEstimate.where(estimate_of_type: "Treasure", estimate_of_id: [treasure, hidden]) actual = PriceEstimate.where(estimate_of: [treasure, hidden]) assert_equal expected.to_sql, actual.to_sql @@ -127,7 +127,7 @@ module ActiveRecord end def test_polymorphic_nested_relation_where - expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: Treasure.where(id: [1,2])) + expected = PriceEstimate.where(estimate_of_type: "Treasure", estimate_of_id: Treasure.where(id: [1,2])) actual = PriceEstimate.where(estimate_of: Treasure.where(id: [1,2])) assert_equal expected.to_sql, actual.to_sql @@ -137,7 +137,7 @@ module ActiveRecord treasure = HiddenTreasure.new treasure.id = 1 - expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: 1) + expected = PriceEstimate.where(estimate_of_type: "Treasure", estimate_of_id: 1) actual = PriceEstimate.where(estimate_of: treasure) assert_equal expected.to_sql, actual.to_sql @@ -147,7 +147,7 @@ module ActiveRecord thing = Post.new thing.id = 1 - expected = Treasure.where(price_estimates: { thing_type: 'Post', thing_id: 1 }).joins(:price_estimates) + expected = Treasure.where(price_estimates: { thing_type: "Post", thing_id: 1 }).joins(:price_estimates) actual = Treasure.where(price_estimates: { thing: thing }).joins(:price_estimates) assert_equal expected.to_sql, actual.to_sql @@ -157,7 +157,7 @@ module ActiveRecord treasure = HiddenTreasure.new treasure.id = 1 - expected = Treasure.where(price_estimates: { estimate_of_type: 'Treasure', estimate_of_id: 1 }).joins(:price_estimates) + expected = Treasure.where(price_estimates: { estimate_of_type: "Treasure", estimate_of_id: 1 }).joins(:price_estimates) actual = Treasure.where(price_estimates: { estimate_of: treasure }).joins(:price_estimates) assert_equal expected.to_sql, actual.to_sql @@ -182,40 +182,40 @@ module ActiveRecord treasure.id = 1 decorated_treasure = treasure_decorator.new(treasure) - expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: 1) + expected = PriceEstimate.where(estimate_of_type: "Treasure", estimate_of_id: 1) actual = PriceEstimate.where(estimate_of: decorated_treasure) assert_equal expected.to_sql, actual.to_sql end def test_aliased_attribute - expected = Topic.where(heading: 'The First Topic') - actual = Topic.where(title: 'The First Topic') + expected = Topic.where(heading: "The First Topic") + actual = Topic.where(title: "The First Topic") assert_equal expected.to_sql, actual.to_sql end def test_where_error - assert_raises(ActiveRecord::StatementInvalid) do - Post.where(:id => { 'posts.author_id' => 10 }).first + assert_nothing_raised do + Post.where(id: { "posts.author_id" => 10 }).first end end def test_where_with_table_name post = Post.first - assert_equal post, Post.where(:posts => { 'id' => post.id }).first + assert_equal post, Post.where(posts: { "id" => post.id }).first end def test_where_with_table_name_and_empty_hash - assert_equal 0, Post.where(:posts => {}).count + assert_equal 0, Post.where(posts: {}).count end def test_where_with_table_name_and_empty_array - assert_equal 0, Post.where(:id => []).count + assert_equal 0, Post.where(id: []).count end def test_where_with_empty_hash_and_no_foreign_key - assert_equal 0, Edge.where(:sink => {}).count + assert_equal 0, Edge.where(sink: {}).count end def test_where_with_blank_conditions @@ -225,32 +225,32 @@ module ActiveRecord end def test_where_with_integer_for_string_column - count = Post.where(:title => 0).count + count = Post.where(title: 0).count assert_equal 0, count end def test_where_with_float_for_string_column - count = Post.where(:title => 0.0).count + count = Post.where(title: 0.0).count assert_equal 0, count end def test_where_with_boolean_for_string_column - count = Post.where(:title => false).count + count = Post.where(title: false).count assert_equal 0, count end def test_where_with_decimal_for_string_column - count = Post.where(:title => BigDecimal.new(0)).count + count = Post.where(title: BigDecimal.new(0)).count assert_equal 0, count end def test_where_with_duration_for_string_column - count = Post.where(:title => 0.seconds).count + count = Post.where(title: 0.seconds).count assert_equal 0, count end def test_where_with_integer_for_binary_column - count = Binary.where(:data => 0).count + count = Binary.where(data: 0).count assert_equal 0, count end |