diff options
| author | Luc Donnet | 2015-02-04 16:51:03 +0100 |
|---|---|---|
| committer | Luc Donnet | 2015-02-04 16:51:03 +0100 |
| commit | 26374d80faaff8f792acceabac9add63ade1dfeb (patch) | |
| tree | 9ee735714f098206e775c246ca42c99ffb7c7445 /spec/support/referential.rb | |
| parent | a5ae05b150514fbec95658d11213c7c06a156dcc (diff) | |
| download | chouette-core-26374d80faaff8f792acceabac9add63ade1dfeb.tar.bz2 | |
Try to fix travis to support apartment for spec
Diffstat (limited to 'spec/support/referential.rb')
| -rw-r--r-- | spec/support/referential.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/support/referential.rb b/spec/support/referential.rb index c1a043b8f..7704d8510 100644 --- a/spec/support/referential.rb +++ b/spec/support/referential.rb @@ -1,7 +1,7 @@ module ReferentialHelper def first_referential - Organisation.find_by_name("first").referentials.find_by_slug("first") + Referential.where(:slug => "first").take! end def self.included(base) @@ -27,21 +27,33 @@ RSpec.configure do |config| config.include ReferentialHelper config.before(:suite) do + # 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 + organisation = Organisation.create!(:name => "first") + Referential.create!(:prefix => "first", :name => "first", :slug => "first", :organisation => organisation) end config.before(:each) do + # Start transaction for this test + DatabaseCleaner.start # Switch into the default tenant first_referential.switch end + config.before(:each, :js => true) do + DatabaseCleaner.strategy = :truncation + end + config.after(:each) do # Reset tenant back to `public` Apartment::Tenant.reset + # Rollback transaction + DatabaseCleaner.clean end end |
