DEV: Add support for Rails 6

Minor fixes to add Rails 6 support to Discourse, we now will boot
with RAILS_MASTER=1, all specs pass

Only one tiny deprecation left

Largest change was the way ActiveModel:Errors changed interface a
bit but there is a simple backwards compat way of working it
This commit is contained in:
Sam Saffron
2019-04-30 16:58:18 +10:00
parent cf235fbd48
commit 1be01f8dd4
31 changed files with 83 additions and 54 deletions

View File

@@ -22,10 +22,10 @@ describe HasCustomFields do
DB.exec("drop table custom_fields_test_items")
DB.exec("drop table custom_fields_test_item_custom_fields")
# import is making my life hard, we need to nuke this out of orbit
des = ActiveSupport::DescendantsTracker.class_variable_get :@@direct_descendants
des[ActiveRecord::Base].delete(CustomFieldsTestItem)
des[ActiveRecord::Base].delete(CustomFieldsTestItemCustomField)
# this weakref in the descendant tracker should clean up the two tests
# if this becomes an issue we can revisit (watch out for erratic tests)
Object.send(:remove_const, :CustomFieldsTestItem)
Object.send(:remove_const, :CustomFieldsTestItemCustomField)
end
it "simple modification of custom fields" do

View File

@@ -21,10 +21,10 @@ describe HasSearchData do
DB.exec("drop table model_items")
DB.exec("drop table model_item_search_data")
# import is making my life hard, we need to nuke this out of orbit
des = ActiveSupport::DescendantsTracker.class_variable_get :@@direct_descendants
des[ActiveRecord::Base].delete(ModelItem)
des[ActiveRecord::Base].delete(ModelItemSearchData)
# this weakref in the descendant tracker should clean up the two tests
# if this becomes an issue we can revisit (watch out for erratic tests)
Object.send(:remove_const, :ModelItem)
Object.send(:remove_const, :ModelItemSearchData)
end
let(:item) do

View File

@@ -20,9 +20,9 @@ describe Positionable do
after do
DB.exec("drop table test_items")
# import is making my life hard, we need to nuke this out of orbit
des = ActiveSupport::DescendantsTracker.class_variable_get :@@direct_descendants
des[ActiveRecord::Base].delete(TestItem)
# this weakref in the descendant tracker should clean up the two tests
# if this becomes an issue we can revisit (watch out for erratic tests)
Object.send(:remove_const, :TestItem)
end
it "can position stuff correctly" do

View File

@@ -22,10 +22,10 @@ describe Searchable do
DB.exec("drop table searchable_records")
DB.exec("drop table searchable_record_search_data")
# import is making my life hard, we need to nuke this out of orbit
des = ActiveSupport::DescendantsTracker.class_variable_get :@@direct_descendants
des[ActiveRecord::Base].delete(SearchableRecord)
des[ActiveRecord::Base].delete(SearchableRecordSearchData)
# this weakref in the descendant tracker should clean up the two tests
# if this becomes an issue we can revisit (watch out for erratic tests)
Object.send(:remove_const, :SearchableRecord)
Object.send(:remove_const, :SearchableRecordSearchData)
end
let(:item) { SearchableRecord.create! }

View File

@@ -227,7 +227,7 @@ describe Validators::PostValidator do
it "should add an error" do
validator.unique_post_validator(new_post)
expect(new_post.errors.keys).to contain_exactly(:raw)
expect(new_post.errors.to_hash.keys).to contain_exactly(:raw)
end
it "should not add an error if post.skip_unique_check is true" do