do not rely on arel class structure
This commit is contained in:
parent
62bb83d0a2
commit
12b3eca420
@ -319,7 +319,9 @@ def to_sql
|
||||
def scope_for_create
|
||||
@scope_for_create ||= begin
|
||||
@create_with_value || Hash[
|
||||
@where_values.grep(Arel::Predicates::Equality).map { |where|
|
||||
@where_values.find_all { |w|
|
||||
w.respond_to?(:operator) && w.operator == :==
|
||||
}.map { |where|
|
||||
[where.operand1.name,
|
||||
where.operand2.respond_to?(:value) ?
|
||||
where.operand2.value : where.operand2]
|
||||
|
@ -208,6 +208,13 @@ def test_scoped_count_include
|
||||
end
|
||||
end
|
||||
|
||||
def test_scope_for_create_only_uses_equal
|
||||
table = VerySpecialComment.arel_table
|
||||
relation = VerySpecialComment.scoped
|
||||
relation.where_values << table[:id].not_eq(1)
|
||||
assert_equal({:type => "VerySpecialComment"}, relation.send(:scope_for_create))
|
||||
end
|
||||
|
||||
def test_scoped_create
|
||||
new_comment = nil
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user