removes wiki#date_index which is not linked in the UI

pull/10734/head
ulferts 3 years ago committed by Oliver Günther
parent 8862cdc0fd
commit 80d22e98fa
  1. 12
      app/controllers/wiki_controller.rb
  2. 6
      app/models/wiki_page.rb
  3. 55
      app/views/wiki/date_index.html.erb
  4. 2
      config/initializers/permissions.rb
  5. 1
      config/routes.rb
  6. 6
      spec/routing/wiki_routing_spec.rb
  7. 16
      spec_legacy/functional/wiki_controller_spec.rb
  8. 7
      spec_legacy/unit/wiki_page_spec.rb

@ -79,16 +79,10 @@ class WikiController < ApplicationController
slug = wiki_page_title.nil? ? 'wiki' : WikiPage.slug(wiki_page_title)
@related_page = WikiPage.find_by(wiki_id: @wiki.id, slug: slug)
load_pages_for_index
@pages = @wiki.pages.order(Arel.sql('title')).includes(wiki: :project)
@pages_by_parent_id = @pages.group_by(&:parent_id)
end
# List of page, by last update
def date_index
load_pages_for_index
@pages_by_date = @pages.group_by { |p| p.updated_at.to_date }
end
def new; end
def new_child
@ -423,10 +417,6 @@ class WikiController < ApplicationController
page.editable_by?(User.current)
end
def load_pages_for_index
@pages = @wiki.pages.with_updated_at.order(Arel.sql('title')).includes(wiki: :project)
end
def default_breadcrumb
Wiki.name.humanize
end

@ -69,12 +69,6 @@ class WikiPage < ApplicationRecord
before_save :update_redirects
before_destroy :remove_redirects
# eager load information about last updates, without loading text
scope :with_updated_at, -> {
select("#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_at")
.joins("LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id")
}
scope :main_pages, ->(wiki_id) {
where(wiki_id: wiki_id, parent_id: nil)
}

@ -1,55 +0,0 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2022 the OpenProject GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
<%= toolbar title: t(:label_index_by_date) do %>
<li class="toolbar-item">
<%= watcher_link(@wiki, User.current) %>
</li>
<% end %>
<% if @pages.empty? %>
<%= no_results_box %>
<% end %>
<% @pages_by_date.keys.sort.reverse.each do |date| %>
<h3><%= format_date(date) %></h3>
<ul>
<% @pages_by_date[date].each do |page| %>
<li><%= link_to page.title, project_wiki_path(page.project, page) %></li>
<% end %>
</ul>
<% end %>
<% if @pages.any? %>
<%= other_formats_links do |f| %>
<%= f.link_to 'Atom', url: {controller: '/activities', action: 'index', show_wiki_edits: 1, key: User.current.rss_key} %>
<%= f.link_to('HTML', url: {action: 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
<% end %>
<% end %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, controller: '/activities', action: 'index', id: @project, show_wiki_edits: 1, format: 'atom', key: User.current.rss_key) %>
<% end %>

@ -259,7 +259,7 @@ Rails.application.reloader.to_prepare do
map.project_module :wiki do |wiki|
wiki.permission :view_wiki_pages,
{ wiki: %i[index show special date_index] }
{ wiki: %i[index show special] }
wiki.permission :list_attachments,
{ wiki: :list_attachments },

@ -228,7 +228,6 @@ OpenProject::Application.routes.draw do
collection do
post '/new' => 'wiki#create', as: 'create'
get :export
get :date_index
get '/index' => 'wiki#index'
end

@ -166,12 +166,6 @@ describe WikiController, type: :routing do
project_id: '567')
}
it {
is_expected.to route(:get, '/projects/567/wiki/date_index').to(controller: 'wiki',
action: 'date_index',
project_id: '567')
}
it {
is_expected.to route(:get, '/projects/567/wiki/export').to(controller: 'wiki',
action: 'export',

@ -225,7 +225,6 @@ describe WikiController, type: :controller do
pages = assigns(:pages)
refute_nil pages
assert_equal wiki.pages.size, pages.size
assert_equal pages.first.content.updated_at, pages.first.updated_at
assert_select 'ul', attributes: { class: 'pages-hierarchy' },
child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/CookBook%20documentation' },
@ -270,21 +269,6 @@ describe WikiController, type: :controller do
end
end
context 'GET :date_index' do
before do
get :date_index, params: { project_id: 'ecookbook' }
end
it { is_expected.to respond_with :success }
it { should_assign_to :pages }
it { should_assign_to :pages_by_date }
it { is_expected.to render_template 'wiki/date_index' }
it 'should include atom link' do
assert_select 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' }
end
end
it 'should not found' do
get :show, params: { project_id: 999 }
assert_response 404

@ -111,11 +111,4 @@ describe WikiPage, type: :model do
assert_nil child.parent_id
end
end
it 'should updated on eager load' do
page = WikiPage.with_updated_at.first
assert page.is_a?(WikiPage)
refute_nil page.read_attribute(:updated_at)
assert_equal page.content.updated_at, page.updated_at
end
end

Loading…
Cancel
Save