2024-07-26 23:24:54 -04:00
|
|
|
require "application_system_test_case"
|
|
|
|
|
|
|
|
class UsersTest < ApplicationSystemTestCase
|
|
|
|
setup do
|
|
|
|
@user = users(:one)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "visiting the index" do
|
2024-09-08 21:07:51 -04:00
|
|
|
login(@user.email)
|
2024-07-26 23:24:54 -04:00
|
|
|
visit users_url
|
|
|
|
assert_selector "h1", text: "Users"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should create user" do
|
|
|
|
visit users_url
|
2024-09-08 21:07:51 -04:00
|
|
|
click_on "Sign up"
|
2024-07-26 23:24:54 -04:00
|
|
|
|
2024-09-08 22:18:56 -04:00
|
|
|
stub_environment(REGISTRATION_ALLOWED: "true") do
|
|
|
|
fill_in "Email", with: "userthree@example.local"
|
|
|
|
fill_in "Password", with: "secret"
|
|
|
|
fill_in "Password confirmation", with: "secret"
|
|
|
|
click_on "Create User"
|
|
|
|
|
|
|
|
assert_text "User was successfully created"
|
|
|
|
end
|
2024-07-26 23:24:54 -04:00
|
|
|
click_on "Back"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should update User" do
|
2024-09-08 21:07:51 -04:00
|
|
|
login(@user.email)
|
2024-07-26 23:24:54 -04:00
|
|
|
visit user_url(@user)
|
|
|
|
click_on "Edit this user", match: :first
|
|
|
|
|
|
|
|
fill_in "Email", with: "newemail@example.local"
|
|
|
|
fill_in "Password", with: "newpassword"
|
|
|
|
fill_in "Password confirmation", with: "newpassword"
|
|
|
|
click_on "Update User"
|
|
|
|
|
|
|
|
assert_text "User was successfully updated"
|
|
|
|
click_on "Back"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy User" do
|
2024-09-08 21:07:51 -04:00
|
|
|
login(@user.email)
|
|
|
|
visit user_url(users(:two))
|
2024-07-26 23:24:54 -04:00
|
|
|
click_on "Destroy this user", match: :first
|
|
|
|
|
|
|
|
assert_text "User was successfully destroyed"
|
|
|
|
end
|
|
|
|
end
|