]> git.openstreetmap.org Git - rails.git/blob - test/system/profile_links_change_test.rb
Rename profile update system tests to match controller names
[rails.git] / test / system / profile_links_change_test.rb
1 require "application_system_test_case"
2
3 class ProfileLinksChangeTest < ApplicationSystemTestCase
4   def setup
5     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
6
7     @user = create(:user)
8     sign_in_as(@user)
9     visit profile_links_path
10   end
11
12   test "can add and remove social link without submitting" do
13     within_content_body do
14       assert_no_field "Social Profile Link 1"
15
16       click_on "Add Social Link"
17
18       assert_field "Social Profile Link 1"
19
20       click_on "Remove Social Profile Link 1"
21
22       assert_no_field "Social Profile Link 1"
23     end
24   end
25
26   test "can add and remove social links" do
27     within_content_body do
28       assert_no_field "Social Profile Link 1"
29
30       click_on "Add Social Link"
31       fill_in "Social Profile Link 1", :with => "https://example.com/user/fred"
32       click_on "Update Profile"
33
34       assert_link "example.com/user/fred"
35
36       click_on "Edit Profile"
37     end
38
39     within_content_heading do
40       click_on "Links"
41     end
42
43     within_content_body do
44       click_on "Remove Social Profile Link 1"
45
46       assert_no_field "Social Profile Link 1"
47
48       click_on "Update Profile"
49
50       assert_no_link "example.com/user/fred"
51     end
52   end
53
54   test "can control social links using keyboard without submitting" do
55     within_content_body do
56       click_on "Add Social Link"
57
58       assert_field "Social Profile Link 1"
59
60       send_keys :tab, :enter
61
62       assert_no_field "Social Profile Link 1"
63     end
64   end
65
66   test "can control social links using keyboard" do
67     within_content_body do
68       click_on "Add Social Link"
69       send_keys "https://example.com/user/typed"
70       click_on "Update Profile"
71
72       assert_link "example.com/user/typed"
73
74       click_on "Edit Profile"
75     end
76
77     within_content_heading do
78       click_on "Links"
79     end
80
81     within_content_body do
82       find_field("Social Profile Link 1").click
83       send_keys :tab, :enter
84
85       assert_no_field "Social Profile Link 1"
86
87       click_on "Update Profile"
88
89       assert_no_link "example.com/user/typed"
90     end
91   end
92
93   test "can add and remove multiple links" do
94     within_content_body do
95       click_on "Add Social Link"
96       fill_in "Social Profile Link 1", :with => "https://example.com/a"
97       click_on "Add Social Link"
98       fill_in "Social Profile Link 2", :with => "https://example.com/b"
99       click_on "Add Social Link"
100       fill_in "Social Profile Link 3", :with => "https://example.com/c"
101       click_on "Update Profile"
102
103       assert_link "example.com/a"
104       assert_link "example.com/b"
105       assert_link "example.com/c"
106
107       click_on "Edit Profile"
108     end
109
110     within_content_heading do
111       click_on "Links"
112     end
113
114     within_content_body do
115       assert_field "Social Profile Link 1", :with => "https://example.com/a"
116       assert_field "Social Profile Link 2", :with => "https://example.com/b"
117       assert_field "Social Profile Link 3", :with => "https://example.com/c"
118
119       click_on "Remove Social Profile Link 2"
120
121       assert_field "Social Profile Link 1", :with => "https://example.com/a"
122       assert_field "Social Profile Link 2", :with => "https://example.com/c"
123
124       click_on "Add Social Link"
125       fill_in "Social Profile Link 3", :with => "https://example.com/d"
126       click_on "Update Profile"
127
128       assert_link "example.com/a"
129       assert_no_link "example.com/b"
130       assert_link "example.com/c"
131       assert_link "example.com/d"
132     end
133   end
134 end