From: Anton Khorev Date: Fri, 17 Jan 2025 14:13:01 +0000 (+0300) Subject: Add empty pd declaration page X-Git-Tag: live~176^2~9 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/62b70f45bc2566d3ca3c0d79c72da7d46d5f49a4 Add empty pd declaration page --- diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index e31e3e930..44b0ba93d 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -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 index 000000000..3d90d250e --- /dev/null +++ b/app/controllers/accounts/pd_declarations_controller.rb @@ -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 index 000000000..ea8804640 --- /dev/null +++ b/app/views/accounts/pd_declarations/show.html.erb @@ -0,0 +1,3 @@ +<% content_for :heading do %> +

<%= t ".title" %>

+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a112f3b0d..861a15003 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}" diff --git a/config/routes.rb b/config/routes.rb index 9e82a037d..4172069b9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 index 000000000..4b961e326 --- /dev/null +++ b/test/controllers/accounts/pd_declarations_controller_test.rb @@ -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