pat / combustion

Simple, elegant testing for Rails Engines
MIT License
708 stars 51 forks source link

Compatibility with Rails 3.2 #14

Closed fschwahn closed 12 years ago

fschwahn commented 12 years ago

Hi, I just stumbled upon a problem while testing an activerecord extension. The tests pass when the bundle is locked to Rails 3.1, but when the bundle is updated to Rails 3.2 the tests start to fail. However, the extension works normal in a Rails 3.2 app, the tests just fail in the combustion app. It seems as if the extension just isn't loaded anymore. I will push the extension to github later today, so you can take a look if you like.

Best regards, Fabian

fschwahn commented 12 years ago

Ok, so here's the repo: https://github.com/fschwahn/activerecord-postgres-array

To run the specs you need postgres. I fixed the rails version in the Gemfile, if you set it to 3.2.0 the tests are failing. However, as I mentioned I tested it with a rails 3.2.0 application and the extension works as expected. So I suspect there's a problem with combustion.

pat commented 12 years ago

Thanks for the repo to play with - it looks like your library's being loaded before some of ActiveRecord's underlying classes (at least, in the tests with 3.2) - so the array column isn't treated as an array.

I'll try to figure out a change for either Combustion or your code to fix this.

pat commented 12 years ago

Maybe it's not perfect, but adding the following line inside your on_load hook (before your existing require) did the trick:

require 'active_record/connection_adapters/postgresql_adapter'

On one level, it's good to make sure the classes you're modifying are already loaded. Though it'd be great if we could make sure that was reliably always the case.

fschwahn commented 12 years ago

Thanks a lot for your help! That missing require was an error on my part, but maybe it makes still sense to mention it somewhere? It seems that combustion has a slightly different order than usual.