ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

unit/user_test.rb:138 fails with mysql2 gem (Bug #171)


Added by Gregor Schmidt at 2011-02-10 05:45 pm. Updated at 2011-02-15 08:16 am.


Status:Closed Start date:2011-02-10
Priority:Normal Due date:
Assignee:Eric Davis % Done:

0%

Category:Testing
Target version:1.1.0 — Bell
Remote issue URL: Affected version:

Description

I'm seeing the following error when running rake test:units

  1) Failure:
test: User#try_to_login should select the exact matching user first. (UserTest)
    [/test/unit/user_test.rb:145:in `__bind_1297359790_531508'
     shoulda (2.10.3) lib/shoulda/context.rb:362:in `call'
     shoulda (2.10.3) lib/shoulda/context.rb:362:in `test: User#try_to_login should select the exact matching user first. ']:
<"ADMIN"> expected but was
<"admin">.

History

Updated by Gregor Schmidt at 2011-02-10 05:52 pm

  • Status changed from Open to Ready for review

Updated by Felix Schäfer at 2011-02-12 03:16 pm

Looks fine to me. Any naysayers?

Updated by Eric Davis at 2011-02-14 01:13 am

I'll check it out right now. Still getting my test env all setup.

  • Assignee set to Eric Davis

Updated by Eric Davis at 2011-02-14 01:48 am

How did you set this up? mysql2 won't even run the unit test suite.

$ r test:units --trace
(in /home/edavis/dev/chiliproject/core)
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
rake aborted!
Task not supported by 'mysql2'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:384
  • Category changed from User accounts to Testing
  • Status changed from Ready for review to Needs more information

Updated by Holger Just at 2011-02-14 08:46 am

mysql2 doesn't support all of the rake tasks by default. Gregor compiled a simple Rails plugin to fix this and add all those rake tasks to mysql too. See https://github.com/finnlabs/mysql2_for_rails_2_3_5.

  • Status changed from Needs more information to Open

Updated by Gregor Schmidt at 2011-02-14 08:58 am

Thanks for taking the time and looking into it.

Unfortunately, the mysql2 gem is not yet fully supported in Rails 2.3.5. This is caused by the database rake tasks being to restrictive when testing for MySQL (#5592 in Rails' Lighthouse). This should be fixed with Rails 2.3.10.

When using mysql2 in production, this is not an issue, since the db:migrate task works fine and that's the only task, you might want to run on a production system. On the other hand mysql2 is actively maintained and claims to be a faster option.

There are 2 options to reproduce the error within the test suite.

1. Run RAILS_ENV=test db:migrate to migrate the test db and execute the test file in isolation, therefore avoiding the breaking rake tasks: ruby -Itest:lib test/unit/user_test.rb

2. Install the mysql2_for_rails_2_3_5 Rails plugin. It includes all the necessary fixes, back ported to Rails 2.3.5 using monkey patching. When this plugin is installed, everything should work the same way as with the mysql gem.

Let me know, if I can help out further.

FYI: The continuous integration currently running at ci.nach-vorne.eu uses the second approach. I will write something up on how to get everything running and all open bug reports on other projects.

  • Status changed from Open to Ready for review

Updated by Eric Davis at 2011-02-14 11:45 pm

Gregor Schmidt:

After installing the plugin the tests started working with mysql2. I've reviewed your patch and merged it into master.

Thanks for the patches.

  • Status changed from Ready for review to Closed

Updated by Gregor Schmidt at 2011-02-15 08:16 am

Thanks for taking the time.

Also available in: Atom PDF