From 4469c9f5e599ab4dc2e92c9240d261c0ab25fbb7 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Fri, 17 Jan 2025 17:43:52 +0300 Subject: [PATCH] Show checkbox on pd declaration page --- .../accounts/pd_declarations/show.html.erb | 8 ++++++ config/locales/en.yml | 1 + test/system/account_pd_declaration_test.rb | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 test/system/account_pd_declaration_test.rb diff --git a/app/views/accounts/pd_declarations/show.html.erb b/app/views/accounts/pd_declarations/show.html.erb index ea8804640..6b8aaa609 100644 --- a/app/views/accounts/pd_declarations/show.html.erb +++ b/app/views/accounts/pd_declarations/show.html.erb @@ -1,3 +1,11 @@ <% content_for :heading do %>

<%= t ".title" %>

<% end %> + +<%= bootstrap_form_tag do |f| %> + <%= f.check_box :consider_pd, + :label => t(".consider_pd"), + :autocomplete => :off, + :checked => current_user.consider_pd, + :disabled => current_user.consider_pd %> +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 861a15003..24d772da4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -327,6 +327,7 @@ en: pd_declarations: show: title: Consider my contributions to be in the Public Domain + consider_pd: "I consider my contributions to be in the Public Domain" browse: deleted_ago_by_html: "Deleted %{time_ago} by %{user}" edited_ago_by_html: "Edited %{time_ago} by %{user}" diff --git a/test/system/account_pd_declaration_test.rb b/test/system/account_pd_declaration_test.rb new file mode 100644 index 000000000..9471c28c1 --- /dev/null +++ b/test/system/account_pd_declaration_test.rb @@ -0,0 +1,26 @@ +require "application_system_test_case" + +class AccountPdDeclarationTest < ApplicationSystemTestCase + def setup + @user = create(:user, :display_name => "test user") + sign_in_as(@user) + end + + test "show checkbox if no declaration was made" do + visit account_pd_declaration_path + + within_content_body do + assert_unchecked_field "I consider my contributions to be in the Public Domain" + end + end + + test "show disabled checkbox if declaration was made" do + @user.update(:consider_pd => true) + + visit account_pd_declaration_path + + within_content_body do + assert_checked_field "I consider my contributions to be in the Public Domain", :disabled => true + end + end +end -- 2.39.5