New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db:test:prepare deprecated #2629

Closed
michelboaventura opened this Issue Jul 3, 2014 · 5 comments

Comments

Projects
None yet
3 participants
@michelboaventura

michelboaventura commented Jul 3, 2014

Because db:test:prepare is deprecated (rails/rails#13528), running

bundle exec rake refinery:testing:dummy_app

give me this:

WARNING: db:test:prepare is deprecated. The Rails test helper now maintains your test schema automatically, see the release notes for details.
rake aborted!
ActiveRecord::NoDatabaseError: Unknown database 'dummy_test'Run `$ bin/rake db:create db:migrate` to create your database

To fix it for me, changed the "db:test:prepare" to "RAILS_ENV=test db:setup" on
https://github.com/refinery/refinerycms/blob/master/testing/lib/refinery/tasks/testing.rake#L55

I didn't send a pull request with this because I don't know if this is the best solution. I was reading that rspec-rails runs it automagicaly (rspec/rspec-rails#936), but I think we use a different path on refinery.

What do you think?

@parndt

This comment has been minimized.

Show comment
Hide comment
@parndt

parndt Jul 3, 2014

Member

It is indeed frustrating that the deprecation appears but then without it we get no database. I say we go with system "bundle exec rake -f #{File.join(dummy_app_path, 'Rakefile')} db:{create,migrate}" unless @JonRowe can shed any light on the best way?

Member

parndt commented Jul 3, 2014

It is indeed frustrating that the deprecation appears but then without it we get no database. I say we go with system "bundle exec rake -f #{File.join(dummy_app_path, 'Rakefile')} db:{create,migrate}" unless @JonRowe can shed any light on the best way?

@JonRowe

This comment has been minimized.

Show comment
Hide comment
@JonRowe

JonRowe Jul 3, 2014

You need to add the relevant lines to your spec_helper

If you're running Rails 4.1:

ActiveRecord::Migration.maintain_test_schema!

If you're running Rails 4:

ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

JonRowe commented Jul 3, 2014

You need to add the relevant lines to your spec_helper

If you're running Rails 4.1:

ActiveRecord::Migration.maintain_test_schema!

If you're running Rails 4:

ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
@JonRowe

This comment has been minimized.

Show comment
Hide comment
@JonRowe

JonRowe Jul 3, 2014

That brings you in line with the "Rails" way™

JonRowe commented Jul 3, 2014

That brings you in line with the "Rails" way™

@parndt

This comment has been minimized.

Show comment
Hide comment
@parndt

parndt Jul 3, 2014

Member

@JonRowe I knew it was a good idea to ask you

Member

parndt commented Jul 3, 2014

@JonRowe I knew it was a good idea to ask you

@michelboaventura

This comment has been minimized.

Show comment
Hide comment
@michelboaventura

michelboaventura Jul 4, 2014

The problem is not the deprecation warning itself, is that if I run the command as the docs suggests, I can't test my app because the dummy_test db isn't created.

Even if I put

ActiveRecord::Migration.maintain_test_schema!

on the spec_helper.rb I got the same error, since this code AFAIK just keep the schema in sync with the dev database, but doesn't create the test db.

michelboaventura commented Jul 4, 2014

The problem is not the deprecation warning itself, is that if I run the command as the docs suggests, I can't test my app because the dummy_test db isn't created.

Even if I put

ActiveRecord::Migration.maintain_test_schema!

on the spec_helper.rb I got the same error, since this code AFAIK just keep the schema in sync with the dev database, but doesn't create the test db.

@parndt parndt closed this in 26d514d Jul 28, 2014

ghoppe added a commit to ghoppe/refinerycms that referenced this issue Jul 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment