debian-mirror-gitlab/spec/controllers/projects/blame_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2015-09-11 14:41:01 +05:30
require 'spec_helper'
2023-06-20 00:43:36 +05:30
RSpec.describe Projects::BlameController, feature_category: :source_code_management do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2015-09-11 14:41:01 +05:30
before do
sign_in(user)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2015-09-11 14:41:01 +05:30
controller.instance_variable_set(:@project, project)
end
2023-06-20 00:43:36 +05:30
shared_examples 'blame_response' do
context 'valid branch, valid file' do
2015-09-11 14:41:01 +05:30
let(:id) { 'master/files/ruby/popen.rb' }
2019-12-26 22:10:19 +05:30
2015-09-11 14:41:01 +05:30
it { is_expected.to respond_with(:success) }
end
2017-08-17 22:00:37 +05:30
2023-06-20 00:43:36 +05:30
context 'valid branch, invalid file' do
2019-12-26 22:10:19 +05:30
let(:id) { 'master/files/ruby/invalid-path.rb' }
it 'redirects' do
2023-05-27 22:25:52 +05:30
expect(subject).to redirect_to("/#{project.full_path}/-/tree/master")
2019-12-26 22:10:19 +05:30
end
end
2023-06-20 00:43:36 +05:30
context 'invalid branch, valid file' do
2022-10-11 01:57:18 +05:30
let(:id) { 'invalid-branch/files/ruby/missing_file.rb' }
2019-12-26 22:10:19 +05:30
it { is_expected.to respond_with(:not_found) }
2017-08-17 22:00:37 +05:30
end
2015-09-11 14:41:01 +05:30
end
2023-06-20 00:43:36 +05:30
describe 'GET show' do
render_views
before do
get :show, params: { namespace_id: project.namespace, project_id: project, id: id }
end
it_behaves_like 'blame_response'
end
describe 'GET page' do
render_views
before do
get :page, params: { namespace_id: project.namespace, project_id: project, id: id }
end
it_behaves_like 'blame_response'
end
2023-07-09 08:55:56 +05:30
describe 'GET streaming' do
render_views
before do
get :streaming, params: { namespace_id: project.namespace, project_id: project, id: id }
end
it_behaves_like 'blame_response'
end
2015-09-11 14:41:01 +05:30
end