Fix wiki controller item specs

pull/4809/head
Oliver Günther 8 years ago
parent 5c8056cbee
commit 6a91e4a32a
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      app/controllers/wiki_controller.rb
  2. 3
      spec/controllers/wiki_controller_spec.rb
  3. 1
      spec/support/matchers/have_exactly_one_selected_menu_item_in.rb

@ -79,7 +79,8 @@ class WikiController < ApplicationController
# List of pages, sorted alphabetically and by parent (hierarchy)
def index
@related_page = WikiPage.find_by(wiki_id: @wiki.id, title: wiki_page_title)
slug = wiki_page_title.nil? ? 'wiki' : wiki_page_title.to_url
@related_page = WikiPage.find_by(wiki_id: @wiki.id, slug: slug)
load_pages_for_index
@pages_by_parent_id = @pages.group_by(&:parent_id)

@ -261,7 +261,7 @@ describe WikiController, type: :controller do
before do
@main_menu_item_for_page_with_content = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id,
title: 'Item for Page with Content',
name: 'page-with-content')
name: @page_with_content.slug)
@main_menu_item_for_new_wiki_page = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id,
title: 'Item for new WikiPage',
@ -318,7 +318,6 @@ describe WikiController, type: :controller do
get 'index', id: @wiki_menu_item.name, project_id: @project.id
expect(response).to be_success
binding.pry
assert_select '#content h2', text: 'Index by title'
assert_select "#main-menu a.#{@wiki_menu_item.name}-menu-item.selected"

@ -52,7 +52,6 @@ RSpec::Matchers.define :have_exactly_one_selected_menu_item_in do |menu|
menu_matches = menu_selector.select(html.root)
if menu_matches.size == 1
menu_item_matches = menu_item_selector.select(menu_matches.first)
if menu_item_matches.size == 0
"Expected to find exactly one selected menu item in #{menu}, but found none."
elsif menu_item_matches.size > 1

Loading…
Cancel
Save