Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ActionView::PathSet immutability and strict type casting in Rails 7.1 #2631

Merged
merged 2 commits into from Oct 28, 2022

Conversation

eugeneius
Copy link
Contributor

Since rails/rails#45957, ActionView::PathSet is immutable, and only accepts subclasses of ActionView::Resolver. This necessitates changes to how RSpec Rails decorates resolvers to return blank templates when render_views? is false.

These changes fix the test suite when running against the Rails main branch:
https://github.com/rspec/rspec-rails/actions/runs/3340449858/jobs/5530555101

Co-authored by @ilianah 馃崘

eugeneius and others added 2 commits October 28, 2022 09:54
Follows
rails/rails@0371317.

ActionView::PathSet no longer responds to unshift or push. We could copy
the new implementation, but we've chosen to delegate to it instead.

Co-authored-by: Iliana Hadzhiatanasova <me@iliana.dev>
Follows
rails/rails@e65d41a.

ActionView::PathSet now rejects resolvers unless they inherit from
ActionView::Resolver, so ResolverDecorator must do so. By removing all
inherited methods, we ensure that method_missing will still intercept
all method calls.

Co-authored-by: Iliana Hadzhiatanasova <me@iliana.dev>
@pirj pirj merged commit c2aac54 into rspec:main Oct 28, 2022
@pirj
Copy link
Member

pirj commented Oct 28, 2022

Thanks a lot @eugeneius and @ilianah !

@JonRowe
Copy link
Member

JonRowe commented Oct 28, 2022

Can you add a spec for this @eugeneius / @ilianah ? The linked build wasn't failing before this?

pirj added a commit that referenced this pull request Oct 28, 2022
@pirj
Copy link
Member

pirj commented Oct 28, 2022

It was, it's just deceivingly green on GitHub:

  1) RSpec::Rails::ViewRendering when render_views? is false supports manipulating view paths with resolvers
     Failure/Error:
       expect {
         controller.prepend_view_path ActionView::Resolver.new
         controller.append_view_path ActionView::Resolver.new
       }.to_not raise_error

       expected no Exception, got #<NoMethodError: undefined method `unshift' for #<ActionView::PathSet:0x00007f6132d1d950 @paths=[]>> with backtrace:
         # ./spec/rspec/rails/view_rendering_spec.rb:142:in `block (4 levels) in <module:Rails>'
         # ./spec/rspec/rails/view_rendering_spec.rb:141:in `block (3 levels) in <module:Rails>'
         # ./spec/spec_helper.rb:74:in `block (3 levels) in <top (required)>'
         # ./spec/spec_helper.rb:68:in `block (2 levels) in <top (required)>'

@JonRowe
Copy link
Member

JonRowe commented Oct 28, 2022

Ah great, thats not obvious from the link

@JonRowe
Copy link
Member

JonRowe commented Oct 28, 2022

@pirj Can you add a changelog entry as you merged this

@pirj
Copy link
Member

pirj commented Oct 28, 2022

@JonRowe Already pushed 馃憤

@JonRowe
Copy link
Member

JonRowe commented Oct 28, 2022

Can you also cherry pick the merge and the changelog commit across to 6-0-maintenance if we're classing these as bug fixes.

pirj added a commit that referenced this pull request Oct 28, 2022
@pirj
Copy link
Member

pirj commented Oct 28, 2022

Done 馃憤
My apologies for missing that step, I'm still new to our release management.

@JonRowe
Copy link
Member

JonRowe commented May 4, 2023

Released in 6.0.2

mamhoff added a commit to mamhoff/solidus_dev_support that referenced this pull request Jan 18, 2024
rspec-rails < 6.0.2 is incompatible with Rails 7.1 because of stricter
view path typecasting in Rails 7.1. This bug is fixed in rspec-rails
6.0.2. Without this, controller specs in extensions will break.

rspec/rspec-rails#2631
mamhoff added a commit to mamhoff/solidus_dev_support that referenced this pull request Jan 18, 2024
rspec-rails < 6.0.2 is incompatible with Rails 7.1 because of stricter
view path typecasting in Rails 7.1. This bug is fixed in rspec-rails
6.0.2. Without this, controller specs in extensions will break.

rspec/rspec-rails#2631

This also raises the minimum version to rspec-rails 5 as Solidus 3.x
needs Rails > 5.2, and rspec-rails 5 is the version for that Rails
version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants