spec/database_spec.rb in apartment-0.18.0 vs spec/database_spec.rb in apartment-0.19.0
- old
+ new
@@ -53,11 +53,11 @@
let(:config){ Apartment::Test.config['connections']['postgresql'].symbolize_keys }
let(:database){ Apartment::Test.next_db }
let(:database2){ Apartment::Test.next_db }
before do
- Apartment.use_postgres_schemas = true
+ Apartment.use_schemas = true
ActiveRecord::Base.establish_connection config
Apartment::Test.load_schema # load the Rails schema in the public db schema
subject.stub(:config).and_return config # Use postgresql database config for this test
end
@@ -77,17 +77,27 @@
expect {
Apartment::Database.adapter
}.to raise_error
end
+ context "threadsafety" do
+ before { subject.create database }
+
+ it 'has a threadsafe adapter' do
+ subject.switch(database)
+ thread = Thread.new { subject.current_database.should == Apartment.default_schema }
+ thread.join
+ subject.current_database.should == database
+ end
+ end
end
context "with schemas" do
before do
Apartment.configure do |config|
config.excluded_models = []
- config.use_postgres_schemas = true
+ config.use_schemas = true
config.seed_after_create = true
end
subject.create database
end