flippercloud / flipper

🐬 Beautiful, performant feature flags for Ruby.
https://www.flippercloud.io/docs
MIT License
3.66k stars 411 forks source link

Maintain Rails 4.2 compatibility #863

Open astupka opened 4 months ago

astupka commented 4 months ago

This PR patches the active record adapter to work with 4.2. The two issues were originally noticed by @clinejj

https://github.com/flippercloud/flipper/issues/857 https://github.com/flippercloud/flipper/issues/858

Getting errors with some tests needing sqllite 1.4.4 though:

Update: Need to fix tests in rails 5.2, 6, and 6.1. Appears to be a setup issue since Rails::VERSION::MAJOR is definitely still defined in Rails 6.

Loading staging environment (Rails 6.0.0)
irb(main):001:0> Rails::VERSION::MAJOR
=> 6
SQLITE3_VERSION='2.0.1' bundle exec rake

Failures:

  1) Flipper::Model::ActiveRecord flipper_id returns class name and id
     Failure/Error: ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

     LoadError:
       Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     # ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Gem::LoadError:
     #   can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     #   ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'

  2) Flipper::Model::ActiveRecord flipper_id uses base class name
     Failure/Error: ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

     LoadError:
       Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     # ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Gem::LoadError:
     #   can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     #   ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'

  3) Flipper::Model::ActiveRecord flipper_properties includes all attributes
     Failure/Error: ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')

     LoadError:
       Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     # ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Gem::LoadError:
     #   can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-x86_64-darwin. Make sure all dependencies are added to Gemfile.
     #   ./spec/flipper/model/active_record_spec.rb:9:in `block (2 levels) in <top (required)>'

Finished in 30.49 seconds (files took 5.89 seconds to load)
2622 examples, 3 failures, 131 pending
severin commented 3 weeks ago

@astupka are you still working on this? Otherwise I'm happy to give it a shot!