2024-12-31 14:20:22 +08:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class UsersControllerTest < ActionDispatch::IntegrationTest
|
2025-01-03 13:48:59 +08:00
|
|
|
def setup
|
|
|
|
@user = users(:michael)
|
|
|
|
@other_user = users(:archer)
|
|
|
|
end
|
2024-12-31 14:20:22 +08:00
|
|
|
test "should get new" do
|
|
|
|
get signup_path
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
test "Should get sign up title" do
|
|
|
|
get signup_path
|
|
|
|
assert_response :success
|
|
|
|
assert_select "title", full_title("Sign up")
|
|
|
|
end
|
2025-01-03 13:48:59 +08:00
|
|
|
|
|
|
|
test "should redirect edit when logged in as wrong user" do
|
|
|
|
log_in_as(@other_user)
|
|
|
|
get edit_user_path(@user)
|
|
|
|
assert flash.empty?
|
|
|
|
assert_redirected_to root_url
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should redirect update when logged in as wrong user" do
|
|
|
|
log_in_as(@other_user)
|
|
|
|
patch user_path(@user), params: { user: { name: @user.name,
|
|
|
|
email: @user.email } }
|
|
|
|
assert flash.empty?
|
|
|
|
assert_redirected_to root_url
|
|
|
|
end
|
2024-12-31 14:20:22 +08:00
|
|
|
end
|