93 lines
2.2 KiB
Ruby
93 lines
2.2 KiB
Ruby
require "test_helper"
|
|
|
|
class DomainsControllerTest < ActionDispatch::IntegrationTest
|
|
include Devise::Test::IntegrationHelpers
|
|
setup do
|
|
@domain = domains(:one)
|
|
end
|
|
|
|
test "not should get index because we are not logged in" do
|
|
get domains_url
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should get index because we are logged in" do
|
|
sign_in users(:bob)
|
|
get domains_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not get new" do
|
|
get new_domain_url
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should get new" do
|
|
sign_in users(:bob)
|
|
get new_domain_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not create domain" do
|
|
post domains_url, params: { domain: { domain: "brand-new-domain.com" } }
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should create domain" do
|
|
sign_in users(:bob)
|
|
assert_difference("Domain.count") do
|
|
post domains_url, params: { domain: { domain: "brand-new-domain.com" } }
|
|
end
|
|
|
|
assert_redirected_to domain_url(Domain.last)
|
|
end
|
|
|
|
test "should show domain" do
|
|
sign_in users(:bob)
|
|
get domain_url(@domain)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not show domain" do
|
|
get domain_url(@domain)
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should get edit" do
|
|
sign_in users(:bob)
|
|
get edit_domain_url(@domain)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should not get edit" do
|
|
get edit_domain_url(@domain)
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
|
|
test "should not update domain" do
|
|
patch domain_url(@domain), params: { domain: { domain: @domain.domain } }
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should update domain" do
|
|
sign_in users(:bob)
|
|
patch domain_url(@domain), params: { domain: { domain: @domain.domain } }
|
|
assert_redirected_to domain_url(@domain)
|
|
end
|
|
|
|
test "should not destroy domain" do
|
|
delete domain_url(@domain)
|
|
assert_redirected_to new_user_session_path
|
|
end
|
|
|
|
test "should destroy domain" do
|
|
sign_in users(:bob)
|
|
assert_difference("Domain.count", -1) do
|
|
delete domain_url(@domain)
|
|
end
|
|
|
|
assert_redirected_to domains_url
|
|
end
|
|
end
|