1 require "application_system_test_case"
3 class ProfileImageChangeTest < ApplicationSystemTestCase
4 test "can't change image when unauthorized" do
10 assert_no_button "Edit Profile Details"
11 assert_no_link "Change Image"
15 test "can't change image of another user" do
17 another_user = create(:user)
20 visit user_path(another_user)
22 within_content_body do
23 assert_no_button "Edit Profile Details"
24 assert_no_link "Change Image"
28 test "can add and remove image" do
34 within_content_body do
35 click_on "Edit Profile Details"
36 click_on "Change Image"
37 assert_unchecked_field "Add an image"
38 assert_no_field "Keep the current image"
39 assert_no_field "Remove the current image"
40 assert_no_field "Replace the current image"
42 attach_file "Avatar", "test/gpx/fixtures/a.gif"
44 assert_checked_field "Add an image"
46 click_on "Update Profile"
49 assert_text "Profile image updated."
51 within_content_body do
52 click_on "Edit Profile Details"
53 click_on "Change Image"
54 assert_no_field "Add an image"
55 assert_checked_field "Keep the current image"
56 assert_unchecked_field "Remove the current image"
57 assert_unchecked_field "Replace the current image"
59 choose "Remove the current image"
60 click_on "Update Profile"
63 assert_text "Profile image updated."
65 within_content_body do
66 click_on "Edit Profile Details"
67 click_on "Change Image"
68 assert_unchecked_field "Add an image"
69 assert_no_field "Keep the current image"
70 assert_no_field "Remove the current image"
71 assert_no_field "Replace the current image"