1 require "application_system_test_case"
3 class ProfileImageChangeTest < ApplicationSystemTestCase
4 test "can't change image when unauthorized" do
9 within_content_heading do
10 assert_no_link "Change Image"
13 within_content_body do
14 assert_no_button "Edit Profile Details"
15 assert_no_link "Change Image"
19 test "can't change image of another user" do
21 another_user = create(:user)
24 visit user_path(another_user)
26 within_content_heading do
27 assert_no_link "Change Image"
30 within_content_body do
31 assert_no_button "Edit Profile Details"
32 assert_no_link "Change Image"
36 test "can add and remove image" do
42 within_content_body do
43 click_on "Edit Profile Details"
44 click_on "Change Image"
45 assert_unchecked_field "Add an image"
46 assert_no_field "Keep the current image"
47 assert_no_field "Remove the current image"
48 assert_no_field "Replace the current image"
50 attach_file "Avatar", "test/gpx/fixtures/a.gif"
52 assert_checked_field "Add an image"
54 click_on "Update Profile"
57 assert_text "Profile image updated."
59 within_content_body do
60 click_on "Edit Profile Details"
61 click_on "Change Image"
62 assert_no_field "Add an image"
63 assert_checked_field "Keep the current image"
64 assert_unchecked_field "Remove the current image"
65 assert_unchecked_field "Replace the current image"
67 choose "Remove the current image"
68 click_on "Update Profile"
71 assert_text "Profile image updated."
73 within_content_body do
74 click_on "Edit Profile Details"
75 click_on "Change Image"
76 assert_unchecked_field "Add an image"
77 assert_no_field "Keep the current image"
78 assert_no_field "Remove the current image"
79 assert_no_field "Replace the current image"
83 test "can add image by clicking the placeholder image" do
89 within_content_heading do
90 click_on "Change Image"
93 within_content_body do
94 assert_unchecked_field "Add an image"
95 assert_no_field "Keep the current image"
96 assert_no_field "Remove the current image"
97 assert_no_field "Replace the current image"
99 attach_file "Avatar", "test/gpx/fixtures/a.gif"
101 assert_checked_field "Add an image"
103 click_on "Update Profile"
106 assert_text "Profile image updated."
108 within_content_heading do
109 click_on "Change Image"
112 within_content_body do
113 assert_no_field "Add an image"
114 assert_checked_field "Keep the current image"
115 assert_unchecked_field "Remove the current image"
116 assert_unchecked_field "Replace the current image"