summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-02-05 08:27:26 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-02-05 08:27:26 +0000
commitbb0e50d63417234e048fa9c4aa34e02953c54f15 (patch)
tree3407d7ee564bc8699feecc581f88d59e3ae84832 /spec/services
parent8e38ca94b2ede968e8d2a66c059170d885d7df70 (diff)
parentebda58e817b843116a9e39ffcac05c9d5aa39535 (diff)
downloadgitlab-ce-bb0e50d63417234e048fa9c4aa34e02953c54f15.tar.gz
Merge branch 'update-pages-config-only-when-changed' into 'master'
Update pages config only when changed See merge request gitlab-org/gitlab-ce!24424
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/projects/update_pages_configuration_service_spec.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/spec/services/projects/update_pages_configuration_service_spec.rb b/spec/services/projects/update_pages_configuration_service_spec.rb
index e4d4e6ff3dd..7f5ef3129d7 100644
--- a/spec/services/projects/update_pages_configuration_service_spec.rb
+++ b/spec/services/projects/update_pages_configuration_service_spec.rb
@@ -2,23 +2,41 @@ require 'spec_helper'
describe Projects::UpdatePagesConfigurationService do
let(:project) { create(:project) }
- subject { described_class.new(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
- it 'updates the .update file' do
- # Access this reference to ensure scoping works
- Projects::Settings # rubocop:disable Lint/Void
- expect(subject).to receive(:pages_config_file).and_return(file.path)
- expect(subject).to receive(:reload_daemon).and_call_original
+ 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.execute).to eq({ status: :success })
+ expect(subject).to include(status: :success, reload: false)
+ end
end
end
end