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.

Unit test fails when using non-standard table names

#4263

Using set_table_name to set a custom table name causes unit tests to fail:

1) Error: test_myotherclass(MyotherclassTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: myrecords: DELETE FROM "myrecords" WHERE 1=1

Of course there is no such table, since I did a “set_table_name 'my_fancy_tablename'” in class Myrecord.

This error has been reported in tickets #389 Incorrect table_name evaluation in tests when using legacy database and #307 FixtureClassNotFound when using Namespaces in Unit Test. These tickets have been marked as spam.

The author of ticket #389 Incorrect table_name evaluation in tests when using legacy database writes “patch included”, however I'm unable to view this patch.

#307 FixtureClassNotFound when using Namespaces in Unit Test
#389 Incorrect table_name evaluation in tests when using legacy database

Reported by ohforf · March 24th, 2010 @ 08:52 PM

State: resolved
Milestone: 3.0.2
Assigned to: nobody
Importance: Low

Activity

  1. ohforf
    ohforf
    • Tag changed from activerecord set_table_name test to activerecord fixtures set_table_name set_fixture_class

    You have to explicitly call the undocumented function set_fixture_class in the test helper to make the fixtures work again:
    set_fixture_class :pears => "Fruit::Pear"

    Maybe this should be documented in the set_table_name function.

    March 25th, 2010 @ 04:21 PM

  2. ohforf
    ohforf
    • Tag changed from activerecord fixtures set_table_name set_fixture_class to activerecord set_table_name test
    • Title changed from Unit test fail when using non-standard table names to Unit test fails when using non-standard table names

    March 25th, 2010 @ 04:21 PM

  3. José Valim
    José Valim

    Please provide a patch to update the documentation, thanks.

    March 26th, 2010 @ 12:04 AM

  4. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from new to incomplete
    • Milestone cleared.

    March 27th, 2010 @ 07:38 AM

  5. Yehuda Katz (wycats)
  6. Cesario
    Cesario

    I tried to update the documentation with this patch. Tell me if this is enough.

    April 8th, 2010 @ 05:07 PM

  7. Dan Pickett
    Dan Pickett
    • Tag changed from activerecord set_table_name test to activerecord set_table_name test, bugmash

    May 9th, 2010 @ 06:26 PM

  8. Wijnand Wiersma
    Wijnand Wiersma

    +1 for this documentation fix.

    May 16th, 2010 @ 11:32 AM

  9. Bastes
    Bastes

    No changes with the documentation fix ; already applied ?

    May 16th, 2010 @ 03:04 PM

  10. Bastes
    Bastes

    +1

    Already applied. Close ?

    May 16th, 2010 @ 04:55 PM

  11. Rizwan Reza
    Rizwan Reza
    • Tag changed from activerecord set_table_name test, bugmash to activerecord set_table_name test
    • State changed from incomplete to resolved

    May 16th, 2010 @ 05:09 PM

  12. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM