Skip to content

Commit 55becdb

Browse files
committed
wip
1 parent 8590c07 commit 55becdb

4 files changed

Lines changed: 122 additions & 0 deletions

File tree

app/views/work_packages/show.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ See COPYRIGHT and LICENSE files for more details.
3737
<%= auto_discovery_link_tag(:atom,
3838
{ format: 'atom', key: User.current.rss_key },
3939
title: "#{work_package.project} - #{work_package.to_s}") %>
40+
<%= tag.link rel: :canonical, href: project_work_package_url(work_package.project_id, work_package.id) %>
4041
<% end %>
4142

4243
<% content_for :content_body do %>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
<% content_for :header_tags do %>
2+
<%= tag.link rel: :canonical, href: project_overview_url(@project.id) %>
3+
<% end %>
4+
15
<%= render(Overviews::PageHeaderComponent.new(project: @project, current_user:)) %>
26
<%= render(Overviews::ShowComponent.new(project: @project, current_user:)) %>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
require "rails_helper"
32+
33+
RSpec.describe "GET project overview", type: :rails_request do
34+
let(:project) { create(:project) }
35+
36+
current_user { create(:admin) }
37+
38+
shared_examples "includes canonical link tag" do
39+
it "renders a canonical link tag pointing to the numeric-ID project URL" do
40+
expect(response).to have_http_status(:ok)
41+
expect(response.body).to include(%(<link rel="canonical" href="http://test.host/projects/#{project.id}">))
42+
end
43+
end
44+
45+
context "when accessed via the numeric ID" do
46+
before { get "/projects/#{project.id}" }
47+
48+
include_examples "includes canonical link tag"
49+
end
50+
51+
context "when accessed via the string identifier" do
52+
before { get "/projects/#{project.identifier}" }
53+
54+
include_examples "includes canonical link tag"
55+
end
56+
end
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
require "rails_helper"
32+
33+
RSpec.describe "GET work package show", type: :rails_request do
34+
let(:project) { create(:project) }
35+
let(:work_package) { create(:work_package, project:) }
36+
37+
current_user { create(:user, member_with_permissions: { project => %i[view_work_packages] }) }
38+
39+
shared_examples "includes canonical link tag" do
40+
it "renders a canonical link tag pointing to the project-scoped DB-ID URL" do
41+
expect(response).to have_http_status(:ok)
42+
expected_path = "/projects/#{project.id}/work_packages/#{work_package.id}"
43+
expect(response.body).to include(%(<link rel="canonical" href="http://test.host#{expected_path}">))
44+
end
45+
end
46+
47+
context "when accessed via the project-scoped URL" do
48+
before { get "/projects/#{project.id}/work_packages/#{work_package.id}/activity" }
49+
50+
include_examples "includes canonical link tag"
51+
end
52+
53+
context "when accessed via the global URL" do
54+
before do
55+
get "/work_packages/#{work_package.id}/activity"
56+
follow_redirect!
57+
end
58+
59+
include_examples "includes canonical link tag"
60+
end
61+
end

0 commit comments

Comments
 (0)