Methods
- I
- M
- N
- P
- T
-
- test_aliased_attribute,
- test_belongs_to_array_value_where,
- test_belongs_to_nested_relation_where,
- test_belongs_to_nested_where,
- test_belongs_to_nested_where_with_relation,
- test_belongs_to_nil_where,
- test_belongs_to_shallow_where,
- test_decorated_polymorphic_where,
- test_polymorphic_array_where_multiple_types,
- test_polymorphic_nested_array_where,
- test_polymorphic_nested_relation_where,
- test_polymorphic_nested_where,
- test_polymorphic_shallow_where,
- test_polymorphic_sti_nested_where,
- test_polymorphic_sti_shallow_where,
- test_rewhere_on_root,
- test_where_copies_arel_bind_params,
- test_where_copies_bind_params,
- test_where_copies_bind_params_in_the_right_order,
- test_where_error,
- test_where_on_association_with_custom_primary_key,
- test_where_on_association_with_custom_primary_key_with_array_of_base,
- test_where_on_association_with_custom_primary_key_with_array_of_ids,
- test_where_on_association_with_custom_primary_key_with_relation,
- test_where_on_association_with_relation_performs_subselect_not_two_queries,
- test_where_with_blank_conditions,
- test_where_with_boolean_for_string_column,
- test_where_with_decimal_for_string_column,
- test_where_with_duration_for_string_column,
- test_where_with_empty_hash_and_no_foreign_key,
- test_where_with_float_for_string_column,
- test_where_with_integer_for_binary_column,
- test_where_with_integer_for_string_column,
- test_where_with_strong_parameters,
- test_where_with_table_name,
- test_where_with_table_name_and_empty_array,
- test_where_with_table_name_and_empty_hash,
- test_where_with_unsupported_arguments,
- to_h
Class Public methods
method_missing(method, *args, &block)
Link
new(parameters)
Link
Instance Public methods
is_a?(klass)
Link
method_missing(method, *args, &block)
Link
permit!()
Link
test_aliased_attribute()
Link
test_belongs_to_array_value_where()
Link
test_belongs_to_nested_relation_where()
Link
test_belongs_to_nested_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 77 def test_belongs_to_nested_where parent = Comment.new parent.id = 1 expected = Post.where(comments: { parent_id: 1 }).joins(:comments) actual = Post.where(comments: { parent: parent }).joins(:comments) assert_equal expected.to_sql, actual.to_sql end
test_belongs_to_nested_where_with_relation()
Link
# File activerecord/test/cases/relation/where_test.rb, line 87 def test_belongs_to_nested_where_with_relation author = authors(:david) expected = Author.where(id: author ).joins(:posts) actual = Author.where(posts: { author_id: Author.where(id: author.id) }).joins(:posts) assert_equal expected.to_a, actual.to_a end
test_belongs_to_nil_where()
Link
test_belongs_to_shallow_where()
Link
test_decorated_polymorphic_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 166 def test_decorated_polymorphic_where treasure_decorator = Struct.new(:model) do def self.method_missing(method, *args, &block) Treasure.send(method, *args, &block) end def is_a?(klass) model.is_a?(klass) end def method_missing(method, *args, &block) model.send(method, *args, &block) end end treasure = Treasure.new treasure.id = 1 decorated_treasure = treasure_decorator.new(treasure) 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
test_polymorphic_array_where_multiple_types()
Link
# File activerecord/test/cases/relation/where_test.rb, line 118 def test_polymorphic_array_where_multiple_types treasure_1 = treasures(:diamond) treasure_2 = treasures(:sapphire) car = cars(:honda) expected = [price_estimates(:diamond), price_estimates(:sapphire_1), price_estimates(:sapphire_2), price_estimates(:honda)].sort actual = PriceEstimate.where(estimate_of: [treasure_1, treasure_2, car]).to_a.sort assert_equal expected, actual end
test_polymorphic_nested_array_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 106 def test_polymorphic_nested_array_where treasure = Treasure.new treasure.id = 1 hidden = HiddenTreasure.new hidden.id = 2 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 end
test_polymorphic_nested_relation_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 129 def test_polymorphic_nested_relation_where 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 end
test_polymorphic_nested_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 146 def test_polymorphic_nested_where thing = Post.new thing.id = 1 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 end
test_polymorphic_shallow_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 96 def test_polymorphic_shallow_where treasure = Treasure.new treasure.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 end
test_polymorphic_sti_nested_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 156 def test_polymorphic_sti_nested_where treasure = HiddenTreasure.new treasure.id = 1 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 end
test_polymorphic_sti_shallow_where()
Link
# File activerecord/test/cases/relation/where_test.rb, line 136 def test_polymorphic_sti_shallow_where treasure = HiddenTreasure.new treasure.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 end
test_rewhere_on_root()
Link
test_where_copies_arel_bind_params()
Link
# File activerecord/test/cases/relation/where_test.rb, line 41 def test_where_copies_arel_bind_params chef = Chef.create! CakeDesigner.create!(chef: chef) cake_designers = CakeDesigner.joins(:chef).where(chefs: { id: chef.id }) chefs = Chef.where(employable: cake_designers) assert_equal [chef], chefs.to_a end
test_where_copies_bind_params()
Link
# File activerecord/test/cases/relation/where_test.rb, line 20 def test_where_copies_bind_params author = authors(:david) posts = author.posts.where('posts.id != 1') joined = Post.where(id: posts) assert_operator joined.length, :>, 0 joined.each { |post| assert_equal author, post.author assert_not_equal 1, post.id } end
test_where_copies_bind_params_in_the_right_order()
Link
test_where_error()
Link
test_where_on_association_with_custom_primary_key()
Link
test_where_on_association_with_custom_primary_key_with_array_of_base()
Link
test_where_on_association_with_custom_primary_key_with_array_of_ids()
Link
test_where_on_association_with_custom_primary_key_with_relation()
Link
test_where_on_association_with_relation_performs_subselect_not_two_queries()
Link
test_where_with_blank_conditions()
Link
test_where_with_boolean_for_string_column()
Link
test_where_with_decimal_for_string_column()
Link
test_where_with_duration_for_string_column()
Link
test_where_with_empty_hash_and_no_foreign_key()
Link
test_where_with_float_for_string_column()
Link
test_where_with_integer_for_binary_column()
Link
test_where_with_integer_for_string_column()
Link
test_where_with_strong_parameters()
Link
# File activerecord/test/cases/relation/where_test.rb, line 292 def test_where_with_strong_parameters protected_params = Class.new do attr_reader :permitted alias :permitted? :permitted def initialize(parameters) @parameters = parameters @permitted = false end def to_h @parameters end def permit! @permitted = true self end end author = authors(:david) params = protected_params.new(name: author.name) assert_raises(ActiveModel::ForbiddenAttributesError) { Author.where(params) } assert_equal author, Author.where(params.permit!).first end
test_where_with_table_name()
Link
test_where_with_table_name_and_empty_array()
Link
test_where_with_table_name_and_empty_hash()
Link
test_where_with_unsupported_arguments()
Link