Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning while testing specs on postgres: there is no transaction in progress

For each step of test occurs 2 lines:

WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress

With Spork lines following triples:

NOTICE:  there is no transaction in progress
NOTICE:  there is no transaction in progress
NOTICE:  there is no transaction in progress
WARNING:  there is already a transaction in progress
WARNING:  there is already a transaction in progress
WARNING:  there is already a transaction in progress

I don't know maybe it's important, just warned. GemFile:

group :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'spork-rails'
  gem 'capybara'
  gem 'database_cleaner'
end

all customized, so there is no need for develop group, and it not helps anyway. this is spec_helper.I found, that it is PostgreSQL feature, but I could not find how to fix it. I will be grateful for the assistance

like image 649
zishe Avatar asked Sep 18 '12 17:09

zishe


1 Answers

In spec_helper.rb

config.use_transactional_examples = false #factoryGirl
config.use_transactional_fixtures = false #fixtures

config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with(:truncation)
  end

In database.yml

test:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: myapp_test
  username: my_username
  password:
  allow_concurrency: true
  pool: 5
  min_messages: error

Even if you have set the min_messages option, you may still see console output like the following:

WARNING:  there is already a transaction in progress

Edit the file

/opt/local/var/db/postgresql92/defaultdb/postgresql.conf

and set the following:

client_min_messages = error

Everything should now be running smoothly.

like image 152
Andreas Lyngstad Avatar answered Nov 15 '22 23:11

Andreas Lyngstad