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 ...@@ -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 updates wiki page' do
describe 'User updates wiki page', :skip_gitaly_mock do shared_examples 'wiki page user update' do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.add_master(user) project.add_master(user)
sign_in(user) sign_in(user)
...@@ -165,7 +164,7 @@ describe 'User updates wiki page', :skip_gitaly_mock do ...@@ -165,7 +164,7 @@ describe 'User updates wiki page', :skip_gitaly_mock do
visit(project_wiki_edit_path(project, wiki_page)) visit(project_wiki_edit_path(project, wiki_page))
end 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}") fill_in(:wiki_title, with: "/#{page_name}")
click_button('Save changes') click_button('Save changes')
...@@ -223,4 +222,13 @@ describe 'User updates wiki page', :skip_gitaly_mock do ...@@ -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}")) expect(current_path).to eq(project_wiki_path(project, "foo1/bar1/#{page_name}"))
end end
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 end
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
...@@ -143,4 +143,13 @@ describe 'User views a wiki page', :skip_gitaly_mock do ...@@ -143,4 +143,13 @@ describe 'User views a wiki page', :skip_gitaly_mock do
expect(page).to have_content('Home · Create Page') expect(page).to have_content('Home · Create Page')
end 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 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
...@@ -188,7 +188,8 @@ describe WikiPage do ...@@ -188,7 +188,8 @@ describe WikiPage do
end end
end end
describe '#create', :skip_gitaly_mock do describe '#create' do
shared_examples 'create method' do
context 'with valid attributes' do context 'with valid attributes' do
it 'raises an error if a page with the same path already exists' do it 'raises an error if a page with the same path already exists' do
create_page('New Page', 'content') create_page('New Page', 'content')
...@@ -210,8 +211,17 @@ describe WikiPage do ...@@ -210,8 +211,17 @@ describe WikiPage do
end end
end end
# Remove skip_gitaly_mock flag when gitaly_update_page implements moving pages context 'when Gitaly is enabled' do
describe "#update", :skip_gitaly_mock 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 before do
create_page("Update", "content") create_page("Update", "content")
@page = wiki.find_page("Update") @page = wiki.find_page("Update")
...@@ -310,7 +320,7 @@ describe WikiPage do ...@@ -310,7 +320,7 @@ describe WikiPage do
@page = wiki.find_page('foo/Existing Page') @page = wiki.find_page('foo/Existing Page')
end 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.slug).to eq 'foo/Existing-Page'
expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy
expect(@page.slug).to eq 'Existing-Page' expect(@page.slug).to eq 'Existing-Page'
...@@ -347,6 +357,15 @@ describe WikiPage do ...@@ -347,6 +357,15 @@ describe WikiPage do
end end
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 describe "#destroy" do
before do before do
create_page("Delete Page", "content") 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