-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c3e902
commit c0a75ab
Showing
5 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module GoogleSignIn::ButtonHelper | ||
def google_sign_in_button(text = nil, proceed_to:, **options, &block) | ||
form_with url: google_sign_in.authorization_path do | ||
hidden_field_tag(:proceed_to, proceed_to, id: nil) + button_tag(text, name: nil, **options, &block) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'test_helper' | ||
|
||
class GoogleSignIn::ButtonHelperTest < ActionView::TestCase | ||
test "generating a login button with text content" do | ||
assert_dom_equal <<-HTML, google_sign_in_button("Log in with Google", proceed_to: 'https://www.example.com/login') | ||
<form action="/google_sign_in/authorization" accept-charset="UTF-8" data-remote="true" method="post"> | ||
<input name="utf8" type="hidden" value="✓" /> | ||
<input name="proceed_to" type="hidden" value="https://www.example.com/login" /> | ||
<button type="submit">Log in with Google</button> | ||
</form> | ||
HTML | ||
end | ||
|
||
test "generating a login button with HTML content" do | ||
assert_dom_equal <<-HTML, google_sign_in_button(proceed_to: 'https://www.example.com/login') { image_tag('google.png') } | ||
<form action="/google_sign_in/authorization" accept-charset="UTF-8" data-remote="true" method="post"> | ||
<input name="utf8" type="hidden" value="✓" /> | ||
<input name="proceed_to" type="hidden" value="https://www.example.com/login" /> | ||
<button type="submit"><img src="/images/google.png"></button> | ||
</form> | ||
HTML | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters