-
Notifications
You must be signed in to change notification settings - Fork 23
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
Showing
20 changed files
with
155 additions
and
70 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
OVERMIND_PROCFILE=Procfile.dev | ||
HIVEMIND_PROCFILE=Procfile.dev | ||
PORT=3000 | ||
OVERMIND_ENV=./.env.local | ||
HIVEMIND_ENV=./.env.local | ||
RSPEC_RETRY_RETRY_COUNT=0 |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
class MainController < ApplicationController | ||
skip_before_action :authenticate_user! | ||
allow_unauthenticated_access | ||
|
||
def index | ||
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 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
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
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 @@ | ||
module AuthenticationHelper | ||
def sign_in(user, password = "password2024") | ||
if respond_to?(:visit) # System specs | ||
visit new_session_path | ||
find_dti("email_field").set(user.email) | ||
find_dti("password_field").set(password) | ||
find_dti("sign_in_button").click | ||
else # Controller specs | ||
session[:user_id] = user.id | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include AuthenticationHelper, type: :system | ||
config.include AuthenticationHelper, type: :controller | ||
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,37 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "User sign in", type: :system do | ||
let!(:user) { create(:user, email: "[email protected]", password: "foobar2024") } | ||
|
||
it "redirects to the login page when trying to access another page" do | ||
visit edit_password_path | ||
expect(page).to have_current_path(new_session_path) | ||
expect(page).to have_content("You need to sign in or sign up before continuing.") | ||
end | ||
|
||
context "when the user inputs invalid credentials" do | ||
it "does not sign the user in" do | ||
visit new_session_path | ||
find_dti("email_field").set("[email protected]") | ||
find_dti("password_field").set("wrongpassword") | ||
find_dti("sign_in_button").click | ||
expect(page).to have_content("Invalid email or password.") | ||
|
||
visit edit_password_path | ||
expect(page).to have_current_path(new_session_path) | ||
end | ||
end | ||
|
||
context "when the user inputs valid credentials" do | ||
it "signs the user in" do | ||
visit new_session_path | ||
find_dti("email_field").set("[email protected]") | ||
find_dti("password_field").set("foobar2024") | ||
find_dti("sign_in_button").click | ||
expect(page).to have_content("Signed in successfully.") | ||
|
||
visit edit_password_path | ||
expect(page).to have_current_path(edit_password_path) | ||
end | ||
end | ||
end |
Oops, something went wrong.