-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
View example group inserts controller path into lookup_context in the wrong order #2729
Comments
sfnelson
added a commit
to katalyst/koi
that referenced
this issue
Feb 5, 2024
So if you change it to prepend (unshift) instead of << in rspec-rails code itself, would it fix your issue? Controller path taking precedence over a zero prefix sounds logical. Would you like to submit a PR? |
@pirj yes, changing line 189 to unshift instead of << will fix the issue. I'll see if I can create a reproduction and a PR. |
sfnelson
added a commit
to katalyst/rspec-rails
that referenced
this issue
Mar 27, 2024
Rails rendering assumes that the first prefix encountered is 'special', specifically, it's the controller's prefix. This can be seen in `ActionView::AbstractRenderer::ObjectRendering#initialize`. This change injects the controller path at the start of the prefix list instead of the end to make sure this assumption is satisfied. Resolves rspec#2729.
sfnelson
added a commit
to katalyst/rspec-rails
that referenced
this issue
Apr 10, 2024
Rails rendering assumes that the first prefix encountered is 'special', specifically, it's the controller's prefix. This can be seen in `ActionView::AbstractRenderer::ObjectRendering#initialize`. This change injects the controller path at the start of the prefix list instead of the end to make sure this assumption is satisfied. Resolves rspec#2729.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.2.3
Rails version: 7.1.3
RSpec version: 3.12.2
Observed behaviour
Testing a controller where the 'prefixes' logic in ActionView::Renderer::AbstractRenderer#merge_prefix_into_object_path applies fails to find view partials when called from inside a nested controller.
This happens because the logic uses
@context_prefix = lookup_context.prefixes.first
, which in view specs is""
, instead of the controller path.Expected behaviour
@context_prefix = lookup_context.prefixes.first
should return the controller's pathCan you provide an example reproduction?
Hard to reproduce as it relates to rails/rails#50916 – the logic in
merge_prefix_into_object_path
isn't very useful. I've got a monkey patch for that logic that address the issue, which is how I came across this issue.I believe the logic in
view_example_group
is faulty because it uses append instead of prepend when setting up the lookup context prefixes.rspec-rails/lib/rspec/rails/example/view_example_group.rb
Line 189 in 06d05ab
The text was updated successfully, but these errors were encountered: