rails 4.2: fix simply_verioned_spec
prevents Woozel from breaking sharding setup refs #CNVS-26056 Change-Id: Iecc28589336e21c416df90e0a9cd7a2d3624b6f5 Reviewed-on: https://gerrit.instructure.com/71132 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
ab0f9be30c
commit
56e555543a
|
@ -1,19 +1,23 @@
|
|||
require File.expand_path(File.dirname(__FILE__)+'/../../../../spec/apis/api_spec_helper')
|
||||
|
||||
class Woozel < ActiveRecord::Base
|
||||
simply_versioned :explicit => true
|
||||
end
|
||||
|
||||
Woozel.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
||||
|
||||
describe 'simply_versioned' do
|
||||
before do
|
||||
before :all do
|
||||
class Woozel < ActiveRecord::Base
|
||||
simply_versioned :explicit => true
|
||||
end
|
||||
Woozel.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
||||
|
||||
Woozel.connection.create_table :woozels, :force => true do |t|
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
after do
|
||||
|
||||
after :all do
|
||||
Woozel.connection.drop_table :woozels
|
||||
Woozel.remove_connection
|
||||
ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants)[ActiveRecord::Base].delete(Woozel)
|
||||
Object.send(:remove_const, :Woozel)
|
||||
GC.start
|
||||
end
|
||||
|
||||
describe "explicit versions" do
|
||||
|
@ -136,6 +140,11 @@ describe 'simply_versioned' do
|
|||
woozel.simply_versioned_options[:on_load] = on_load
|
||||
woozel.reload
|
||||
end
|
||||
|
||||
after do
|
||||
woozel.simply_versioned_options[:on_load] = nil
|
||||
end
|
||||
|
||||
it "can modify a version after loading" do
|
||||
expect(YAML::load(woozel.current_version.yaml)['name']).to eq 'test'
|
||||
expect(woozel.current_version.model.name).to eq 'test override'
|
||||
|
|
|
@ -50,7 +50,6 @@ describe 'Models' do
|
|||
ignore_classes << CustomField if Object.const_defined?('CustomField')
|
||||
ignore_classes << CustomFieldValue if Object.const_defined?('CustomFieldValue')
|
||||
ignore_classes << RemoveQuizDataIds::QuizQuestion if Object.const_defined?('RemoveQuizDataIds::QuizQuestion')
|
||||
ignore_classes << Woozel if Object.const_defined?('Woozel')
|
||||
ActiveRecord::Base.all_models.each do |subclass|
|
||||
next unless subclass.name # unnamed class, probably from specs
|
||||
expect(subclass).to protect_attributes unless ignore_classes.include?(subclass)
|
||||
|
|
Loading…
Reference in New Issue