Fix update_root_ref with inmemory feature disabled

parent da05f79b
...@@ -57,8 +57,8 @@ module Geo ...@@ -57,8 +57,8 @@ module Geo
project.update_root_ref(GEO_REMOTE_NAME, remote_url, authorization) project.update_root_ref(GEO_REMOTE_NAME, remote_url, authorization)
else else
repository_with_config(jwt_authentication_header) do repository.with_config(jwt_authentication_header) do
project.update_root_ref(GEO_REMOTE_NAME, remote_url) project.update_root_ref(GEO_REMOTE_NAME, remote_url, nil)
end end
end end
end end
......
...@@ -233,53 +233,119 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -233,53 +233,119 @@ RSpec.describe Geo::RepositorySyncService, :geo do
context 'with non empty repositories' do context 'with non empty repositories' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
context 'when when HEAD change' do context 'with inmemory feature disabled' do
before do before do
allow(project.repository) stub_feature_flags(find_remote_root_refs_inmemory: false)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return('feature')
end end
it 'syncs gitattributes to info/attributes' do context 'when HEAD change' do
expect(repository).to receive(:copy_gitattributes) before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, nil)
.and_return('feature')
end
subject.execute it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch with JWT credentials' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.twice
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
end end
it 'updates the default branch with JWT credentials' do context 'when HEAD does not change' do
expect(repository).to receive(:with_config) before do
.with("http.#{url_to_repo}.extraHeader" => anything) allow(project.repository)
.and_call_original .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, nil)
.and_return(project.default_branch)
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch with JWT credentials' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.twice
expect(project).to receive(:change_head).with('feature').once expect(project).to receive(:change_head).with('master').once
subject.execute subject.execute
end
end end
end end
context 'when HEAD does not change' do context 'with inmemory feature enabled' do
before do before do
allow(project.repository) stub_feature_flags(find_remote_root_refs_inmemory: true)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return(project.default_branch)
end end
it 'syncs gitattributes to info/attributes' do context 'when HEAD change' do
expect(repository).to receive(:copy_gitattributes) before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return('feature')
end
subject.execute it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.once
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
end end
it 'updates the default branch with JWT credentials' do context 'when HEAD does not change' do
expect(repository).to receive(:with_config) before do
.with("http.#{url_to_repo}.extraHeader" => anything) allow(project.repository)
.and_call_original .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return(project.default_branch)
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.once
expect(project).to receive(:change_head).with('master').once expect(project).to receive(:change_head).with('master').once
subject.execute subject.execute
end
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