|
|
@ -31,30 +31,31 @@ require 'spec_helper' |
|
|
|
describe WikiController, type: :controller do |
|
|
|
describe WikiController, type: :controller do |
|
|
|
shared_let(:admin) { FactoryBot.create :admin } |
|
|
|
shared_let(:admin) { FactoryBot.create :admin } |
|
|
|
|
|
|
|
|
|
|
|
describe 'actions' do |
|
|
|
shared_let(:project) do |
|
|
|
before do |
|
|
|
FactoryBot.create(:project).tap(&:reload) |
|
|
|
allow(@controller).to receive(:set_localization) |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@role = FactoryBot.create(:non_member) |
|
|
|
shared_let(:existing_page) do |
|
|
|
login_as admin |
|
|
|
FactoryBot.create(:wiki_page, wiki_id: project.wiki.id, title: 'ExistingPage') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@project = FactoryBot.create(:project) |
|
|
|
shared_let(:existing_content) do |
|
|
|
@project.reload # to get the wiki into the proxy |
|
|
|
# creating page contents |
|
|
|
|
|
|
|
FactoryBot.create(:wiki_content, page_id: existing_page.id, author_id: admin.id) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# creating pages |
|
|
|
|
|
|
|
@existing_page = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, |
|
|
|
|
|
|
|
title: 'ExistingPage') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# creating page contents |
|
|
|
describe 'actions' do |
|
|
|
FactoryBot.create(:wiki_content, page_id: @existing_page.id, |
|
|
|
before do |
|
|
|
author_id: admin.id) |
|
|
|
allow(controller).to receive(:set_localization) |
|
|
|
|
|
|
|
login_as admin |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
shared_examples_for "a 'new' action" do |
|
|
|
shared_examples_for "a 'new' action" do |
|
|
|
it 'assigns @project to the current project' do |
|
|
|
it 'assigns @project to the current project' do |
|
|
|
get_page |
|
|
|
get_page |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:project]).to eq(@project) |
|
|
|
expect(assigns[:project]).to eq(project) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @page to a newly created wiki page' do |
|
|
|
it 'assigns @page to a newly created wiki page' do |
|
|
@ -62,7 +63,7 @@ describe WikiController, type: :controller do |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:page]).to be_new_record |
|
|
|
expect(assigns[:page]).to be_new_record |
|
|
|
expect(assigns[:page]).to be_kind_of WikiPage |
|
|
|
expect(assigns[:page]).to be_kind_of WikiPage |
|
|
|
expect(assigns[:page].wiki).to eq(@project.wiki) |
|
|
|
expect(assigns[:page].wiki).to eq(project.wiki) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns @content to a newly created wiki content' do |
|
|
|
it 'assigns @content to a newly created wiki content' do |
|
|
@ -81,35 +82,35 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe 'new' do |
|
|
|
describe 'new' do |
|
|
|
let(:get_page) { get 'new', params: { project_id: @project } } |
|
|
|
let(:get_page) { get 'new', params: { project_id: project } } |
|
|
|
|
|
|
|
|
|
|
|
it_should_behave_like "a 'new' action" |
|
|
|
it_should_behave_like "a 'new' action" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe 'new_child' do |
|
|
|
describe 'new_child' do |
|
|
|
let(:get_page) { get 'new_child', params: { project_id: @project, id: @existing_page.title } } |
|
|
|
let(:get_page) { get 'new_child', params: { project_id: project, id: existing_page.title } } |
|
|
|
|
|
|
|
|
|
|
|
it_should_behave_like "a 'new' action" |
|
|
|
it_should_behave_like "a 'new' action" |
|
|
|
|
|
|
|
|
|
|
|
it 'sets the parent page for the new page' do |
|
|
|
it 'sets the parent page for the new page' do |
|
|
|
get_page |
|
|
|
get_page |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:page].parent).to eq(@existing_page) |
|
|
|
expect(assigns[:page].parent).to eq(existing_page) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'renders 404 if used with an unknown page title' do |
|
|
|
it 'renders 404 if used with an unknown page title' do |
|
|
|
get 'new_child', params: { project_id: @project, id: 'foobar' } |
|
|
|
get 'new_child', params: { project_id: project, id: 'foobar' } |
|
|
|
|
|
|
|
|
|
|
|
expect(response.status).to eq(404) # not found |
|
|
|
expect(response.status).to eq(404) # not found |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe 'show' do |
|
|
|
describe 'show' do |
|
|
|
let(:get_page) { get :show, params: { project_id: @project, id: 'wiki' } } |
|
|
|
let(:get_page) { get :show, params: { project_id: project, id: 'wiki' } } |
|
|
|
|
|
|
|
|
|
|
|
describe 'with an empty wiki and no permission to edit' do |
|
|
|
describe 'with an empty wiki and no permission to edit' do |
|
|
|
let(:view_role) { FactoryBot.create :role, permissions: %w[view_wiki_pages] } |
|
|
|
let(:view_role) { FactoryBot.create :role, permissions: %w[view_wiki_pages] } |
|
|
|
let(:user) { FactoryBot.create(:user, member_in_project: @project, member_through_role: view_role) } |
|
|
|
let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: view_role) } |
|
|
|
|
|
|
|
|
|
|
|
it 'visiting the start page redirects to index' do |
|
|
|
it 'visiting the start page redirects to index' do |
|
|
|
login_as user |
|
|
|
login_as user |
|
|
@ -122,7 +123,7 @@ describe WikiController, type: :controller do |
|
|
|
|
|
|
|
|
|
|
|
describe 'edit' do |
|
|
|
describe 'edit' do |
|
|
|
it 'will link to a parent page if it was set' do |
|
|
|
it 'will link to a parent page if it was set' do |
|
|
|
get 'edit', params: { project_id: @project, id: 'foobar' }, flash: { _related_wiki_page_id: 1234 } |
|
|
|
get 'edit', params: { project_id: project, id: 'foobar' }, flash: { _related_wiki_page_id: 1234 } |
|
|
|
|
|
|
|
|
|
|
|
page = assigns[:page] |
|
|
|
page = assigns[:page] |
|
|
|
expect(page.parent_id).to eq 1234 |
|
|
|
expect(page.parent_id).to eq 1234 |
|
|
@ -134,21 +135,21 @@ describe WikiController, type: :controller do |
|
|
|
it 'redirects to the show action' do |
|
|
|
it 'redirects to the show action' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: 'abc' } } |
|
|
|
content: { text: 'h1. abc', page: { title: 'abc' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to action: 'show', project_id: @project, id: 'abc' |
|
|
|
expect(response).to redirect_to action: 'show', project_id: project, id: 'abc' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'saves a new WikiPage with proper content' do |
|
|
|
it 'saves a new WikiPage with proper content' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: 'abc' } } |
|
|
|
content: { text: 'h1. abc', page: { title: 'abc' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
page = @project.wiki.pages.find_by title: 'abc' |
|
|
|
page = project.wiki.pages.find_by title: 'abc' |
|
|
|
expect(page).not_to be_nil |
|
|
|
expect(page).not_to be_nil |
|
|
|
expect(page.content.text).to eq('h1. abc') |
|
|
|
expect(page.content.text).to eq('h1. abc') |
|
|
|
end |
|
|
|
end |
|
|
@ -158,7 +159,7 @@ describe WikiController, type: :controller do |
|
|
|
it 'renders "wiki/new"' do |
|
|
|
it 'renders "wiki/new"' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,33 +169,33 @@ describe WikiController, type: :controller do |
|
|
|
it 'assigns project to work with new template' do |
|
|
|
it 'assigns project to work with new template' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:project]).to eq(@project) |
|
|
|
expect(assigns[:project]).to eq(project) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns wiki to work with new template' do |
|
|
|
it 'assigns wiki to work with new template' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:wiki]).to eq(@project.wiki) |
|
|
|
expect(assigns[:wiki]).to eq(project.wiki) |
|
|
|
expect(assigns[:wiki]).not_to be_new_record |
|
|
|
expect(assigns[:wiki]).not_to be_new_record |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'assigns page to work with new template' do |
|
|
|
it 'assigns page to work with new template' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:page]).to be_new_record |
|
|
|
expect(assigns[:page]).to be_new_record |
|
|
|
expect(assigns[:page].wiki.project).to eq(@project) |
|
|
|
expect(assigns[:page].wiki.project).to eq(project) |
|
|
|
expect(assigns[:page].title).to eq('') |
|
|
|
expect(assigns[:page].title).to eq('') |
|
|
|
expect(assigns[:page]).not_to be_valid |
|
|
|
expect(assigns[:page]).not_to be_valid |
|
|
|
end |
|
|
|
end |
|
|
@ -202,21 +203,40 @@ describe WikiController, type: :controller do |
|
|
|
it 'assigns content to work with new template' do |
|
|
|
it 'assigns content to work with new template' do |
|
|
|
post 'create', |
|
|
|
post 'create', |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
project_id: @project, |
|
|
|
project_id: project, |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
content: { text: 'h1. abc', page: { title: '' } } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
expect(assigns[:content]).to be_new_record |
|
|
|
expect(assigns[:content]).to be_new_record |
|
|
|
expect(assigns[:content].page.wiki.project).to eq(@project) |
|
|
|
expect(assigns[:content].page.wiki.project).to eq(project) |
|
|
|
expect(assigns[:content].text).to eq('h1. abc') |
|
|
|
expect(assigns[:content].text).to eq('h1. abc') |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'update' do |
|
|
|
|
|
|
|
context 'when the page is locked' do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
existing_page.update!(protected: true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'redirects to the show action' do |
|
|
|
|
|
|
|
post 'update', |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
project_id: project, |
|
|
|
|
|
|
|
id: existing_page.title, |
|
|
|
|
|
|
|
content: { text: 'h1. abc', page: { title: 'foobar' } } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(response).to redirect_to action: 'show', project_id: project, id: 'foobar' |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe 'destroy' do |
|
|
|
describe 'destroy' do |
|
|
|
describe 'successful action' do |
|
|
|
describe 'successful action' do |
|
|
|
context 'when it is not the only wiki page' do |
|
|
|
context 'when it is not the only wiki page' do |
|
|
|
let(:wiki) { @project.wiki } |
|
|
|
let(:wiki) { project.wiki } |
|
|
|
let(:redirect_page_after_destroy) { wiki.find_page(wiki.start_page) || wiki.pages.first } |
|
|
|
let(:redirect_page_after_destroy) { wiki.find_page(wiki.start_page) || wiki.pages.first } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
@ -224,15 +244,15 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'redirects to wiki#index' do |
|
|
|
it 'redirects to wiki#index' do |
|
|
|
delete :destroy, params: { project_id: @project, id: @existing_page } |
|
|
|
delete :destroy, params: { project_id: project, id: existing_page } |
|
|
|
expect(response).to redirect_to action: 'index', project_id: @project, id: redirect_page_after_destroy |
|
|
|
expect(response).to redirect_to action: 'index', project_id: project, id: redirect_page_after_destroy |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context 'when it is the only wiki page' do |
|
|
|
context 'when it is the only wiki page' do |
|
|
|
it 'redirects to projects#show' do |
|
|
|
it 'redirects to projects#show' do |
|
|
|
delete :destroy, params: { project_id: @project, id: @existing_page } |
|
|
|
delete :destroy, params: { project_id: project, id: existing_page } |
|
|
|
expect(response).to redirect_to project_path(@project) |
|
|
|
expect(response).to redirect_to project_path(project) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -242,6 +262,10 @@ describe WikiController, type: :controller do |
|
|
|
describe 'view related stuff' do |
|
|
|
describe 'view related stuff' do |
|
|
|
render_views |
|
|
|
render_views |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared_let(:project) do |
|
|
|
|
|
|
|
FactoryBot.create(:public_project).tap(&:reload) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
before :each do |
|
|
|
before :each do |
|
|
|
allow(@controller).to receive(:set_localization) |
|
|
|
allow(@controller).to receive(:set_localization) |
|
|
|
allow(Setting).to receive(:login_required?).and_return(false) |
|
|
|
allow(Setting).to receive(:login_required?).and_return(false) |
|
|
@ -255,21 +279,18 @@ describe WikiController, type: :controller do |
|
|
|
|
|
|
|
|
|
|
|
allow(User).to receive(:current).and_return admin |
|
|
|
allow(User).to receive(:current).and_return admin |
|
|
|
|
|
|
|
|
|
|
|
@project = FactoryBot.create(:public_project) |
|
|
|
|
|
|
|
@project.reload # to get the wiki into the proxy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# creating pages |
|
|
|
# creating pages |
|
|
|
@page_default = FactoryBot.create(:wiki_page, |
|
|
|
@page_default = FactoryBot.create(:wiki_page, |
|
|
|
wiki_id: @project.wiki.id, |
|
|
|
wiki_id: project.wiki.id, |
|
|
|
title: 'Wiki') |
|
|
|
title: 'Wiki') |
|
|
|
@page_with_content = FactoryBot.create(:wiki_page, |
|
|
|
@page_with_content = FactoryBot.create(:wiki_page, |
|
|
|
wiki_id: @project.wiki.id, |
|
|
|
wiki_id: project.wiki.id, |
|
|
|
title: 'PagewithContent') |
|
|
|
title: 'PagewithContent') |
|
|
|
@page_without_content = FactoryBot.create(:wiki_page, |
|
|
|
@page_without_content = FactoryBot.create(:wiki_page, |
|
|
|
wiki_id: @project.wiki.id, |
|
|
|
wiki_id: project.wiki.id, |
|
|
|
title: 'PagewithoutContent') |
|
|
|
title: 'PagewithoutContent') |
|
|
|
@unrelated_page = FactoryBot.create(:wiki_page, |
|
|
|
@unrelated_page = FactoryBot.create(:wiki_page, |
|
|
|
wiki_id: @project.wiki.id, |
|
|
|
wiki_id: project.wiki.id, |
|
|
|
title: 'UnrelatedPage') |
|
|
|
title: 'UnrelatedPage') |
|
|
|
|
|
|
|
|
|
|
|
# creating page contents |
|
|
|
# creating page contents |
|
|
@ -283,7 +304,7 @@ describe WikiController, type: :controller do |
|
|
|
# creating some child pages |
|
|
|
# creating some child pages |
|
|
|
@children = {} |
|
|
|
@children = {} |
|
|
|
[@page_with_content].each do |page| |
|
|
|
[@page_with_content].each do |page| |
|
|
|
child_page = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, |
|
|
|
child_page = FactoryBot.create(:wiki_page, wiki_id: project.wiki.id, |
|
|
|
parent_id: page.id, |
|
|
|
parent_id: page.id, |
|
|
|
title: page.title + ' child') |
|
|
|
title: page.title + ' child') |
|
|
|
FactoryBot.create(:wiki_content, page_id: child_page.id, |
|
|
|
FactoryBot.create(:wiki_content, page_id: child_page.id, |
|
|
@ -296,24 +317,24 @@ describe WikiController, type: :controller do |
|
|
|
describe '- main menu links' do |
|
|
|
describe '- main menu links' do |
|
|
|
before do |
|
|
|
before do |
|
|
|
@main_menu_item_for_page_with_content = FactoryBot.create(:wiki_menu_item, |
|
|
|
@main_menu_item_for_page_with_content = FactoryBot.create(:wiki_menu_item, |
|
|
|
navigatable_id: @project.wiki.id, |
|
|
|
navigatable_id: project.wiki.id, |
|
|
|
title: 'Item for Page with Content', |
|
|
|
title: 'Item for Page with Content', |
|
|
|
name: @page_with_content.slug) |
|
|
|
name: @page_with_content.slug) |
|
|
|
|
|
|
|
|
|
|
|
@main_menu_item_for_new_wiki_page = FactoryBot.create(:wiki_menu_item, |
|
|
|
@main_menu_item_for_new_wiki_page = FactoryBot.create(:wiki_menu_item, |
|
|
|
navigatable_id: @project.wiki.id, |
|
|
|
navigatable_id: project.wiki.id, |
|
|
|
title: 'Item for new WikiPage', |
|
|
|
title: 'Item for new WikiPage', |
|
|
|
name: 'new-wiki-page') |
|
|
|
name: 'new-wiki-page') |
|
|
|
|
|
|
|
|
|
|
|
@other_menu_item = FactoryBot.create(:wiki_menu_item, |
|
|
|
@other_menu_item = FactoryBot.create(:wiki_menu_item, |
|
|
|
navigatable_id: @project.wiki.id, |
|
|
|
navigatable_id: project.wiki.id, |
|
|
|
title: 'Item for other page', |
|
|
|
title: 'Item for other page', |
|
|
|
name: @unrelated_page.slug) |
|
|
|
name: @unrelated_page.slug) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
shared_examples_for 'all wiki menu items' do |
|
|
|
shared_examples_for 'all wiki menu items' do |
|
|
|
it 'is inactive, when an unrelated page is shown' do |
|
|
|
it 'is inactive, when an unrelated page is shown' do |
|
|
|
get 'show', params: { id: @unrelated_page.slug, project_id: @project.id } |
|
|
|
get 'show', params: { id: @unrelated_page.slug, project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -322,7 +343,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "is inactive, when another wiki menu item's page is shown" do |
|
|
|
it "is inactive, when another wiki menu item's page is shown" do |
|
|
|
get 'show', params: { id: @other_wiki_menu_item.name, project_id: @project.id } |
|
|
|
get 'show', params: { id: @other_wiki_menu_item.name, project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
expect(response.body).to have_selector('.main-menu--children a.selected', count: 0) |
|
|
|
expect(response.body).to have_selector('.main-menu--children a.selected', count: 0) |
|
|
@ -332,7 +353,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is active, when the given wiki menu item is shown' do |
|
|
|
it 'is active, when the given wiki menu item is shown' do |
|
|
|
get 'show', params: { id: @wiki_menu_item.name, project_id: @project.id } |
|
|
|
get 'show', params: { id: @wiki_menu_item.name, project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -343,7 +364,7 @@ describe WikiController, type: :controller do |
|
|
|
shared_examples_for 'all existing wiki menu items' do |
|
|
|
shared_examples_for 'all existing wiki menu items' do |
|
|
|
# TODO: Add tests for new and toc options within menu item |
|
|
|
# TODO: Add tests for new and toc options within menu item |
|
|
|
it 'is active on parents item, when new page is shown' do |
|
|
|
it 'is active on parents item, when new page is shown' do |
|
|
|
get 'new_child', params: { id: @wiki_menu_item.name, project_id: @project.identifier } |
|
|
|
get 'new_child', params: { id: @wiki_menu_item.name, project_id: project.identifier } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -351,7 +372,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is active, when a toc page is shown' do |
|
|
|
it 'is active, when a toc page is shown' do |
|
|
|
get 'index', params: { id: @wiki_menu_item.name, project_id: @project.id } |
|
|
|
get 'index', params: { id: @wiki_menu_item.name, project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
assert_select '#content h2', text: 'Table of Contents' |
|
|
|
assert_select '#content h2', text: 'Table of Contents' |
|
|
@ -361,7 +382,7 @@ describe WikiController, type: :controller do |
|
|
|
|
|
|
|
|
|
|
|
shared_examples_for 'all wiki menu items with child pages' do |
|
|
|
shared_examples_for 'all wiki menu items with child pages' do |
|
|
|
it 'is active, when the given wiki menu item is an ancestor of the shown page' do |
|
|
|
it 'is active, when the given wiki menu item is an ancestor of the shown page' do |
|
|
|
get 'show', params: { id: @child_page.slug, project_id: @project.id } |
|
|
|
get 'show', params: { id: @child_page.slug, project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
expect(response.body).to have_selector('#main-menu a.selected', count: 1) |
|
|
|
expect(response.body).to have_selector('#main-menu a.selected', count: 1) |
|
|
@ -394,7 +415,7 @@ describe WikiController, type: :controller do |
|
|
|
describe '- wiki_menu_item containing special chars only' do |
|
|
|
describe '- wiki_menu_item containing special chars only' do |
|
|
|
before do |
|
|
|
before do |
|
|
|
@wiki_menu_item = FactoryBot.create(:wiki_menu_item, |
|
|
|
@wiki_menu_item = FactoryBot.create(:wiki_menu_item, |
|
|
|
navigatable_id: @project.wiki.id, |
|
|
|
navigatable_id: project.wiki.id, |
|
|
|
title: '?', |
|
|
|
title: '?', |
|
|
|
name: 'help') |
|
|
|
name: 'help') |
|
|
|
@other_wiki_menu_item = @other_menu_item |
|
|
|
@other_wiki_menu_item = @other_menu_item |
|
|
@ -409,7 +430,7 @@ describe WikiController, type: :controller do |
|
|
|
describe 'on a show page' do |
|
|
|
describe 'on a show page' do |
|
|
|
describe 'being authorized to configure menu items' do |
|
|
|
describe 'being authorized to configure menu items' do |
|
|
|
it 'is visible' do |
|
|
|
it 'is visible' do |
|
|
|
get 'show', params: { project_id: @project.id } |
|
|
|
get 'show', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -423,7 +444,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'show', params: { project_id: @project.id } |
|
|
|
get 'show', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -437,7 +458,7 @@ describe WikiController, type: :controller do |
|
|
|
describe 'on an index page' do |
|
|
|
describe 'on an index page' do |
|
|
|
describe 'being authorized to edit wiki pages' do |
|
|
|
describe 'being authorized to edit wiki pages' do |
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'index', params: { project_id: @project.id } |
|
|
|
get 'index', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -451,7 +472,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'index', params: { project_id: @project.id } |
|
|
|
get 'index', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -465,14 +486,14 @@ describe WikiController, type: :controller do |
|
|
|
describe 'with a wiki page present' do |
|
|
|
describe 'with a wiki page present' do |
|
|
|
it 'is visible' do |
|
|
|
it 'is visible' do |
|
|
|
get 'show', |
|
|
|
get 'show', |
|
|
|
params: { id: @page_with_content.title, project_id: @project.identifier } |
|
|
|
params: { id: @page_with_content.title, project_id: project.identifier } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
|
# Expect to set back ref id |
|
|
|
# Expect to set back ref id |
|
|
|
expect(flash[:_related_wiki_page_id]).to eq @page_with_content.id |
|
|
|
expect(flash[:_related_wiki_page_id]).to eq @page_with_content.id |
|
|
|
|
|
|
|
|
|
|
|
path = new_child_project_wiki_path(project_id: @project, id: @page_with_content.slug) |
|
|
|
path = new_child_project_wiki_path(project_id: project, id: @page_with_content.slug) |
|
|
|
|
|
|
|
|
|
|
|
assert_select "#content a[href='#{path}']", 'Wiki page' |
|
|
|
assert_select "#content a[href='#{path}']", 'Wiki page' |
|
|
|
end |
|
|
|
end |
|
|
@ -480,11 +501,11 @@ describe WikiController, type: :controller do |
|
|
|
|
|
|
|
|
|
|
|
describe 'with no wiki page present' do |
|
|
|
describe 'with no wiki page present' do |
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'show', params: { id: 'i-am-a-ghostpage', project_id: @project.identifier } |
|
|
|
get 'show', params: { id: 'i-am-a-ghostpage', project_id: project.identifier } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
|
assert_select "#content a[href='#{new_child_project_wiki_path(project_id: @project, id: 'i-am-a-ghostpage')}']", |
|
|
|
assert_select "#content a[href='#{new_child_project_wiki_path(project_id: project, id: 'i-am-a-ghostpage')}']", |
|
|
|
text: 'Wiki page', count: 0 |
|
|
|
text: 'Wiki page', count: 0 |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -496,7 +517,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'show', params: { id: @page_with_content.title, project_id: @project.identifier } |
|
|
|
get 'show', params: { id: @page_with_content.title, project_id: project.identifier } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
@ -510,11 +531,11 @@ describe WikiController, type: :controller do |
|
|
|
describe 'on a show page' do |
|
|
|
describe 'on a show page' do |
|
|
|
describe 'being authorized to edit wiki pages' do |
|
|
|
describe 'being authorized to edit wiki pages' do |
|
|
|
it 'is visible' do |
|
|
|
it 'is visible' do |
|
|
|
get 'show', params: { project_id: @project.id } |
|
|
|
get 'show', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
|
assert_select ".toolbar-items a[href='#{new_child_project_wiki_path(project_id: @project, id: 'wiki')}']", |
|
|
|
assert_select ".toolbar-items a[href='#{new_child_project_wiki_path(project_id: project, id: 'wiki')}']", |
|
|
|
'Wiki page' |
|
|
|
'Wiki page' |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -525,7 +546,7 @@ describe WikiController, type: :controller do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'is invisible' do |
|
|
|
it 'is invisible' do |
|
|
|
get 'show', params: { project_id: @project.id } |
|
|
|
get 'show', params: { project_id: project.id } |
|
|
|
|
|
|
|
|
|
|
|
expect(response).to be_successful |
|
|
|
expect(response).to be_successful |
|
|
|
|
|
|
|
|
|
|
|