From d97ef45337c07e80840b3ba24447f8161d5aa68a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 19 Feb 2025 07:48:07 +0300 Subject: [PATCH] Show terms acceptance dates and link to terms on account page --- app/views/accounts/show.html.erb | 61 +++++++++++++++-------- config/locales/en.yml | 19 ++++--- test/system/account_terms_test.rb | 83 +++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 test/system/account_terms_test.rb diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 34665947c..5c45c4acb 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -27,26 +27,6 @@ -
- - - <% if current_user.terms_agreed? %> - <%= t ".contributor terms.agreed" %> - (" target="_new"><%= t ".contributor terms.link text" %>) -
- <% if current_user.consider_pd? %> - <%= t ".contributor terms.agreed_with_pd" %> - <% else %> - <%= t ".contributor terms.not_agreed_with_pd" %> - (<%= link_to t(".contributor terms.pd_link_text"), account_pd_declaration_path %>) - <% end %> - <% else %> - <%= t ".contributor terms.not yet agreed" %> - <%= link_to t(".contributor terms.review link text"), account_terms_path %> - <% end %> -
-
-
<%= f.primary t(".save changes button") %> @@ -55,8 +35,49 @@ <%= link_to t(".delete_account"), account_deletion_path, :class => "btn btn-outline-danger" %>
+ <% end %> +
+ +
+
+

<%= t ".contributor_terms.heading" %>

+
+ <% if current_user.terms_agreed? %> + <%= t ".contributor_terms.agreed", :date => l(@current_user.terms_agreed.to_date, :format => :long) %> + <% else %> + <%= t ".contributor_terms.not_agreed" %> + <% end %> +
+ <% if current_user.consider_pd? %> + <%= t ".contributor_terms.agreed_with_pd" %> + <% else %> + <%= t ".contributor_terms.not_agreed_with_pd" %> + <% end %> +
+ <%= link_to current_user.terms_agreed? ? t(".contributor_terms.review") : t(".contributor_terms.review_and_accept"), account_terms_path %> + <% unless current_user.consider_pd? %> + · + <%= link_to t(".contributor_terms.consider_pd"), account_pd_declaration_path %> + <% end %> +
+
+ +
+

<%= t ".terms_of_use.heading" %>

+
+ <% if current_user.tou_agreed? %> + <%= t ".terms_of_use.agreed", :date => l(@current_user.tou_agreed.to_date, :format => :long) %> + <% else %> + <%= t ".terms_of_use.not_agreed" %> + <% end %> +
+ <%= link_to current_user.tou_agreed? ? t(".terms_of_use.review") : t(".terms_of_use.review_and_accept"), account_terms_path %> +
+
+
+ <% unless current_user.data_public? %> <%= render :partial => "go_public" %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 6c507f317..4fc6de6f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -258,16 +258,21 @@ en: my_account: My Account current email address: "Current Email Address" external auth: "External Authentication" - contributor terms: + contributor_terms: heading: "Contributor Terms" - agreed: "You have agreed to the new Contributor Terms." - not yet agreed: "You have not yet agreed to the new Contributor Terms." - review link text: "Please follow this link at your convenience to review and accept the new Contributor Terms." + agreed: "You agreed to the Contributor Terms on %{date}." + not_agreed: "You have not yet agreed to the Contributor Terms." agreed_with_pd: "You have also declared that you consider your edits to be in the Public Domain." - link: "https://osmfoundation.org/wiki/Licence/Contributor_Terms" - link text: "what is this?" not_agreed_with_pd: "You haven't declared that you consider your edits to be in the Public Domain." - pd_link_text: "declare" + review: "Review the Terms" + review_and_accept: "Review and accept the Terms" + consider_pd: "Consider Public Domain" + terms_of_use: + heading: "Terms of Use" + agreed: "You agreed to the Terms of Use on %{date}." + not_agreed: "You have not yet agreed to the Terms of Use." + review: "Review the Terms" + review_and_accept: "Review and accept the Terms" save changes button: Save Changes delete_account: Delete Account... go_public: diff --git a/test/system/account_terms_test.rb b/test/system/account_terms_test.rb new file mode 100644 index 000000000..cd5feeb8b --- /dev/null +++ b/test/system/account_terms_test.rb @@ -0,0 +1,83 @@ +require "application_system_test_case" + +class AccountTermsTest < ApplicationSystemTestCase + test "should inform about terms if not agreed" do + user = create(:user, :terms_seen => true, :terms_agreed => nil, :tou_agreed => nil) + + sign_in_as(user) + visit account_path + + within_content_body do + assert_text(/You have not yet agreed to.*Contributor Terms/) + assert_text(/You have not yet agreed to.*Terms of Use/) + assert_link "Review and accept the Terms" + + click_on "Review and accept the Terms", :match => :first + end + + assert_current_path account_terms_path + end + + test "should inform about terms if partially agreed" do + user = create(:user, :terms_seen => true, :terms_agreed => "2022-03-14", :tou_agreed => nil) + + sign_in_as(user) + visit account_path + + within_content_body do + assert_text(/You agreed to.*Contributor Terms.*March 14, 2022/) + assert_text(/You have not yet agreed to.*Terms of Use/) + assert_link "Review the Terms" + assert_link "Review and accept the Terms" + + click_on "Review and accept the Terms", :match => :first + end + + assert_current_path account_terms_path + end + + test "should inform about terms if agreed" do + user = create(:user, :terms_seen => true, :terms_agreed => "2023-04-15", :tou_agreed => "2024-05-16") + + sign_in_as(user) + visit account_path + + within_content_body do + assert_text(/You agreed to.*Contributor Terms.*April 15, 2023/) + assert_text(/You agreed to.*Terms of Use.*May 16, 2024/) + assert_link "Review the Terms" + + click_on "Review the Terms", :match => :first + end + + assert_current_path account_terms_path + end + + test "should ask to consider pd if not considered" do + user = create(:user, :consider_pd => false) + + sign_in_as(user) + visit account_path + + within_content_body do + assert_text(/You haven't declared.*Public Domain/) + assert_link "Consider Public Domain" + + click_on "Consider Public Domain" + end + + assert_current_path account_pd_declaration_path + end + + test "should not ask to consider pd if considered" do + user = create(:user, :consider_pd => true) + + sign_in_as(user) + visit account_path + + within_content_body do + assert_text(/You have also declared.*Public Domain/) + assert_no_link "Consider Public Domain" + end + end +end -- 2.39.5