This project is archived and is in readonly mode.

#3698 ✓invalid
Matija Folnovic

Tests and model not based on activerecord

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

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!

Comments and changes to this ticket

  • Mark Foster

    Mark Foster April 12th, 2010 @ 10:07 PM

    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.

  • Rohit Arondekar

    Rohit Arondekar June 15th, 2010 @ 02:01 PM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages