Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rake test task looks at wrong database

#1599

The test tasks (test:units, test:functionals, etc.) attempt to access the development DB by default. The problem is in db:test:prepare, which calls db:abort_if_pending_migrations without setting RAILS_ENV.

Is this behavior desired and/or still needed? Typically, I would expect that testing tasks could run without the other databases present...

Reported by Matt Jones · December 18th, 2008 @ 07:14 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik

    "I would expect that testing tasks could run without the other databases present..."

    Me too.

    December 19th, 2008 @ 02:08 PM

  2. andyjeffries
    andyjeffries
    • Tag changed from 2.2, db, rake, testing to 2.2, db, patch, rake, testing

    I'm very new to Rails development, but I've had a quick play with this locally and it seems as simple as a one-line patch.

    Can someone test it out and let me know if this works.

    Also, I couldn't find any tests for Rake tasks so I'm not aware of where to put a test to prove this works (I'm new to testing Rake tasks).

    February 25th, 2009 @ 01:12 PM

  3. Michael Koziarski
    Michael Koziarski

    db:test:prepare will copy the values over from development to test after running those migrations though. So if there are pending migrations in development you'll get the wrong behaviour.

    March 2nd, 2009 @ 05:25 AM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.2, db, patch, rake, testing to 2.2, bugmash, db, patch, rake, testing

    August 5th, 2009 @ 02:17 PM

  5. Nick Quaranto
    Nick Quaranto
    1. This seems like a strange use case, I can see it maybe for CI servers and the like, but it doesn't seem helpful enough for normal development.

    August 8th, 2009 @ 08:25 PM

  6. Nick Quaranto
    Nick Quaranto

    That was a minus 1. Seems like LH likes to eat my formatting.

    August 8th, 2009 @ 08:26 PM

  7. Dan Pickett
    Dan Pickett

    -1 on this as well - I think this is something that we might want to address in 3, but I don't identify it as critical to 2.x - in the use case of CI, I just create the dev database so prepare will run successfully

    August 8th, 2009 @ 10:10 PM

  8. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to wontfix
    • Tag changed from 2.2, bugmash, db, patch, rake, testing to 2.2, db, patch, rake, testing

    No one has come up with a good workaround for the issue Koz raised. We can reopen if someone has a brainstorm.

    August 10th, 2009 @ 02:54 AM