]> git.openstreetmap.org Git - rails.git/commitdiff
Add empty pd declaration page
authorAnton Khorev <tony29@yandex.ru>
Fri, 17 Jan 2025 14:13:01 +0000 (17:13 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 18 Jan 2025 16:16:17 +0000 (19:16 +0300)
app/abilities/ability.rb
app/controllers/accounts/pd_declarations_controller.rb [new file with mode: 0644]
app/views/accounts/pd_declarations/show.html.erb [new file with mode: 0644]
config/locales/en.yml
config/routes.rb
test/controllers/accounts/pd_declarations_controller_test.rb [new file with mode: 0644]

index e31e3e930cc8ed60368b85c94fc73318756491a7..44b0ba93d2af8d402b9316f6eabcafe81172bced 100644 (file)
@@ -29,7 +29,7 @@ class Ability
 
     if user&.active?
       can :welcome, :site
-      can :read, [:deletion, :account_terms]
+      can :read, [:deletion, :account_terms, :account_pd_declaration]
 
       if Settings.status != "database_offline"
         can [:subscribe, :unsubscribe], Changeset
diff --git a/app/controllers/accounts/pd_declarations_controller.rb b/app/controllers/accounts/pd_declarations_controller.rb
new file mode 100644 (file)
index 0000000..3d90d25
--- /dev/null
@@ -0,0 +1,12 @@
+module Accounts
+  class PdDeclarationsController < ApplicationController
+    layout "site"
+
+    before_action :authorize_web
+    before_action :set_locale
+
+    authorize_resource :class => :account_pd_declaration
+
+    def show; end
+  end
+end
diff --git a/app/views/accounts/pd_declarations/show.html.erb b/app/views/accounts/pd_declarations/show.html.erb
new file mode 100644 (file)
index 0000000..ea88046
--- /dev/null
@@ -0,0 +1,3 @@
+<% content_for :heading do %>
+  <h1><%= t ".title" %></h1>
+<% end %>
index a112f3b0dee17d495fc794888118f392c0b76b39..861a15003ea291eb0ce79328722d083b18a28f64 100644 (file)
@@ -324,6 +324,9 @@ en:
         terms_declined_html: We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see %{terms_declined_link}.
         terms_declined_link: this wiki page
         terms_declined_url: https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined
+    pd_declarations:
+      show:
+        title: 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}"
index 9e82a037dafea8d95c3c25a6ee4597ea1e6a888d..4172069b9396e03f83f8a7461d9effa9992ce1f3 100644 (file)
@@ -279,6 +279,7 @@ OpenStreetMap::Application.routes.draw do
   resource :account, :only => [:edit, :update, :destroy] do
     scope :module => :accounts do
       resource :terms, :only => [:show, :update]
+      resource :pd_declaration, :only => :show
       resource :deletion, :only => :show
     end
   end
diff --git a/test/controllers/accounts/pd_declarations_controller_test.rb b/test/controllers/accounts/pd_declarations_controller_test.rb
new file mode 100644 (file)
index 0000000..4b961e3
--- /dev/null
@@ -0,0 +1,29 @@
+require "test_helper"
+
+module Accounts
+  class PdDeclarationsControllerTest < ActionDispatch::IntegrationTest
+    ##
+    # test all routes which lead to this controller
+    def test_routes
+      assert_routing(
+        { :path => "/account/pd_declaration", :method => :get },
+        { :controller => "accounts/pd_declarations", :action => "show" }
+      )
+    end
+
+    def test_show_not_logged_in
+      get account_pd_declaration_path
+
+      assert_redirected_to login_path(:referer => account_pd_declaration_path)
+    end
+
+    def test_show_agreed
+      user = create(:user)
+      session_for(user)
+
+      get account_pd_declaration_path
+
+      assert_response :success
+    end
+  end
+end