-
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.
- Loading branch information
1 parent
5c9f9c9
commit 45a4176
Showing
6 changed files
with
36 additions
and
10 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 |
---|---|---|
|
@@ -33,3 +33,4 @@ gem 'bcrypt', '~> 3.1.7' | |
|
||
gem 'jwt' | ||
|
||
gem 'rails-controller-testing' |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
require "test_helper" | ||
require 'test_helper' | ||
|
||
class SessionControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# 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 |
---|---|---|
@@ -1,7 +1,23 @@ | ||
require "test_helper" | ||
require 'test_helper' | ||
|
||
class UserControllerTest < ActionDispatch::IntegrationTest | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end | ||
test "should get register_form" do | ||
get register_path | ||
assert_response :success | ||
assert assigns(:user).is_a?(User) | ||
end | ||
|
||
test "should handle_register with valid parameters" do | ||
post register_path, params: { user: { username: "testuser", password: "password", password_confirmation: "password" } } | ||
assert_redirected_to root_path | ||
assert User.exists?(username: "testuser") | ||
assert_equal session[:user]['id'], User.find_by(username: "testuser").id | ||
end | ||
|
||
test "should handle_register with invalid parameters" do | ||
post register_path, params: { user: { username: "testuser", password: "password", password_confirmation: "wrongpassword" } } | ||
assert_template :register_form | ||
assert_response :unprocessable_entity | ||
assert assigns(:user).errors.full_messages.include?("Password confirmation doesn't match Password") | ||
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
one: | ||
username: "testuser_yml" | ||
password_digest: <%= BCrypt::Password.create("password") %> | ||
|
||
two: | ||
username: "anotheruser_yml" | ||
password_digest: <%= BCrypt::Password.create("anotherpassword") %> |