]> git.openstreetmap.org Git - rails.git/blob - test/system/profile_description_change_test.rb
Fix eslint warning
[rails.git] / test / system / profile_description_change_test.rb
1 require "application_system_test_case"
2
3 class ProfileLinksChangeTest < ApplicationSystemTestCase
4   test "can't change description when unauthorized" do
5     user = create(:user)
6
7     visit user_path(user)
8
9     within_content_body do
10       assert_no_link "Edit Description"
11     end
12   end
13
14   test "can't change description of another user" do
15     user = create(:user)
16     another_user = create(:user)
17
18     sign_in_as(user)
19     visit user_path(another_user)
20
21     within_content_body do
22       assert_no_link "Edit Description"
23     end
24   end
25
26   test "can change description" do
27     user = create(:user)
28     check_description_change(user)
29   end
30
31   test "can change description when have a description" do
32     user = create(:user, :description => "My old profile description")
33     check_description_change(user)
34   end
35
36   test "can change description when have a link" do
37     user = create(:user)
38     create(:social_link, :user => user)
39     check_description_change(user)
40   end
41
42   test "can change description when have a description and a link" do
43     user = create(:user, :description => "My old profile description")
44     create(:social_link, :user => user)
45     check_description_change(user)
46   end
47
48   private
49
50   def check_description_change(user)
51     sign_in_as(user)
52     visit user_path(user)
53
54     within_content_body do
55       click_on "Edit Description"
56       fill_in "Profile Description", :with => "This is my updated OSM profile!"
57       click_on "Update Profile"
58     end
59
60     assert_text "Profile description updated."
61
62     within_content_body do
63       assert_text "This is my updated OSM profile!"
64     end
65   end
66 end