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

50 lines
1.1 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'
2020-06-23 00:09:42 +05:30
RSpec.describe Projects::BlameController do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2015-09-11 14:41:01 +05:30
let(:user) { create(:user) }
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
describe "GET show" do
render_views
before do
get(:show,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project,
id: id
})
2015-09-11 14:41:01 +05:30
end
2019-12-26 22:10:19 +05:30
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
2019-12-26 22:10:19 +05:30
context "valid branch, invalid file" do
let(:id) { 'master/files/ruby/invalid-path.rb' }
it 'redirects' do
expect(subject)
2020-03-13 15:44:24 +05:30
.to redirect_to("/#{project.full_path}/-/tree/master")
2019-12-26 22:10:19 +05:30
end
end
context "invalid branch, valid file" do
let(:id) { 'invalid-branch/files/ruby/missing_file.rb'}
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
end