2017-01-26 20:58:42 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Projects::UpdatePagesConfigurationService do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2019-01-16 07:00:43 -05:00
|
|
|
let(:service) { described_class.new(project) }
|
2017-01-26 20:58:42 -05:00
|
|
|
|
|
|
|
describe "#update" do
|
|
|
|
let(:file) { Tempfile.new('pages-test') }
|
|
|
|
|
2019-01-16 07:00:43 -05:00
|
|
|
subject { service.execute }
|
|
|
|
|
2017-01-26 20:58:42 -05:00
|
|
|
after do
|
|
|
|
file.close
|
|
|
|
file.unlink
|
|
|
|
end
|
|
|
|
|
2019-01-16 07:00:43 -05: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
|
|
|
|
|
|
|
|
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)
|
2017-01-26 20:58:42 -05:00
|
|
|
|
2019-01-16 07:00:43 -05:00
|
|
|
expect(subject).to include(status: :success, reload: false)
|
|
|
|
end
|
2017-01-26 20:58:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|