rails 5: fix initializer specs

in particular, completely dump the quoting monkeypatch and specs -
we no longer know what column it's quoting for at this level, and
the float problems have long been fixed in rails proper

Change-Id: I9bbd214e6c866fcae1222f368f544f4805aac1cf
Reviewed-on: https://gerrit.instructure.com/103830
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2017-03-02 14:49:57 -07:00
parent d2d7b81fee
commit 87375fc3dd
3 changed files with 101 additions and 95 deletions

View File

@ -177,6 +177,7 @@ module PostgreSQLAdapterExtensions
end
end
if CANVAS_RAILS4_2
# Force things with (approximate) integer representations (Floats,
# BigDecimals, Times, etc.) into those representations. Raise
# ActiveRecord::StatementInvalid for any other non-integer things.
@ -203,6 +204,7 @@ module PostgreSQLAdapterExtensions
super
end
end
end
def extension_installed?(extension)
@extensions ||= {}

View File

@ -1,6 +1,7 @@
require File.expand_path('../spec_helper', File.dirname( __FILE__ ))
module ActiveRecord
if CANVAS_RAILS4_2
module ActiveRecord
module ConnectionAdapters
if defined?(PostgreSQLAdapter)
describe PostgreSQLAdapter do
@ -89,4 +90,5 @@ module ActiveRecord
end
end
end
end
end

View File

@ -242,7 +242,8 @@ module ActiveRecord
describe "union" do
shared_examples_for "query creation" do
it "should include conditions after the union inside of the subquery" do
wheres = base.active.where(id:99).union(User.where(id:1)).where_values
scope = base.active.where(id:99).union(User.where(id:1))
wheres = CANVAS_RAILS4_2 ? scope.where_values : scope.where_clause.send(:predicates)
expect(wheres.count).to eq 1
sql_before_union, sql_after_union = wheres.first.split("UNION ALL")
expect(sql_before_union.include?('"id" = 99')).to be_falsey
@ -250,7 +251,8 @@ module ActiveRecord
end
it "should include conditions prior to the union outside of the subquery" do
wheres = base.active.union(User.where(id:1)).where(id:99).where_values
scope = base.active.union(User.where(id:1)).where(id:99)
wheres = CANVAS_RAILS4_2 ? scope.where_values : scope.where_clause.send(:predicates)
expect(wheres.count).to eq 2
union_where = wheres.detect{|w| w.is_a?(String) && w.include?("UNION ALL")}
expect(union_where.include?('"id" = 99')).to be_falsey