pat / combustion

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

Getting a NameError on `ActiveRecord` for project not initialising activerecord #118

Closed jornvandebeek closed 2 years ago

jornvandebeek commented 2 years ago

For projects that do not require ActiveRecord, the ActiveRecord constant is not loaded, which causes the new rails 7 handling to crash.

Failure/Error: Combustion.initialize! :action_controller, :action_view, :sprockets

NameError:
  uninitialized constant Combustion::Configurations::ActiveRecord::ActiveRecord
# gems/combustion-1.3.2/lib/combustion/configurations/active_record.rb:5:in `call'

https://github.com/pat/combustion/commit/4fbea4120070be85a88a9f88d3725da44f6d0cdd#diff-59be8c6951e39e4f546dc687875846547c2fc847be8ab89fe945d01b0640969aR5

As for the fix. I guess using Rails.version instead would be the correct way to do it? Alternatively, I am unsure why the combustion activerecord configuration is loaded when it is not specified for initialization, so skipping it altogether might be an option?

pat commented 2 years ago

I've just pushed a fix (though the commit was a little too eager on autoclosing the issue 😅) - if you could confirm it's all fine via the git repo for your project, that'd be great, and I'll get a release out soon.

gem "combustion",
  git: "https://github.com/pat/combustion.git",
  branch: "main"
brettfishman commented 2 years ago

@pat this did the trick for us - thanks for the quick fix!

pat commented 2 years ago

Appreciate the confirmation @brettfishman - I've just released v1.3.3 with this fix :)

jornvandebeek commented 2 years ago

I can also confirm 1.3.3 works to fix the issue. Thank you for the prompt resolution!