diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
commit | 585826cb22ecea5998a2c2a4675735c94bdeedac (patch) | |
tree | 5b05f0b30d33cef48963609e8a18a4dff260eab3 /spec/controllers/projects/blob_controller_spec.rb | |
parent | df221d036e5d0c6c0ee4d55b9c97f481ee05dee8 (diff) |
Add latest changes from gitlab-org/gitlab@16-6-stable-eev16.6.0-rc42
Diffstat (limited to 'spec/controllers/projects/blob_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 49c1935c4a3..7811ef3bade 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -23,18 +23,12 @@ RSpec.describe Projects::BlobController, feature_category: :source_code_manageme render_views context 'with file path' do + include_context 'with ambiguous refs for controllers' + before do - expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original - project.repository.add_tag(project.creator, 'ambiguous_ref', RepoHelpers.sample_commit.id) - project.repository.add_branch(project.creator, 'ambiguous_ref', RepoHelpers.another_sample_commit.id) request end - after do - project.repository.rm_tag(project.creator, 'ambiguous_ref') - project.repository.rm_branch(project.creator, 'ambiguous_ref') - end - context 'when the ref is ambiguous' do let(:ref) { 'ambiguous_ref' } let(:path) { 'README.md' } @@ -43,6 +37,8 @@ RSpec.describe Projects::BlobController, feature_category: :source_code_manageme context 'and the redirect_with_ref_type flag is disabled' do let(:redirect_with_ref_type) { false } + it_behaves_like '#set_is_ambiguous_ref when ref is ambiguous' + context 'and explicitly requesting a branch' do let(:ref_type) { 'heads' } @@ -61,16 +57,22 @@ RSpec.describe Projects::BlobController, feature_category: :source_code_manageme end context 'and the redirect_with_ref_type flag is enabled' do - context 'when the ref_type is nil' do - let(:ref_type) { nil } + let(:ref_type) { nil } - it 'redirects to the tag' do - expect(response).to redirect_to(project_blob_path(project, id, ref_type: 'tags')) - end + it 'redirects to the tag' do + expect(response).to redirect_to(project_blob_path(project, id, ref_type: 'tags')) end end end + describe '#set_is_ambiguous_ref with no ambiguous ref' do + let(:id) { 'master/invalid-path.rb' } + let(:redirect_with_ref_type) { false } + let(:ambiguous_ref_modal) { true } + + it_behaves_like '#set_is_ambiguous_ref when ref is not ambiguous' + end + context "valid branch, valid file" do let(:id) { 'master/README.md' } |