Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_service_spec.rb « wiki_pages « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ca2d38ad70ddd13246928d678fce7ac83504b443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe WikiPages::CreateService, feature_category: :wiki do
  it_behaves_like 'WikiPages::CreateService#execute', :project

  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
end