2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe WikiPages::CreateService, feature_category: :wiki do
|
2020-05-24 23:13:21 +05:30
|
|
|
it_behaves_like 'WikiPages::CreateService#execute', :project
|
2021-09-30 23:02:18 +05:30
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
|
|
|
subject(:service) { described_class.new(container: project) }
|
|
|
|
|
|
|
|
context 'when wiki create fails due to git error' do
|
|
|
|
let(:wiki_git_error) { 'Could not create wiki page' }
|
|
|
|
|
|
|
|
it 'catches the thrown error and returns a ServiceResponse error' do
|
|
|
|
allow_next_instance_of(WikiPage) do |instance|
|
|
|
|
allow(instance).to receive(:create).and_raise(Gitlab::Git::CommandError.new(wiki_git_error))
|
|
|
|
end
|
|
|
|
|
|
|
|
result = service.execute
|
|
|
|
expect(result).to be_error
|
|
|
|
expect(result.message).to eq(wiki_git_error)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|