-
Notifications
You must be signed in to change notification settings - Fork 443
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new helper API #1860
Add new helper API #1860
Conversation
@camertron I haven't added the test helpers discussed yet, but can you take a look at what is added so far |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, thanks @reeganviljoen! Could I ask you to take a look at my comments and write some docs as well?
Co-authored-by: Cameron Dutro <[email protected]>
Co-authored-by: Cameron Dutro <[email protected]>
Co-authored-by: Cameron Dutro <[email protected]>
Co-authored-by: Cameron Dutro <[email protected]>
Thanks for this @reeganviljoen! Let us know if you need help with the docs! |
@camertron, @Spone I got the use_helpers helper top work finally after many hours of debugging strange errors, however I believe it can be further refactored quite a bit but due to these errors whenever I try it breaks, if you can possibly help(if you can) it would be much appreciated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I had a few suggestions/thoughts but I like where this is going!
lib/view_component/test_helpers.rb
Outdated
# Set the controller helpers to be used while executing the given block, | ||
# | ||
# ```ruby | ||
# with_helpers(UsersHelper) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was imagining that this could be used to mock helpers instead of including helpers that should already be present on the view context.
e.g.
test "foo" do
# delegates to the current_user method
with_helpers(current_user: :current_user) do
render_inline MyComponent.new
end
current_user = create(:user)
# stubs the current_user helper to return this value
with_helpers(current_user: current_user) do
render_inline MyComponent.new
end
end
def current_user
# some logic
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlakeWilliams moving this to a new pr
@Spone, @BlakeWilliams , @camertron I have decided to separate the test_helper portion of this pull request as their seems to be a few unrelated issues that would benefit from focused attention, would any of you be able to review what is left of the |
Co-authored-by: Hans Lemuet <[email protected]>
Good call, let's focus on the core feature, then add the test helper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I think this is ready to go!
closes #1848
What are you trying to accomplish?
as discussed I am attempting to add a more explicit helpers api to replace
helper.<helper>
What approach did you choose and why?
I used a active support concern to add the method to make it modular and optional
Anything you want to highlight for special attention from reviewers?