diff options
| author | Luc Donnet | 2015-01-05 14:56:12 +0100 |
|---|---|---|
| committer | Luc Donnet | 2015-01-05 14:56:12 +0100 |
| commit | 3bc6d313bebdc1f03e4021aabbc774a0cd97d938 (patch) | |
| tree | ac5b8c6d8309012136606d9fd9b9a00290f486a8 /spec/support/referential.rb | |
| parent | e632a4634b1762f4c73d11f1e5b127de9832a1ff (diff) | |
| download | chouette-core-3bc6d313bebdc1f03e4021aabbc774a0cd97d938.tar.bz2 | |
Initialize rails 4 migration
Diffstat (limited to 'spec/support/referential.rb')
| -rw-r--r-- | spec/support/referential.rb | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/spec/support/referential.rb b/spec/support/referential.rb index 28f3799ec..d20b68ee6 100644 --- a/spec/support/referential.rb +++ b/spec/support/referential.rb @@ -27,15 +27,29 @@ RSpec.configure do |config| config.include ReferentialHelper config.before(:suite) do - organisation = Organisation.find_or_create_by_name :name => "first" - organisation.referentials.find_by_slug("first" ) || - Referential.create(:prefix => "first", :name => "first", :slug => "first", :organisation => organisation) - # FIXME in Rails 3.2 : - # Referential.where(:slug => 'first').first_or_create(FactoryGirl.attributes_for(:referential)) + # Clean all tables to start + DatabaseCleaner.clean_with :truncation + # Use transactions for tests + DatabaseCleaner.strategy = :transaction + # Truncating doesn't drop schemas, ensure we're clean here, first *may not* exist + Apartment::Tenant.drop('first') rescue nil + # Create the default tenant for our tests + organisation = Organisation.where(:name => "first").first_or_create + Referential.where(:prefix => "first", :name => "first", :slug => "first", :organisation => organisation).first_or_create end config.before(:each) do + # Start transaction for this test + #DatabaseCleaner.start + # Switch into the default tenant first_referential.switch end + config.after(:each) do + # Reset tenant back to `public` + Apartment::Tenant.reset + # Rollback transaction + DatabaseCleaner.clean + end + end |
