2019-04-11 12:17:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-27 01:58:42 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.describe Projects::UpdatePagesConfigurationService do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2019-01-16 12:00:43 +00:00
|
|
|
let(:service) { described_class.new(project) }
|
2017-01-27 01:58:42 +00:00
|
|
|
|
|
|
|
describe "#update" do
|
|
|
|
let(:file) { Tempfile.new('pages-test') }
|
|
|
|
|
2019-01-16 12:00:43 +00:00
|
|
|
subject { service.execute }
|
|
|
|
|
2017-01-27 01:58:42 +00:00
|
|
|
after do
|
|
|
|
file.close
|
|
|
|
file.unlink
|
|
|
|
end
|
|
|
|
|
2019-01-16 12:00:43 +00:00
|
|
|
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
|
|
|
|
|
2020-07-29 18:09:50 +00:00
|
|
|
expect(subject).to include(status: :success)
|
2019-01-16 12:00:43 +00:00
|
|
|
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)
|
2017-01-27 01:58:42 +00:00
|
|
|
|
2020-07-29 18:09:50 +00:00
|
|
|
expect(subject).to include(status: :success)
|
2019-01-16 12:00:43 +00:00
|
|
|
end
|
2017-01-27 01:58:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|