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

update_pages_configuration_service_spec.rb « projects « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4c9fc779faebd2b1de7cb81276a2750b7c5e7f9 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Projects::UpdatePagesConfigurationService do
  let(:project) { create(:project) }
  let(:service) { described_class.new(project) }

  describe "#update" do
    let(:file) { Tempfile.new('pages-test') }

    subject { service.execute }

    after do
      file.close
      file.unlink
    end

    before do
      allow(service).to receive(:pages_config_file).and_return(file.path)
    end

    context 'when configuration changes' do
      it 'updates the .update file' do
        expect(service).to receive(:reload_daemon).and_call_original

        expect(subject).to include(status: :success, reload: true)
      end
    end

    context 'when configuration does not change' do
      before do
        # we set the configuration
        service.execute
      end

      it 'does not update the .update file' do
        expect(service).not_to receive(:reload_daemon)

        expect(subject).to include(status: :success, reload: false)
      end
    end
  end
end