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