diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-07-27 16:51:04 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-07-27 16:51:04 +0300 |
commit | 5f84509c05c63130143a9d9ac0c69a00ea10cf4c (patch) | |
tree | 47e96dcad9296ffb3005a1b41527b5b735ab4409 /spec/models | |
parent | ed81ee9ba2b5a0b68996ccb238bfa4c69a6df062 (diff) | |
parent | 7a233b37cd1281698107f1f3236b425bf4cc5ae7 (diff) |
Merge branch 'stop-dynamic-routable-creation' into 'master'
Stop building Route rows on the fly
See merge request gitlab-org/gitlab-ce!20313
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/routable_spec.rb | 33 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 4 |
3 files changed, 10 insertions, 37 deletions
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index ed3e28fbeca..565266321d3 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -12,16 +12,6 @@ describe Group, 'Routable' do it { is_expected.to have_many(:redirect_routes).dependent(:destroy) } end - describe 'GitLab read-only instance' do - it 'does not save route if route is not present' do - group.route.path = '' - allow(Gitlab::Database).to receive(:read_only?).and_return(true) - expect(group).to receive(:update_route).and_call_original - - expect { group.full_path }.to change { Route.count }.by(0) - end - end - describe 'Callbacks' do it 'creates route record on create' do expect(group.route.path).to eq(group.path) @@ -131,29 +121,6 @@ describe Group, 'Routable' do it { expect(group.full_path).to eq(group.path) } it { expect(nested_group.full_path).to eq("#{group.full_path}/#{nested_group.path}") } - - context 'with RequestStore active', :request_store do - it 'does not load the route table more than once' do - group.expires_full_path_cache - expect(group).to receive(:uncached_full_path).once.and_call_original - - 3.times { group.full_path } - expect(group.full_path).to eq(group.path) - end - end - end - - describe '#expires_full_path_cache' do - context 'with RequestStore active', :request_store do - it 'expires the full_path cache' do - expect(group.full_path).to eq('foo') - - group.route.update(path: 'bar', name: 'bar') - group.expires_full_path_cache - - expect(group.full_path).to eq('bar') - end - end end describe '#full_name' do diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 8ff16cbd7cc..9b7f932ec3a 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -323,6 +323,16 @@ describe Namespace do parent.update(path: 'mygroup_new') + # Routes are loaded when creating the projects, so we need to manually + # reload them for the below code to be aware of the above UPDATE. + [ + project_in_parent_group, + hashed_project_in_subgroup, + legacy_project_in_subgroup + ].each do |project| + project.route.reload + end + expect(project_rugged(project_in_parent_group).config['gitlab.fullpath']).to eq "mygroup_new/#{project_in_parent_group.path}" expect(project_rugged(hashed_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{hashed_project_in_subgroup.path}" expect(project_rugged(legacy_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{legacy_project_in_subgroup.path}" diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 88442247093..b75ca91b007 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2958,8 +2958,6 @@ describe Project do expect(project).to receive(:expire_caches_before_rename) - expect(project).to receive(:expires_full_path_cache) - project.rename_repo end @@ -3119,8 +3117,6 @@ describe Project do expect(project).to receive(:expire_caches_before_rename) - expect(project).to receive(:expires_full_path_cache) - project.rename_repo end |