Forum: Ruby on Rails New problems with ActiveRecord tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Francesca T. (Guest)
on 2009-06-09 14:25
I tried to use ActiveRecord 2.3.2, opened ad as a Ruby project with
existing source, to run its tests and they worked but with this
following errors:

Finished in 71.143069 seconds.

  1) Failure:
test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas(AdapterTest)
    [test/cases/adapter_test.rb:129:in
`test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<" LIMIT 1,7"> expected but was
<" LIMIT 1, 7 procedure help()">.

  2) Failure:
test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas(AdapterTest)
    [test/cases/adapter_test.rb:115:in
`test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<" LIMIT 1"> expected but was
<" LIMIT 1 select * from schema">.

  3) Failure:
test_read_attributes_before_type_cast_on_datetime(BasicsTest)
    [test/cases/base_test.rb:148:in
`test_read_attributes_before_type_cast_on_datetime'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<"2009-06-09 09:29:03"> expected but was
<"2009-06-09 09:29:03.0">.

  4) Failure:
test_update_all_with_order_and_limit_updates_subset_only(BasicsTest)
    [test/cases/base_test.rb:693:in
`test_update_all_with_order_and_limit_updates_subset_only'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
Exception raised:
Class: <ActiveRecord::StatementInvalid>
Message: <"ActiveRecord::ActiveRecordError: This version of MySQL
doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery': UPDATE `posts`
SET body = 'bulk update!' WHERE `id` IN (SELECT `id` FROM `posts` WHERE
(`posts`.author_id = 1)  ORDER BY posts.id LIMIT 1)">
---Backtrace---
./test/cases/../../lib/active_record/connection_adapters/abstract_adapter.rb:212:in
`log'
/home/ffrancy/.gem/jruby/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:563:in
`execute'
./test/cases/helper.rb:37:in `execute_with_query_record'
/home/ffrancy/.gem/jruby/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:582:in
`jdbc_update'
./test/cases/../../lib/active_record/connection_adapters/abstract/query_cache.rb:25:in
`update_with_query_dirty'
./test/cases/../../lib/active_record/base.rb:852:in `update_all'
./test/cases/../../lib/active_record/associations/association_collection.rb:375:in
`method_missing'
./test/cases/../../lib/active_record/base.rb:2148:in `with_scope'
./test/cases/../../lib/active_record/associations/association_proxy.rb:206:in
`with_scope'
./test/cases/../../lib/active_record/associations/association_collection.rb:371:in
`method_missing'
test/cases/base_test.rb:696:in
`test_update_all_with_order_and_limit_updates_subset_only'
test/cases/base_test.rb:693:in
`test_update_all_with_order_and_limit_updates_subset_only'
./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run'
---------------

  5) Failure:
test_integer_creates_integer_column(ChangeTableMigrationsTest)
    [(eval):16:in `integer'
     (eval):5:in `each'
     (eval):5:in `integer'
     test/cases/migration_test.rb:1399:in
`test_integer_creates_integer_column'
     test/cases/migration_test.rb:1491:in `with_change_table'
     ./test/cases/../../lib/active_record/connection_adapters/abstract/schema_statements.rb:175:in
`change_table'
     test/cases/migration_test.rb:1490:in `with_change_table'
     test/cases/migration_test.rb:1396:in
`test_integer_creates_integer_column'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
unexpected invocation:
#<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x18b8>.add_column(:delete_me,
:foo, 'integer(10)', {})
unsatisfied expectations:
- expected exactly once, not yet invoked:
#<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x18b8>.add_column(:delete_me,
:bar, 'integer', {})
- expected exactly once, not yet invoked:
#<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x18b8>.add_column(:delete_me,
:foo, 'integer', {})

  6) Error:
test_create_table_with_defaults(MigrationTest):
ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError:
BLOB/TEXT column 'five' can't have a default value: CREATE TABLE
`testings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `one`
varchar(255) DEFAULT 'hello', `two` tinyint(1) DEFAULT 1, `three`
tinyint(1) DEFAULT 0, `four` integer(10) DEFAULT 1, `five` text DEFAULT
'hello') ENGINE=InnoDB CHARACTER SET `utf8`
    ./test/cases/../../lib/active_record/connection_adapters/abstract_adapter.rb:212:in
`log'
    /home/ffrancy/.gem/jruby/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:563:in
`execute'
    ./test/cases/helper.rb:37:in `execute_with_query_record'
    ./test/cases/../../lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in
`create_table'
    /home/ffrancy/.gem/jruby/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_mysql.rb:171:in
`create_table'
    test/cases/migration_test.rb:149:in
`test_create_table_with_defaults'
    ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run'

  7) Failure:
test_keeping_default_and_notnull_constaint_on_change(MigrationTest)
    [test/cases/migration_test.rb:775:in
`test_keeping_default_and_notnull_constaint_on_change'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> expected but was
<true>.

  8) Failure:
test_rename_column_preserves_default_value_not_null(MigrationTest)
    [test/cases/migration_test.rb:556:in
`test_rename_column_preserves_default_value_not_null'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<70000> expected but was
<nil>.

  9) Failure:
test_rename_nonexistent_column(MigrationTest)
    [test/cases/migration_test.rb:572:in
`test_rename_nonexistent_column'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<ActiveRecord::ActiveRecordError> exception expected but was
Class: <NoMethodError>
Message: <"undefined method `[]' for nil:NilClass">
---Backtrace---
/home/ffrancy/.gem/jruby/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_mysql.rb:200:in
`rename_column'
test/cases/migration_test.rb:573:in `test_rename_nonexistent_column'
test/cases/migration_test.rb:572:in `test_rename_nonexistent_column'
./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run'
---------------

 10) Failure:
test_count_queries_with_cache(QueryCacheTest)
    [./test/cases/../../lib/active_record/test_case.rb:31:in
`assert_queries'
     test/cases/query_cache_test.rb:25:in
`test_count_queries_with_cache'
     ./test/cases/../../lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
     ./test/cases/../../lib/active_record/query_cache.rb:9:in `cache'
     test/cases/query_cache_test.rb:24:in
`test_count_queries_with_cache'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
2 instead of 1 queries were executed.
Queries:
SELECT count(*) AS count_all FROM `tasks`
SELECT count(*) AS count_all FROM `tasks` .
<1> expected but was
<2>.

 11) Failure:
test_schema_dump_includes_limit_constraint_for_integer_columns(SchemaDumperTest)
    [test/cases/schema_dumper_test.rb:113:in
`test_schema_dump_includes_limit_constraint_for_integer_columns'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<"# This file is auto-generated from the current state of the database.
Instead of editing this file, \n# please use the migrations feature of
Active Record to incrementally modify your database, and\n# then
regenerate this schema definition.\n#\n# Note that this schema.rb
definition is the authoritative source for your database schema. If you
need\n# to create the application database on another system, you should
be using db:schema:load, not running\n# all the migrations from scratch.
The latter is a flawed and unsustainable approach (the more
migrations\n# you'll amass, the slower it'll run and the greater
likelihood for issues).\n#\n# It's strongly recommended to check this
file into your version control
system.\n\nActiveRecord::Schema.define(:version => 0) do\n\n
create_table \"integer_limits\", :force => true do |t|\n    t.integer
\"c_int_without_limit\"\n    t.integer \"c_int_1\",             :limit
=> 1\n    t.integer \"c_int_2\",             :limit => 2\n    t.integer
\"c_int_3\",             :limit => 3\n    t.integer \"c_int_4\",
:limit => 4\n    t.integer \"c_int_5\",             :limit => 5\n
t.integer \"c_int_6\",             :limit => 6\n    t.integer
\"c_int_7\",             :limit => 7\n    t.integer \"c_int_8\",
:limit => 8\n  end\n\nend\n"> expected to be =~
</c_int_5.*:limit => 8/>.

 12) Failure:
test_underlying_adapter_no_longer_active(TestUnconnectedAdapter)
    [test/cases/unconnected_test.rb:30:in
`test_underlying_adapter_no_longer_active'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
Removed adapter should no longer be active.
<false> is not true.

 13) Failure:
test_optionally_validates_length_of_using_within_on_create_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1074:in
`test_optionally_validates_length_of_using_within_on_create_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1065:in
`test_optionally_validates_length_of_using_within_on_create_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> is not true.

 14) Failure:
test_optionally_validates_length_of_using_within_on_update_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1092:in
`test_optionally_validates_length_of_using_within_on_update_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1088:in
`test_optionally_validates_length_of_using_within_on_update_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> is not true.

 15) Failure:
test_optionally_validates_length_of_using_within_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1054:in
`test_optionally_validates_length_of_using_within_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1050:in
`test_optionally_validates_length_of_using_within_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
#<ActiveRecord::Errors:0x512bcf @errors={"title"=>["is too long (maximum
is 5 characters)"]}, @base=#<Topic id: nil, title: "一二三四五", 
author_name:
nil, author_email_address: "removed_email_address@domain.invalid", written_on: 
nil, bonus_time:
nil, last_read: nil, content: nil, approved: true, replies_count: 0,
parent_id: nil, type: nil>>.
<false> is not true.

 16) Failure:
test_validate_case_sensitive_uniqueness(ValidationsTest)
    [test/cases/validations_test.rb:485:in
`test_validate_case_sensitive_uniqueness'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
Should be valid.
<false> is not true.

 17) Failure:
test_validates_length_of_using_is_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1114:in
`test_validates_length_of_using_is_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1110:in
`test_validates_length_of_using_is_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> is not true.

 18) Failure:
test_validates_length_of_using_maximum_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1026:in
`test_validates_length_of_using_maximum_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1022:in
`test_validates_length_of_using_maximum_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> is not true.

 19) Failure:
test_validates_length_of_using_minimum_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1015:in
`test_validates_length_of_using_minimum_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1008:in
`test_validates_length_of_using_minimum_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<false> is not true.

 20) Failure:
test_validates_length_of_using_within_utf8(ValidationsTest)
    [test/cases/validations_test.rb:1041:in
`test_validates_length_of_using_within_utf8'
     ./test/cases/../../lib/active_record/test_case.rb:57:in
`with_kcode'
     test/cases/validations_test.rb:1036:in
`test_validates_length_of_using_within_utf8'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in
`run']:
<"is too short (minimum is 3 characters)"> expected but was
<"is too long (maximum is 5 characters)">.

2013 tests, 6503 assertions, 19 failures, 1 errors
rake aborted!
Command failed with status (1): [/opt/jruby/bin/jruby
-Ilib:test:test/conne...]


I have to say that I'm using JRuby 1.6, Glassfish V 3 Prelude, Rails
2.2.2 and NetBeans IDE.

How can I make everything work?
Do I have to upgrade something?

And also, if I have to use rails 2.3.2, how can I make it work with
glassfish?

Thanks a lot!!!
This topic is locked and can not be replied to.