-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve sign out, allow account creation
- Loading branch information
1 parent
391d80e
commit c029fc7
Showing
13 changed files
with
179 additions
and
3 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
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 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 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 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,17 @@ | ||
.container.has-text-centered | ||
.columns | ||
.column.is-4.is-offset-4 | ||
%h3.title.has-text-grey= t('sessions.sign_up') | ||
.box | ||
= form_with(url: create_account_session_path) do |f| | ||
.field | ||
.control | ||
= f.email_field :email, autofocus: true, autocomplete: 'email', placeholder: '[email protected]', class: 'input is-large', value: @email | ||
.field | ||
.control | ||
= f.password_field :password, autocomplete: "new-password", placeholder: t(".password"), class: 'input is-large' | ||
.field | ||
.control | ||
= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: t(".password_confirmation"), class: 'input is-large' | ||
= f.submit t("sessions.sign_up"), class: 'button is-block is-info is-large is-fullwidth' | ||
= render "sessions/shared/links" |
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,5 @@ | ||
%p.has-text-grey | ||
!= [ | | ||
action_name != "new" ? link_to(t("sessions.sign_in"), new_session_path) : nil, | | ||
action_name != "new_account" ? link_to(t("sessions.sign_up"), new_account_session_path) : nil | | ||
].compact.join(" · ") | |
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 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 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 |
---|---|---|
|
@@ -35,4 +35,48 @@ class RetroMeetClientTest < ActiveSupport::TestCase | |
end | ||
assert_requested(:post, "http://localhost:3000/login") | ||
end | ||
|
||
test "calls the create_account method with good params and get an auth token" do | ||
login = "[email protected]" | ||
password = "bar" | ||
stub_request(:post, "http://localhost:3000/create-account").with(headers: { "Content-Type" => "application/json" }) | ||
.to_return(webfixture_json_file("create_account_ok")) | ||
|
||
expected_response = "eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50X2lkIjoxNCwiYXV0aGVudGljYXRlZF9ieSI6WyJhdXRvbG9naW4iXSwiYXV0b2xvZ2luX3R5cGUiOiJjcmVhdGVfYWNjb3VudCJ9.Fo5ZXDASNTcea-V4KlX8JjWy7XQOcPHDFcjET0HeIsw" | ||
assert_equal expected_response, RetroMeetClient.create_account(login:, password:) | ||
assert_requested(:post, "http://localhost:3000/create-account") | ||
end | ||
test "calls the create_account method with good params but already used login and gets the proper error" do | ||
login = "[email protected]" | ||
password = "bar" | ||
stub_request(:post, "http://localhost:3000/create-account").with(headers: { "Content-Type" => "application/json" }) | ||
.to_return(webfixture_json_file("create_account_existing")) | ||
|
||
assert_raises RetroMeetClient::LoginAlreadyTakenError do | ||
RetroMeetClient.create_account(login:, password:) | ||
end | ||
assert_requested(:post, "http://localhost:3000/create-account") | ||
end | ||
test "calls the create_account method with a bad password and gets an error" do | ||
login = "[email protected]" | ||
password = "" | ||
stub_request(:post, "http://localhost:3000/create-account").with(headers: { "Content-Type" => "application/json" }) | ||
.to_return(webfixture_json_file("create_account_bad_password")) | ||
|
||
assert_raises RetroMeetClient::BadPasswordError do | ||
RetroMeetClient.create_account(login:, password:) | ||
end | ||
assert_requested(:post, "http://localhost:3000/create-account") | ||
end | ||
test "calls the create_account method with a bad login and gets an error" do | ||
login = "bad_login" | ||
password = "bad_password" | ||
stub_request(:post, "http://localhost:3000/create-account").with(headers: { "Content-Type" => "application/json" }) | ||
.to_return(webfixture_json_file("create_account_bad_login")) | ||
|
||
assert_raises RetroMeetClient::BadLoginError do | ||
RetroMeetClient.create_account(login:, password:) | ||
end | ||
assert_requested(:post, "http://localhost:3000/create-account") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 422 Unprocessable Entity | ||
authorization: eyJhbGciOiJIUzI1NiJ9.e30.7k-y2TFPta8oQgUMssFXSdaS8XEogkVljv1-STmDjgk | ||
content-type: application/json | ||
vary: accept-encoding | ||
content-length: 119 | ||
|
||
{"field-error":["login","invalid login, not a valid email address"],"error":"There was an error creating your account"} |
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 @@ | ||
HTTP/1.1 422 Unprocessable Entity | ||
authorization: eyJhbGciOiJIUzI1NiJ9.e30.7k-y2TFPta8oQgUMssFXSdaS8XEogkVljv1-STmDjgk | ||
content-type: application/json | ||
vary: accept-encoding | ||
content-length: 149 | ||
|
||
{"field-error":["password","invalid password, does not meet requirements (minimum 6 characters)"],"error":"There was an error creating your account"} |
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 @@ | ||
HTTP/1.1 422 Unprocessable Entity | ||
authorization: eyJhbGciOiJIUzI1NiJ9.e30.7k-y2TFPta8oQgUMssFXSdaS8XEogkVljv1-STmDjgk | ||
content-type: application/json | ||
vary: accept-encoding | ||
content-length: 128 | ||
|
||
{"field-error":["login","invalid login, already an account with this login"],"error":"There was an error creating your account"} |
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 @@ | ||
HTTP/1.1 200 OK | ||
authorization: eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50X2lkIjoxNCwiYXV0aGVudGljYXRlZF9ieSI6WyJhdXRvbG9naW4iXSwiYXV0b2xvZ2luX3R5cGUiOiJjcmVhdGVfYWNjb3VudCJ9.Fo5ZXDASNTcea-V4KlX8JjWy7XQOcPHDFcjET0HeIsw | ||
content-type: application/json | ||
vary: accept-encoding | ||
content-length: 43 | ||
|
||
{"success":"Your account has been created"} |