Commit 206a15d7 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fj-removing-disable-gitaly-flags' into 'master'

Removing gitaly flags

See merge request gitlab-org/gitlab-ce!16953
parents 683984f2 d40912bb
...@@ -25,9 +25,8 @@ module Gitlab ...@@ -25,9 +25,8 @@ module Gitlab
@repository.exists? @repository.exists?
end end
# Disabled because of https://gitlab.com/gitlab-org/gitaly/merge_requests/539
def write_page(name, format, content, commit_details) def write_page(name, format, content, commit_details)
@repository.gitaly_migrate(:wiki_write_page, status: Gitlab::GitalyClient::MigrationStatus::DISABLED) do |is_enabled| @repository.gitaly_migrate(:wiki_write_page) do |is_enabled|
if is_enabled if is_enabled
gitaly_write_page(name, format, content, commit_details) gitaly_write_page(name, format, content, commit_details)
gollum_wiki.clear_cache gollum_wiki.clear_cache
...@@ -48,9 +47,8 @@ module Gitlab ...@@ -48,9 +47,8 @@ module Gitlab
end end
end end
# Disable because of https://gitlab.com/gitlab-org/gitlab-ce/issues/42094
def update_page(page_path, title, format, content, commit_details) def update_page(page_path, title, format, content, commit_details)
@repository.gitaly_migrate(:wiki_update_page, status: Gitlab::GitalyClient::MigrationStatus::DISABLED) do |is_enabled| @repository.gitaly_migrate(:wiki_update_page) do |is_enabled|
if is_enabled if is_enabled
gitaly_update_page(page_path, title, format, content, commit_details) gitaly_update_page(page_path, title, format, content, commit_details)
gollum_wiki.clear_cache gollum_wiki.clear_cache
......
require 'spec_helper' require 'spec_helper'
# Remove skip_gitaly_mock flag when gitaly_update_page implements moving pages describe 'User views a wiki page' do
describe 'User views a wiki page', :skip_gitaly_mock do shared_examples 'wiki page user view' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
let(:wiki_page) do let(:wiki_page) do
create(:wiki_page, create(:wiki_page,
wiki: project.wiki, wiki: project.wiki,
attrs: { title: 'home', content: 'Look at this [image](image.jpg)\n\n ![alt text](image.jpg)' }) attrs: { title: 'home', content: 'Look at this [image](image.jpg)\n\n ![alt text](image.jpg)' })
end end
before do
project.add_master(user)
sign_in(user)
end
context 'when wiki is empty' do
before do before do
visit(project_wikis_path(project)) project.add_master(user)
sign_in(user)
end
click_on('New page') context 'when wiki is empty' do
before do
visit(project_wikis_path(project))
page.within('#modal-new-wiki') do click_on('New page')
fill_in(:new_wiki_path, with: 'one/two/three-test')
click_on('Create page')
end
page.within('.wiki-form') do page.within('#modal-new-wiki') do
fill_in(:wiki_content, with: 'wiki content') fill_in(:new_wiki_path, with: 'one/two/three-test')
click_on('Create page') click_on('Create page')
end
page.within('.wiki-form') do
fill_in(:wiki_content, with: 'wiki content')
click_on('Create page')
end
end end
end
it 'shows the history of a page that has a path', :js do it 'shows the history of a page that has a path', :js do
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
first(:link, text: 'Three').click first(:link, text: 'Three').click
click_on('Page history') click_on('Page history')
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
page.within(:css, '.nav-text') do page.within(:css, '.nav-text') do
expect(page).to have_content('History') expect(page).to have_content('History')
end
end end
end
it 'shows an old version of a page', :js do it 'shows an old version of a page', :js do
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
expect(find('.wiki-pages')).to have_content('Three') expect(find('.wiki-pages')).to have_content('Three')
first(:link, text: 'Three').click first(:link, text: 'Three').click
expect(find('.nav-text')).to have_content('Three') expect(find('.nav-text')).to have_content('Three')
click_on('Edit') click_on('Edit')
expect(current_path).to include('one/two/three-test') expect(current_path).to include('one/two/three-test')
expect(page).to have_content('Edit Page') expect(page).to have_content('Edit Page')
fill_in('Content', with: 'Updated Wiki Content') fill_in('Content', with: 'Updated Wiki Content')
click_on('Save changes') click_on('Save changes')
click_on('Page history') click_on('Page history')
page.within(:css, '.nav-text') do page.within(:css, '.nav-text') do
expect(page).to have_content('History') expect(page).to have_content('History')
end end
find('a[href*="?version_id"]') find('a[href*="?version_id"]')
end
end end
end
context 'when a page does not have history' do context 'when a page does not have history' do
before do before do
visit(project_wiki_path(project, wiki_page)) visit(project_wiki_path(project, wiki_page))
end end
it 'shows all the pages' do it 'shows all the pages' do
expect(page).to have_content(user.name) expect(page).to have_content(user.name)
expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize) expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize)
end end
it 'shows a file stored in a page' do it 'shows a file stored in a page' do
gollum_file_double = double('Gollum::File', gollum_file_double = double('Gollum::File',
mime_type: 'image/jpeg', mime_type: 'image/jpeg',
name: 'images/image.jpg', name: 'images/image.jpg',
path: 'images/image.jpg', path: 'images/image.jpg',
raw_data: '') raw_data: '')
wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double) wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double)
allow(wiki_file).to receive(:mime_type).and_return('image/jpeg') allow(wiki_file).to receive(:mime_type).and_return('image/jpeg')
allow_any_instance_of(ProjectWiki).to receive(:find_file).with('image.jpg', nil).and_return(wiki_file) allow_any_instance_of(ProjectWiki).to receive(:find_file).with('image.jpg', nil).and_return(wiki_file)
expect(page).to have_xpath('//img[@data-src="image.jpg"]') expect(page).to have_xpath('//img[@data-src="image.jpg"]')
expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg")
click_on('image') click_on('image')
expect(current_path).to match('wikis/image.jpg') expect(current_path).to match('wikis/image.jpg')
expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved
end end
it 'shows the creation page if file does not exist' do it 'shows the creation page if file does not exist' do
expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg") expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/image.jpg")
click_on('image') click_on('image')
expect(current_path).to match('wikis/image.jpg') expect(current_path).to match('wikis/image.jpg')
expect(page).to have_content('New Wiki Page') expect(page).to have_content('New Wiki Page')
expect(page).to have_content('Create page') expect(page).to have_content('Create page')
end
end end
end
context 'when a page has history' do context 'when a page has history' do
before do before do
wiki_page.update(message: 'updated home', content: 'updated [some link](other-page)') wiki_page.update(message: 'updated home', content: 'updated [some link](other-page)')
end end
it 'shows the page history' do it 'shows the page history' do
visit(project_wiki_path(project, wiki_page)) visit(project_wiki_path(project, wiki_page))
expect(page).to have_selector('a.btn', text: 'Edit') expect(page).to have_selector('a.btn', text: 'Edit')
click_on('Page history') click_on('Page history')
expect(page).to have_content(user.name) expect(page).to have_content(user.name)
expect(page).to have_content("#{user.username} created page: home") expect(page).to have_content("#{user.username} created page: home")
expect(page).to have_content('updated home') expect(page).to have_content('updated home')
end
it 'does not show the "Edit" button' do
visit(project_wiki_path(project, wiki_page, version_id: wiki_page.versions.last.id))
expect(page).not_to have_selector('a.btn', text: 'Edit')
end
end end
it 'does not show the "Edit" button' do it 'opens a default wiki page', :js do
visit(project_wiki_path(project, wiki_page, version_id: wiki_page.versions.last.id)) visit(project_path(project))
expect(page).not_to have_selector('a.btn', text: 'Edit') find('.shortcuts-wiki').click
expect(page).to have_content('Home · Create Page')
end end
end end
it 'opens a default wiki page', :js do context 'when Gitaly is enabled' do
visit(project_path(project)) it_behaves_like 'wiki page user view'
end
find('.shortcuts-wiki').click
expect(page).to have_content('Home · Create Page') context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'wiki page user view'
end end
end end
...@@ -3,34 +3,38 @@ require 'spec_helper' ...@@ -3,34 +3,38 @@ require 'spec_helper'
describe Gitlab::Git::Wiki do describe Gitlab::Git::Wiki do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { project.owner } let(:user) { project.owner }
let(:wiki) { ProjectWiki.new(project, user) } let(:project_wiki) { ProjectWiki.new(project, user) }
let(:gollum_wiki) { wiki.wiki } subject { project_wiki.wiki }
# Remove skip_gitaly_mock flag when gitaly_find_page when # Remove skip_gitaly_mock flag when gitaly_find_page when
# https://gitlab.com/gitlab-org/gitaly/merge_requests/539 gets merged # https://gitlab.com/gitlab-org/gitlab-ce/issues/42039 is solved
describe '#page', :skip_gitaly_mock do describe '#page', :skip_gitaly_mock do
it 'returns the right page' do before do
create_page('page1', 'content') create_page('page1', 'content')
create_page('foo/page1', 'content') create_page('foo/page1', 'content foo/page1')
end
expect(gollum_wiki.page(title: 'page1', dir: '').url_path).to eq 'page1'
expect(gollum_wiki.page(title: 'page1', dir: 'foo').url_path).to eq 'foo/page1'
after do
destroy_page('page1') destroy_page('page1')
destroy_page('page1', 'foo') destroy_page('page1', 'foo')
end end
it 'returns the right page' do
expect(subject.page(title: 'page1', dir: '').url_path).to eq 'page1'
expect(subject.page(title: 'page1', dir: 'foo').url_path).to eq 'foo/page1'
end
end end
def create_page(name, content) def create_page(name, content)
gollum_wiki.write_page(name, :markdown, content, commit_details) subject.write_page(name, :markdown, content, commit_details(name))
end end
def commit_details def commit_details(name)
Gitlab::Git::Wiki::CommitDetails.new(user.name, user.email, "test commit") Gitlab::Git::Wiki::CommitDetails.new(user.name, user.email, "created page #{name}")
end end
def destroy_page(title, dir = '') def destroy_page(title, dir = '')
page = gollum_wiki.page(title: title, dir: dir) page = subject.page(title: title, dir: dir)
wiki.delete_page(page, "test commit") project_wiki.delete_page(page, "test commit")
end end
end end
This diff is collapsed.
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