Remove special sidebar page logic for wiki.

pull/6233/head
Wieland Lindenthal 7 years ago
parent ec6d820eb7
commit caad6495a5
  1. 6
      app/models/wiki.rb
  2. 32
      app/views/wiki/_sidebar.html.erb
  3. 3
      app/views/wiki/date_index.html.erb
  4. 4
      app/views/wiki/index.html.erb
  5. 4
      app/views/wiki/show.html.erb
  6. 11
      spec_legacy/functional/wiki_controller_spec.rb
  7. 19
      spec_legacy/unit/wiki_spec.rb

@ -51,12 +51,6 @@ class Wiki < ActiveRecord::Base
!user.nil? && user.allowed_to?(:view_wiki_pages, project)
end
# Returns the wiki page that acts as the sidebar content
# or nil if no such page exists
def sidebar
@sidebar ||= find_page('Sidebar', with_redirect: false)
end
# find the page with the given title
# if page doesn't exist, return a new page
def find_or_new_page(title)

@ -1,32 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
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-2017 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 docs/COPYRIGHT.rdoc for more details.
++#%>
<% if @wiki && @wiki.sidebar -%>
<%= format_text @wiki.sidebar.content, :text %>
<% end -%>

@ -43,9 +43,6 @@ See docs/COPYRIGHT.rdoc for more details.
<% end %>
</ul>
<% end %>
<% content_for :sidebar do %>
<%= render partial: 'sidebar' %>
<% 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} %>

@ -45,10 +45,6 @@ See docs/COPYRIGHT.rdoc for more details.
<%= render_page_hierarchy(@pages_by_parent_id, nil, timestamp: true) %>
</div>
<% content_for :sidebar do %>
<%= render partial: 'sidebar' %>
<% end %>
<% unless @pages.empty? %>
<%= other_formats_links do |f| %>
<%= f.link_to 'Atom', url: {controller: '/activities', action: 'index', show_wiki_edits: 1, key: User.current.rss_key} %>

@ -153,8 +153,4 @@ See docs/COPYRIGHT.rdoc for more details.
<%= auto_discovery_link_tag(:atom, controller: '/activities', action: 'index', id: @project, show_wiki_edits: 1, format: 'atom', key: User.current.rss_key) %>
<% end %>
<% content_for :sidebar do %>
<%= render partial: 'wiki/sidebar' %>
<% end %>
<% html_title h(@page.title) %>

@ -71,17 +71,6 @@ describe WikiController, type: :controller do
alt: 'This is a logo' }
end
it 'should show with sidebar' do
page = Project.find(1).wiki.pages.new(title: 'Sidebar')
page.content = WikiContent.new(text: 'Side bar content for test_show_with_sidebar')
page.save!
get :show, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_select 'div', attributes: { id: 'sidebar' },
content: /Side bar content for test_show_with_sidebar/
end
it 'should show unexistent page without edit right' do
get :show, params: { project_id: 1, id: 'Unexistent page' }
assert_response 404

@ -61,23 +61,4 @@ describe Wiki, type: :model do
page = FactoryGirl.create(:wiki_page, wiki: wiki, title: '2009\\02\\09')
assert_equal page, wiki.find_page('2009\\02\\09')
end
context '#sidebar' do
before do
@wiki = Wiki.find(1)
end
it 'should return nil if undefined' do
assert_nil @wiki.sidebar
end
it 'should return a WikiPage if defined' do
page = @wiki.pages.new(title: 'Sidebar')
page.content = WikiContent.new(text: 'Side bar content for test_show_with_sidebar')
page.save!
assert_kind_of WikiPage, @wiki.sidebar
assert_equal 'Sidebar', @wiki.sidebar.title
end
end
end

Loading…
Cancel
Save