diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-14 15:09:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-14 15:09:23 +0300 |
commit | 0b194c4854f312e36616fccf7c610cb2b0ec6957 (patch) | |
tree | f4c3d8ed1cd799e50b979035506675a1d90ad4a9 /spec/controllers/projects | |
parent | c1e7698dff17b737299127ecf484443e676cdd4f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 17 | ||||
-rw-r--r-- | spec/controllers/projects/tree_controller_spec.rb | 19 |
2 files changed, 33 insertions, 3 deletions
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 9493215247a..53efcc65066 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe Projects::BlobController do include ProjectForksHelper - let(:project) { create(:project, :public, :repository) } + let(:project) { create(:project, :public, :repository, previous_default_branch: previous_default_branch) } + let(:previous_default_branch) { nil } describe "GET show" do def request @@ -42,6 +43,20 @@ RSpec.describe Projects::BlobController do it { is_expected.to respond_with(:not_found) } end + context "renamed default branch, valid file" do + let(:id) { 'old-default-branch/README.md' } + let(:previous_default_branch) { 'old-default-branch' } + + it { is_expected.to redirect_to("/#{project.full_path}/-/blob/#{project.default_branch}/README.md") } + end + + context "renamed default branch, invalid file" do + let(:id) { 'old-default-branch/invalid-path.rb' } + let(:previous_default_branch) { 'old-default-branch' } + + it { is_expected.to redirect_to("/#{project.full_path}/-/blob/#{project.default_branch}/invalid-path.rb") } + end + context "binary file" do let(:id) { 'binary-encoding/encoding/binary-1.bin' } diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 8e4e275bdbe..143516e4712 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -3,8 +3,9 @@ require 'spec_helper' RSpec.describe Projects::TreeController do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:project) { create(:project, :repository, previous_default_branch: previous_default_branch) } + let(:previous_default_branch) { nil } + let(:user) { create(:user) } before do sign_in(user) @@ -55,6 +56,20 @@ RSpec.describe Projects::TreeController do it { is_expected.to respond_with(:not_found) } end + context "renamed default branch, valid file" do + let(:id) { 'old-default-branch/encoding/' } + let(:previous_default_branch) { 'old-default-branch' } + + it { is_expected.to redirect_to("/#{project.full_path}/-/tree/#{project.default_branch}/encoding/") } + end + + context "renamed default branch, invalid file" do + let(:id) { 'old-default-branch/invalid-path/' } + let(:previous_default_branch) { 'old-default-branch' } + + it { is_expected.to redirect_to("/#{project.full_path}/-/tree/#{project.default_branch}/invalid-path/") } + end + context "valid empty branch, invalid path" do let(:id) { 'empty-branch/invalid-path/' } |