]> git.openstreetmap.org Git - rails.git/blob - test/system/account_terms_test.rb
Merge remote-tracking branch 'upstream/pull/6182'
[rails.git] / test / system / account_terms_test.rb
1 require "application_system_test_case"
2
3 class AccountTermsTest < ApplicationSystemTestCase
4   test "should inform about terms if not agreed" do
5     user = create(:user, :terms_seen => true, :terms_agreed => nil, :tou_agreed => nil)
6
7     sign_in_as(user)
8     visit account_path
9
10     within_content_body do
11       assert_text(/You have not yet agreed to.*Contributor Terms/)
12       assert_text(/You have not yet agreed to.*Terms of Use/)
13       assert_link "Review and accept the Terms"
14
15       click_on "Review and accept the Terms", :match => :first
16     end
17
18     assert_current_path account_terms_path
19   end
20
21   test "should inform about terms if partially agreed" do
22     user = create(:user, :terms_seen => true, :terms_agreed => "2022-03-14", :tou_agreed => nil)
23
24     sign_in_as(user)
25     visit account_path
26
27     within_content_body do
28       assert_text(/You agreed to.*Contributor Terms.*March 14, 2022/)
29       assert_text(/You have not yet agreed to.*Terms of Use/)
30       assert_link "Review the Terms"
31       assert_link "Review and accept the Terms"
32
33       click_on "Review and accept the Terms", :match => :first
34     end
35
36     assert_current_path account_terms_path
37   end
38
39   test "should inform about terms if agreed" do
40     user = create(:user, :terms_seen => true, :terms_agreed => "2023-04-15", :tou_agreed => "2024-05-16")
41
42     sign_in_as(user)
43     visit account_path
44
45     within_content_body do
46       assert_text(/You agreed to.*Contributor Terms.*April 15, 2023/)
47       assert_text(/You agreed to.*Terms of Use.*May 16, 2024/)
48       assert_link "Review the Terms"
49
50       click_on "Review the Terms", :match => :first
51     end
52
53     assert_current_path account_terms_path
54   end
55
56   test "should ask to consider pd if not considered" do
57     user = create(:user, :consider_pd => false)
58
59     sign_in_as(user)
60     visit account_path
61
62     within_content_body do
63       assert_text(/You haven't declared.*Public Domain/)
64       assert_link "Consider Public Domain"
65
66       click_on "Consider Public Domain"
67     end
68
69     assert_current_path account_pd_declaration_path
70   end
71
72   test "should not ask to consider pd if considered" do
73     user = create(:user, :consider_pd => true)
74
75     sign_in_as(user)
76     visit account_path
77
78     within_content_body do
79       assert_text(/You have also declared.*Public Domain/)
80       assert_no_link "Consider Public Domain"
81     end
82   end
83 end