Removed routes from credentials that aren't used along with controller actions
79 lines
2.4 KiB
Ruby
79 lines
2.4 KiB
Ruby
require "test_helper"
|
|
|
|
class CredentialsControllerTest < ActionDispatch::IntegrationTest
|
|
include Devise::Test::IntegrationHelpers
|
|
|
|
setup do
|
|
@credential = credentials(:one)
|
|
@domain = domains(:one)
|
|
end
|
|
|
|
test "should not get new" do
|
|
get new_domain_credential_url(@domain.id)
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should get new" do
|
|
sign_in users(:bob)
|
|
get new_domain_credential_url(@domain.id)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not create credential because we are not logged in" do
|
|
assert_no_difference("Credential.count") do
|
|
post domain_credentials_url(@domain.id), params: { credential: { email: "steve", password: "ThePassword12345%" } }
|
|
end
|
|
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should create credential because we are logged in" do
|
|
sign_in users(:bob)
|
|
assert_difference("Credential.count") do
|
|
post domain_credentials_url(@domain.id), params: { credential: { email: "steve", password: "ThePassword12345%" } }
|
|
end
|
|
|
|
assert_redirected_to domain_path(@domain.id)
|
|
end
|
|
|
|
test "should get edit not get edit because we are not logged in" do
|
|
get edit_domain_credential_url(@domain,@credential)
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should get edit because we are logged in" do
|
|
sign_in users(:bob)
|
|
get edit_domain_credential_url(@domain,@credential)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not update credential because we are not logged in" do
|
|
patch domain_credential_url(@domain,@credential), params: { credential: { email: @credential.email, password: @credential.password } }
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should update credential because we are logged in" do
|
|
sign_in users(:bob)
|
|
patch domain_credential_url(@domain,@credential), params: { credential: { email: @credential.email, password: @credential.password } }
|
|
assert_redirected_to domain_url(@domain)
|
|
end
|
|
|
|
test "should not destroy credential because we are not logged in" do
|
|
assert_no_difference("Credential.count") do
|
|
delete domain_credential_url(@domain,@credential)
|
|
end
|
|
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should destroy credential because we are logged in" do
|
|
sign_in users(:bob)
|
|
assert_difference("Credential.count", -1) do
|
|
delete domain_credential_url(@domain,@credential)
|
|
end
|
|
|
|
assert_redirected_to domain_url(@domain)
|
|
end
|
|
|
|
end
|