Commit d40912bb authored by Francisco Javier López's avatar Francisco Javier López Committed by Sean McGivern

Removing gitaly flags

parent 683984f2
......@@ -25,9 +25,8 @@ module Gitlab
@repository.exists?
end
# Disabled because of https://gitlab.com/gitlab-org/gitaly/merge_requests/539
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
gitaly_write_page(name, format, content, commit_details)
gollum_wiki.clear_cache
......@@ -48,9 +47,8 @@ module Gitlab
end
end
# Disable because of https://gitlab.com/gitlab-org/gitlab-ce/issues/42094
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
gitaly_update_page(page_path, title, format, content, commit_details)
gollum_wiki.clear_cache
......
require 'spec_helper'
# Remove skip_gitaly_mock flag when gitaly_update_page implements moving pages
describe 'User updates wiki page', :skip_gitaly_mock do
describe 'User updates wiki page' do
shared_examples 'wiki page user update' do
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
......@@ -165,7 +164,7 @@ describe 'User updates wiki page', :skip_gitaly_mock do
visit(project_wiki_edit_path(project, wiki_page))
end
it 'moves the page to the root folder' do
it 'moves the page to the root folder', :skip_gitaly_mock do
fill_in(:wiki_title, with: "/#{page_name}")
click_button('Save changes')
......@@ -223,4 +222,13 @@ describe 'User updates wiki page', :skip_gitaly_mock do
expect(current_path).to eq(project_wiki_path(project, "foo1/bar1/#{page_name}"))
end
end
end
context 'when Gitaly is enabled' do
it_behaves_like 'wiki page user update'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'wiki page user update'
end
end
require 'spec_helper'
# Remove skip_gitaly_mock flag when gitaly_update_page implements moving pages
describe 'User views a wiki page', :skip_gitaly_mock do
describe 'User views a wiki page' do
shared_examples 'wiki page user view' do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let(:wiki_page) do
......@@ -143,4 +143,13 @@ describe 'User views a wiki page', :skip_gitaly_mock do
expect(page).to have_content('Home · Create Page')
end
end
context 'when Gitaly is enabled' do
it_behaves_like 'wiki page user view'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'wiki page user view'
end
end
......@@ -3,34 +3,38 @@ require 'spec_helper'
describe Gitlab::Git::Wiki do
let(:project) { create(:project) }
let(:user) { project.owner }
let(:wiki) { ProjectWiki.new(project, user) }
let(:gollum_wiki) { wiki.wiki }
let(:project_wiki) { ProjectWiki.new(project, user) }
subject { project_wiki.wiki }
# 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
it 'returns the right page' do
before do
create_page('page1', 'content')
create_page('foo/page1', 'content')
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'
create_page('foo/page1', 'content foo/page1')
end
after do
destroy_page('page1')
destroy_page('page1', 'foo')
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
def create_page(name, content)
gollum_wiki.write_page(name, :markdown, content, commit_details)
subject.write_page(name, :markdown, content, commit_details(name))
end
def commit_details
Gitlab::Git::Wiki::CommitDetails.new(user.name, user.email, "test commit")
def commit_details(name)
Gitlab::Git::Wiki::CommitDetails.new(user.name, user.email, "created page #{name}")
end
def destroy_page(title, dir = '')
page = gollum_wiki.page(title: title, dir: dir)
wiki.delete_page(page, "test commit")
page = subject.page(title: title, dir: dir)
project_wiki.delete_page(page, "test commit")
end
end
......@@ -188,7 +188,8 @@ describe WikiPage do
end
end
describe '#create', :skip_gitaly_mock do
describe '#create' do
shared_examples 'create method' do
context 'with valid attributes' do
it 'raises an error if a page with the same path already exists' do
create_page('New Page', 'content')
......@@ -210,8 +211,17 @@ describe WikiPage do
end
end
# Remove skip_gitaly_mock flag when gitaly_update_page implements moving pages
describe "#update", :skip_gitaly_mock do
context 'when Gitaly is enabled' do
it_behaves_like 'create method'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'create method'
end
end
describe "#update" do
shared_examples 'update method' do
before do
create_page("Update", "content")
@page = wiki.find_page("Update")
......@@ -310,7 +320,7 @@ describe WikiPage do
@page = wiki.find_page('foo/Existing Page')
end
it 'moves the page to the root folder if the title is preceded by /' do
it 'moves the page to the root folder if the title is preceded by /', :skip_gitaly_mock do
expect(@page.slug).to eq 'foo/Existing-Page'
expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy
expect(@page.slug).to eq 'Existing-Page'
......@@ -347,6 +357,15 @@ describe WikiPage do
end
end
context 'when Gitaly is enabled' do
it_behaves_like 'update method'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'update method'
end
end
describe "#destroy" do
before do
create_page("Delete Page", "content")
......
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