Commit 96dd516f authored by Markus Koller's avatar Markus Koller

Merge branch '325526-fj-enable-new-wiki-destroy-page-RPC' into 'master'

Enable new wiki delete page RPC [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57106
parents cd021cb0 3111761e
......@@ -192,16 +192,9 @@ class Wiki
def delete_page(page, message = nil)
return unless page
if Feature.enabled?(:gitaly_replace_wiki_delete_page, user, default_enabled: :yaml)
capture_git_error(:deleted) do
repository.delete_file(user, page.path, **multi_commit_options(:deleted, message, page.title))
capture_git_error(:deleted) do
repository.delete_file(user, page.path, **multi_commit_options(:deleted, message, page.title))
after_wiki_activity
true
end
else
wiki.delete_page(page.path, commit_details(:deleted, message, page.title))
after_wiki_activity
true
......
---
title: Enable new RPC to destroy wiki pages
merge_request: 57106
author:
type: changed
---
name: gitaly_replace_wiki_delete_page
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56495
rollout_issue_url:
milestone: '13.10'
type: development
group: group::editor
default_enabled: false
......@@ -73,12 +73,6 @@ module Gitlab
end
end
def delete_page(page_path, commit_details)
wrapped_gitaly_errors do
gitaly_delete_page(page_path, commit_details)
end
end
def update_page(page_path, title, format, content, commit_details)
wrapped_gitaly_errors do
gitaly_update_page(page_path, title, format, content, commit_details)
......@@ -140,10 +134,6 @@ module Gitlab
gitaly_wiki_client.update_page(page_path, title, format, content, commit_details)
end
def gitaly_delete_page(page_path, commit_details)
gitaly_wiki_client.delete_page(page_path, commit_details)
end
def gitaly_find_page(title:, version: nil, dir: nil)
return unless title.present?
......
......@@ -64,16 +64,6 @@ module Gitlab
GitalyClient.call(@repository.storage, :wiki_service, :wiki_update_page, enum, timeout: GitalyClient.medium_timeout)
end
def delete_page(page_path, commit_details)
request = Gitaly::WikiDeletePageRequest.new(
repository: @gitaly_repo,
page_path: encode_binary(page_path),
commit_details: gitaly_commit_details(commit_details)
)
GitalyClient.call(@repository.storage, :wiki_service, :wiki_delete_page, request, timeout: GitalyClient.medium_timeout)
end
def find_page(title:, version: nil, dir: nil)
request = Gitaly::WikiFindPageRequest.new(
repository: @gitaly_repo,
......
......@@ -58,22 +58,6 @@ RSpec.describe Gitlab::Git::Wiki do
end
end
describe '#delete_page' do
after do
destroy_page('page1')
end
it 'only removes the page with the same path' do
create_page('page1', 'content')
create_page('*', 'content')
subject.delete_page('*', commit_details('whatever'))
expect(subject.list_pages.count).to eq 1
expect(subject.list_pages.first.title).to eq 'page1'
end
end
describe '#preview_slug' do
where(:title, :format, :expected_slug) do
'The Best Thing' | :markdown | 'The-Best-Thing'
......
......@@ -51,7 +51,7 @@ RSpec.describe Git::WikiPushService, services: true do
process_changes do
write_new_page
update_page(wiki_page_a.title)
delete_page(wiki_page_b.page.path)
delete_page(wiki_page_b.page)
end
end
......@@ -198,7 +198,7 @@ RSpec.describe Git::WikiPushService, services: true do
context 'when a page we do not know about has been deleted' do
def run_service
wiki_page = create(:wiki_page, wiki: wiki)
process_changes { delete_page(wiki_page.page.path) }
process_changes { delete_page(wiki_page.page) }
end
it 'create a new meta-data record' do
......@@ -350,8 +350,8 @@ RSpec.describe Git::WikiPushService, services: true do
git_wiki.update_page(page.path, title, 'markdown', 'Hey', commit_details)
end
def delete_page(path)
git_wiki.delete_page(path, commit_details)
def delete_page(page)
wiki.delete_page(page, 'commit message')
end
def commit_details
......
......@@ -469,34 +469,30 @@ RSpec.shared_examples 'wiki model' do
end
describe '#delete_page' do
shared_examples 'delete_page operations' do
let(:page) { create(:wiki_page, wiki: wiki) }
let(:page) { create(:wiki_page, wiki: wiki) }
it 'deletes the page' do
subject.delete_page(page)
it 'deletes the page' do
subject.delete_page(page)
expect(subject.list_pages.count).to eq(0)
end
expect(subject.list_pages.count).to eq(0)
end
it 'sets the correct commit email' do
subject.delete_page(page)
it 'sets the correct commit email' do
subject.delete_page(page)
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
it 'runs after_wiki_activity callbacks' do
page
it 'runs after_wiki_activity callbacks' do
page
expect(subject).to receive(:after_wiki_activity)
expect(subject).to receive(:after_wiki_activity)
subject.delete_page(page)
end
subject.delete_page(page)
end
it_behaves_like 'delete_page operations'
context 'when an error is raised' do
it 'logs the error and returns false' do
page = build(:wiki_page, wiki: wiki)
......@@ -509,14 +505,6 @@ RSpec.shared_examples 'wiki model' do
expect(subject.delete_page(page)).to be_falsey
end
end
context 'when feature flag :gitaly_replace_wiki_delete_page is disabled' do
before do
stub_feature_flags(gitaly_replace_wiki_delete_page: false)
end
it_behaves_like 'delete_page operations'
end
end
describe '#ensure_repository' do
......
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