RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.clean_with(:deletion)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each, :js => true) do
    DatabaseCleaner.strategy = :deletion
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end
end

RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do
    DatabaseCleaner.strategy = :transaction
  end

  config.before(:each, :js => true) do
    DatabaseCleaner.strategy = :truncation
  end

  config.before(:each) do
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end
end

Fix foreign key errors when resetting DB in tests
Fix foreign key errors when resetting DB in tests

Problem

I couldn't get the test suite passing because of foreign key errors when
resetting the DB. For example,

```
Failures:

  1) customer show page links to the customer's orders
     Failure/Error: DatabaseCleaner.clean

     ActiveRecord::InvalidForeignKey:
       PG::ForeignKeyViolation: ERROR:  update o delete en «customers»
       viola la llave foránea «fk_rails_3dad120da9» en la tabla «orders»
       DETAIL:  La llave (id)=(1) todavía es referida desde la tabla
       «orders».  : DELETE FROM "public"."customers";

       (...backtrace ommited...)

Finished in 1.75 seconds (files took 2.03 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/features/show_page_spec.rb:34
```

Solution

Use "truncation" strategy instead of "deletion" for resetting the DB.
