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.

Tests and model not based on activerecord

#3698

Hello!

I have unit test for controller Players, and in it, I have:

test "encrypting password" do
assert true
end

I also have a model map which isn't based on activerecord ( tableless ), and when I run tests, I get these errors for each test:

  1) Error:
test_encrypting_password(PlayerTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: maps: DELETE FROM "maps" WHERE 1=1
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract_adapter.rb:206:in rescue in log'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract_adapter.rb:196:inlog'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/sqlite_adapter.rb:150:in block in execute'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/sqlite_adapter.rb:390:incatch_schema_changes'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/sqlite_adapter.rb:150:in execute'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract/database_statements.rb:226:inupdate_sql'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/sqlite_adapter.rb:154:in update_sql'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract/database_statements.rb:231:indelete_sql'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/sqlite_adapter.rb:160:in delete_sql'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract/database_statements.rb:54:indelete'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract/query_cache.rb:25:in delete_with_query_dirty'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:549:indelete_existing_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:511:in block (4 levels) in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:511:ineach'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:511:in block (3 levels) in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract/database_statements.rb:136:intransaction'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:510:in block (2 levels) in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/connection_adapters/abstract_adapter.rb:107:indisable_referential_integrity'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:501:in block in create_fixtures'
/var/lib/gems/1.9.1/gems/activesupport-3.0.pre/lib/active_support/benchmarkable.rb:55:insilence'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:500:in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:961:inload_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.0.pre/lib/active_record/fixtures.rb:926:in setup_fixtures'
/var/lib/gems/1.9.1/gems/activesupport-3.0.pre/lib/active_support/callbacks.rb:428:in_run_setup_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.0.pre/lib/active_support/testing/setup_and_teardown.rb:31:in run'</code>
</pre>


It seems after test, it's trying to delete everything from each model table, but seems it isn't checking if it's based on activerecord...
Tnx in advance!

Reported by Matija Folnovic · January 15th, 2010 @ 04:35 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Mark Foster
    Mark Foster

    I suspect you are getting this because in test_helper.rb you have the fixtures setting:

    fixtures :all

    Comment that out and specify individual fixtures for your AR models and your error should go away.

    April 12th, 2010 @ 10:07 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid

    I'm closing this ticket as Mark's advice seems spot on. If the issue still exists, feel free to make a comment asking for ticket to be re-opened and I'll do it.

    June 15th, 2010 @ 02:01 PM