shrinerb / shrine

File Attachment toolkit for Ruby applications

Home Page:https://shrinerb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails some tests on Rails 6.1.0.rc1

jrochkind opened this issue · comments

Rails 6.1.0.rc1 is out, and I wanted to verify that shrine passed it's AR-related tests with it.

Unfortunately, they do not, although it looks like just a test setup issue.

To test, I just manually edited the shrine.gemspec in a locally checked out copy of shrine, to say:

gem.add_development_dependency "activerecord", RUBY_VERSION >= "2.5" ? ">= 6.1.0.rc1" : "~> 5.2"

And then ran bundle update, bundle exec rake. And these are the errors:

  1) Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0001_handles json type:
FrozenError: can't modify frozen ActiveRecord::ConnectionAdapters::SqlTypeMetadata
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:284:in `instance_variable_set'
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:284:in `block (4 levels) in <top (required)>'

Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0001_handles json type:
FrozenError: can't modify frozen ActiveRecord::ConnectionAdapters::SqlTypeMetadata
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:279:in `instance_variable_set'
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:279:in `block (4 levels) in <top (required)>'

  2) Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0002_handles jsonb type:
FrozenError: can't modify frozen ActiveRecord::ConnectionAdapters::SqlTypeMetadata
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:298:in `instance_variable_set'
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:298:in `block (4 levels) in <top (required)>'

Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0002_handles jsonb type:
FrozenError: can't modify frozen ActiveRecord::ConnectionAdapters::SqlTypeMetadata
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:279:in `instance_variable_set'
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:279:in `block (4 levels) in <top (required)>'

Actually kind of looks like just one error, which may very well just be a test setup error?

Looks like the test setup is trying to modify something that is now frozen... I don't totally have my head wrapped around what it's doing, or how to refactor the test to set up what it needs without doing it like that.

.instance_variable_set(:@type, :text) # revert schema change

There are a few more of those .instance_variable_set that are going to be a problem.

We'd have to fix that, to then see if the tests actually all pass on rails 6.1.0, which they very well may.

@jrochkind Thanks for the info 👍 I've just pushed some changes that work around the new frozen state, let me know if the test suite now passes on the release candidate.

Thanks @janko !

On master at c4b0e91, we move to a different set of similar errors:

  1) Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0002_handles jsonb type:
FrozenError: can't modify frozen Hash
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:295:in `block (4 levels) in <top (required)>'

  2) Error:
Shrine::Plugins::Activerecord::Attacher::JSON columns#test_0001_handles json type:
FrozenError: can't modify frozen Hash
    /Users/jrochkind/code/shrine/test/plugin/activerecord_test.rb:280:in `block (4 levels) in <top (required)>'

You can of course run tests yourself as you go, although I'm happy to be your interactive test runner for you if you like! We could also add an ENV variable for rails version to let people run tests against different versions of rails, instead of hard-coding it.

Ok, thanks for the update, I will take a better look into it tomorrow.