Much base work started
This commit is contained in:
67
test/controllers/passwords_controller_test.rb
Normal file
67
test/controllers/passwords_controller_test.rb
Normal file
@@ -0,0 +1,67 @@
|
||||
require "test_helper"
|
||||
|
||||
class PasswordsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup { @user = User.take }
|
||||
|
||||
test "new" do
|
||||
get new_password_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "create" do
|
||||
post passwords_path, params: { email_address: @user.email_address }
|
||||
assert_enqueued_email_with PasswordsMailer, :reset, args: [ @user ]
|
||||
assert_redirected_to new_session_path
|
||||
|
||||
follow_redirect!
|
||||
assert_notice "reset instructions sent"
|
||||
end
|
||||
|
||||
test "create for an unknown user redirects but sends no mail" do
|
||||
post passwords_path, params: { email_address: "missing-user@example.com" }
|
||||
assert_enqueued_emails 0
|
||||
assert_redirected_to new_session_path
|
||||
|
||||
follow_redirect!
|
||||
assert_notice "reset instructions sent"
|
||||
end
|
||||
|
||||
test "edit" do
|
||||
get edit_password_path(@user.password_reset_token)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "edit with invalid password reset token" do
|
||||
get edit_password_path("invalid token")
|
||||
assert_redirected_to new_password_path
|
||||
|
||||
follow_redirect!
|
||||
assert_notice "reset link is invalid"
|
||||
end
|
||||
|
||||
test "update" do
|
||||
assert_changes -> { @user.reload.password_digest } do
|
||||
put password_path(@user.password_reset_token), params: { password: "new", password_confirmation: "new" }
|
||||
assert_redirected_to new_session_path
|
||||
end
|
||||
|
||||
follow_redirect!
|
||||
assert_notice "Password has been reset"
|
||||
end
|
||||
|
||||
test "update with non matching passwords" do
|
||||
token = @user.password_reset_token
|
||||
assert_no_changes -> { @user.reload.password_digest } do
|
||||
put password_path(token), params: { password: "no", password_confirmation: "match" }
|
||||
assert_redirected_to edit_password_path(token)
|
||||
end
|
||||
|
||||
follow_redirect!
|
||||
assert_notice "Passwords did not match"
|
||||
end
|
||||
|
||||
private
|
||||
def assert_notice(text)
|
||||
assert_select "div", /#{text}/
|
||||
end
|
||||
end
|
||||
33
test/controllers/sessions_controller_test.rb
Normal file
33
test/controllers/sessions_controller_test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require "test_helper"
|
||||
|
||||
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup { @user = User.take }
|
||||
|
||||
test "new" do
|
||||
get new_session_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "create with valid credentials" do
|
||||
post session_path, params: { email_address: @user.email_address, password: "password" }
|
||||
|
||||
assert_redirected_to root_path
|
||||
assert cookies[:session_id]
|
||||
end
|
||||
|
||||
test "create with invalid credentials" do
|
||||
post session_path, params: { email_address: @user.email_address, password: "wrong" }
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_nil cookies[:session_id]
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
sign_in_as(User.take)
|
||||
|
||||
delete session_path
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_empty cookies[:session_id]
|
||||
end
|
||||
end
|
||||
23
test/controllers/storage_locations_controller_test.rb
Normal file
23
test/controllers/storage_locations_controller_test.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require "test_helper"
|
||||
|
||||
class StorageLocationsControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get index" do
|
||||
get storage_locations_index_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get storage_locations_show_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get create" do
|
||||
get storage_locations_create_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get destroy" do
|
||||
get storage_locations_destroy_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
13
test/controllers/videos_controller_test.rb
Normal file
13
test/controllers/videos_controller_test.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require "test_helper"
|
||||
|
||||
class VideosControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get index" do
|
||||
get videos_index_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get videos_show_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
13
test/controllers/works_controller_test.rb
Normal file
13
test/controllers/works_controller_test.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require "test_helper"
|
||||
|
||||
class WorksControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get index" do
|
||||
get works_index_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get works_show_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user