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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View helper methods #5493

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

gardnerapp
Copy link

@gardnerapp gardnerapp commented May 19, 2022

If/Else conditional statements based on a users session status are relatively common at the controller and view level of applications. These conditional statements are repetitive, accumulate quickly and make our code bulky . Great programs are DRY and this pull request seeks to DRY up our code by creating helper methods that abstract if/else conditionals into methods where a block is called based on a resources sign_in/out state.

Examples:

View ->

user_signed_out do <%= link_to "Sign In", new_user_session_path %> end

Controller ->

def some_action; admin_signed_in { render @posts }; admin_signed_out { redirect_to root_path }; end

class ViewsHelperMethodsTest < Devise::IntegrationTest

test 'Action View includes Devise::Views::Helpers' do
assert_includes ActionView.ancestors, Devise::Views::Helpers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_includes ActionView.ancestors, Devise::Views::Helpers
assert_includes ActionView.ancestors, Devise::Views::Helpers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get this pulled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Could we get this pull request submitted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants