Commit 23974334 authored by Stan Hu's avatar Stan Hu Committed by James Edwards-Jones

Fix GitLab Pages not refreshing upon new content

Due to autoloading and Ruby scoping, the .update file was never being
updated due to this error:

```
NoMethodError: undefined method `pages' for Projects::Settings:Module
        from /opt/gitlab/embedded/service/gitlab-rails/app/services/projects/update_pages_configuration_service.rb:50:in `pages_update_file'
        from /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/metrics/instrumentation.rb:157:in `pages_update_file'
        from (irb):6
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/console.rb:110:in `start'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/console.rb:9:in `start'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:68:in `console'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:9:in `require'
```

This error was caught and discarded quietly. This fix exercises this code and fixes the scope problem.

Closes gitlab-com/infrastructure#1058
parent 9677b538
......@@ -47,7 +47,7 @@ module Projects
end
def pages_update_file
File.join(Settings.pages.path, '.update')
File.join(::Settings.pages.path, '.update')
end
def update_file(file, data)
......
require 'spec_helper'
describe Projects::UpdatePagesConfigurationService, services: true do
let(:project) { create(:empty_project) }
subject { described_class.new(project) }
describe "#update" do
let(:file) { Tempfile.new('pages-test') }
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
expect(subject.execute).to eq({ 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