]> git.openstreetmap.org Git - rails.git/commitdiff
Show checkbox on pd declaration page
authorAnton Khorev <tony29@yandex.ru>
Fri, 17 Jan 2025 14:43:52 +0000 (17:43 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 18 Jan 2025 16:16:17 +0000 (19:16 +0300)
app/views/accounts/pd_declarations/show.html.erb
config/locales/en.yml
test/system/account_pd_declaration_test.rb [new file with mode: 0644]

index ea88046401a0ba24ba2d7b057e637e20ce32a2b4..6b8aaa6096bbdc51bb83fd2de34fbc6caf4f130d 100644 (file)
@@ -1,3 +1,11 @@
 <% content_for :heading do %>
   <h1><%= t ".title" %></h1>
 <% 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 %>
index 861a15003ea291eb0ce79328722d083b18a28f64..24d772da4de10db5f1e67f4105b304cef85b4142 100644 (file)
@@ -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 (file)
index 0000000..9471c28
--- /dev/null
@@ -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