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
end
def execute
if file_equals?(pages_config_file, pages_config_json)
return success(reload: false)
unless file_equals?(pages_config_file, pages_config_json)
update_file(pages_config_file, pages_config_json)
reload_daemon
end
update_file(pages_config_file, pages_config_json)
reload_daemon
success(reload: true)
success
rescue => e
Gitlab::ErrorTracking.track_exception(e)
error(e.message)
end
......
......@@ -14,12 +14,10 @@ class PagesWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord
def deploy(build_id)
build = Ci::Build.find_by(id: build_id)
result = Projects::UpdatePagesService.new(build.project, build).execute
if result[:status] == :success
result = Projects::UpdatePagesConfigurationService.new(build.project).execute
update_contents = Projects::UpdatePagesService.new(build.project, build).execute
if update_contents[:status] == :success
Projects::UpdatePagesConfigurationService.new(build.project).execute
end
result
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -24,7 +24,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
it 'updates the .update file' do
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
......@@ -37,7 +37,7 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
it 'does not update the .update file' do
expect(service).not_to receive(:reload_daemon)
expect(subject).to include(status: :success, reload: false)
expect(subject).to include(status: :success)
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