2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-20 04:02:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe Projects::BlameController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2015-08-20 04:02:12 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2015-08-20 04:02:12 -04:00
|
|
|
controller.instance_variable_set(:@project, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET show" do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
get(:show,
|
2018-12-17 17:52:17 -05:00
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: id
|
|
|
|
})
|
2015-08-20 04:02:12 -04:00
|
|
|
end
|
|
|
|
|
2019-10-21 14:06:29 -04:00
|
|
|
context "valid branch, valid file" do
|
2015-08-20 04:02:12 -04:00
|
|
|
let(:id) { 'master/files/ruby/popen.rb' }
|
2019-10-21 14:06:29 -04:00
|
|
|
|
2015-08-20 04:02:12 -04:00
|
|
|
it { is_expected.to respond_with(:success) }
|
|
|
|
end
|
2016-12-16 10:10:04 -05:00
|
|
|
|
2019-10-21 14:06:29 -04:00
|
|
|
context "valid branch, invalid file" do
|
|
|
|
let(:id) { 'master/files/ruby/invalid-path.rb' }
|
|
|
|
|
|
|
|
it 'redirects' do
|
|
|
|
expect(subject)
|
2020-01-27 07:08:35 -05:00
|
|
|
.to redirect_to("/#{project.full_path}/-/tree/master")
|
2019-10-21 14:06:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "invalid branch, valid file" do
|
2022-08-26 14:12:09 -04:00
|
|
|
let(:id) { 'invalid-branch/files/ruby/missing_file.rb' }
|
2019-10-21 14:06:29 -04:00
|
|
|
|
|
|
|
it { is_expected.to respond_with(:not_found) }
|
2016-12-16 10:10:04 -05:00
|
|
|
end
|
2015-08-20 04:02:12 -04:00
|
|
|
end
|
|
|
|
end
|