Commit b8c9ad52 authored by Alex Kalderimis's avatar Alex Kalderimis

Add specs for nil page content

parent 6df27e86
......@@ -167,7 +167,11 @@ class Projects::WikisController < Projects::ApplicationController
end
def load_page
@page ||= @project_wiki.find_page(*page_params)
@page ||= find_page
end
def find_page
@project_wiki.find_page(*page_params)
end
def page_params
......
......@@ -200,7 +200,20 @@ describe Projects::WikisController do
subject
expect(response).to redirect_to(project_wiki_path(project, project_wiki.list_pages.first))
expect(response).to redirect_to_wiki(project, project_wiki.list_pages.first)
end
end
context 'when the page has nil content' do
let(:page) { create(:wiki_page) }
it 'redirects to show' do
allow(page).to receive(:content).and_return(nil)
allow(controller).to receive(:find_page).and_return(page)
subject
expect(response).to redirect_to_wiki(project, page)
end
end
......@@ -235,7 +248,7 @@ describe Projects::WikisController do
allow(controller).to receive(:valid_encoding?).and_return(false)
subject
expect(response).to redirect_to(project_wiki_path(project, project_wiki.list_pages.first))
expect(response).to redirect_to_wiki(project, project_wiki.list_pages.first)
end
end
......@@ -265,4 +278,8 @@ describe Projects::WikisController do
page = wiki.page(title: title, dir: dir)
project_wiki.delete_page(page, "test commit")
end
def redirect_to_wiki(project, page)
redirect_to(controller.project_wiki_path(project, page))
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment