Commit 6dc71d6f authored by Jacob Vosmaer's avatar Jacob Vosmaer Committed by Markus Koller

Small improvements to UpdatePagesConfigurationService

parent 4504c75b
...@@ -11,14 +11,14 @@ module Projects ...@@ -11,14 +11,14 @@ module Projects
end end
def execute def execute
if file_equals?(pages_config_file, pages_config_json) unless file_equals?(pages_config_file, pages_config_json)
return success(reload: false)
end
update_file(pages_config_file, pages_config_json) update_file(pages_config_file, pages_config_json)
reload_daemon reload_daemon
success(reload: true) end
success
rescue => e rescue => e
Gitlab::ErrorTracking.track_exception(e)
error(e.message) error(e.message)
end end
......
...@@ -14,12 +14,10 @@ class PagesWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -14,12 +14,10 @@ class PagesWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def deploy(build_id) def deploy(build_id)
build = Ci::Build.find_by(id: build_id) build = Ci::Build.find_by(id: build_id)
result = Projects::UpdatePagesService.new(build.project, build).execute update_contents = Projects::UpdatePagesService.new(build.project, build).execute
if result[:status] == :success if update_contents[:status] == :success
result = Projects::UpdatePagesConfigurationService.new(build.project).execute Projects::UpdatePagesConfigurationService.new(build.project).execute
end end
result
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -24,7 +24,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do ...@@ -24,7 +24,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
it 'updates the .update file' do it 'updates the .update file' do
expect(service).to receive(:reload_daemon).and_call_original expect(service).to receive(:reload_daemon).and_call_original
expect(subject).to include(status: :success, reload: true) expect(subject).to include(status: :success)
end end
end end
...@@ -37,7 +37,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do ...@@ -37,7 +37,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
it 'does not update the .update file' do it 'does not update the .update file' do
expect(service).not_to receive(:reload_daemon) expect(service).not_to receive(:reload_daemon)
expect(subject).to include(status: :success, reload: false) expect(subject).to include(status: :success)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment