2012-09-25 23:40:04 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-06-23 13:25:06 -04:00
|
|
|
describe Projects::CommitsController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2013-04-25 10:15:33 -04:00
|
|
|
let(:user) { create(:user) }
|
2012-09-25 23:40:04 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_master(user)
|
2012-09-25 23:40:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET show" do
|
2017-10-01 10:54:12 -04:00
|
|
|
render_views
|
|
|
|
|
|
|
|
context 'with file path' do
|
|
|
|
before do
|
|
|
|
get(:show,
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: id)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch, valid file" do
|
|
|
|
let(:id) { 'master/README.md' }
|
|
|
|
|
|
|
|
it { is_expected.to respond_with(:success) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch, invalid file" do
|
|
|
|
let(:id) { 'master/invalid-path.rb' }
|
2016-10-07 11:49:48 -04:00
|
|
|
|
2017-10-01 10:54:12 -04:00
|
|
|
it { is_expected.to respond_with(:not_found) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "invalid branch, valid file" do
|
|
|
|
let(:id) { 'invalid-branch/README.md' }
|
|
|
|
|
|
|
|
it { is_expected.to respond_with(:not_found) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the ref name ends in .atom" do
|
2016-10-07 11:49:48 -04:00
|
|
|
context "when the ref does not exist with the suffix" do
|
2018-01-21 06:06:48 -05:00
|
|
|
before do
|
2016-10-07 11:49:48 -04:00
|
|
|
get(:show,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-10-07 11:49:48 -04:00
|
|
|
id: "master.atom")
|
2018-01-21 06:06:48 -05:00
|
|
|
end
|
2016-10-07 11:49:48 -04:00
|
|
|
|
2018-01-21 06:06:48 -05:00
|
|
|
it "renders as atom" do
|
2016-10-07 11:49:48 -04:00
|
|
|
expect(response).to be_success
|
|
|
|
expect(response.content_type).to eq('application/atom+xml')
|
|
|
|
end
|
2018-01-21 06:06:48 -05:00
|
|
|
|
|
|
|
it 'renders summary with type=html' do
|
|
|
|
expect(response.body).to include('<summary type="html">')
|
|
|
|
end
|
2016-10-07 11:49:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when the ref exists with the suffix" do
|
|
|
|
before do
|
|
|
|
commit = project.repository.commit('master')
|
|
|
|
|
|
|
|
allow_any_instance_of(Repository).to receive(:commit).and_call_original
|
|
|
|
allow_any_instance_of(Repository).to receive(:commit).with('master.atom').and_return(commit)
|
|
|
|
|
|
|
|
get(:show,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-10-07 11:49:48 -04:00
|
|
|
id: "master.atom")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "renders as HTML" do
|
|
|
|
expect(response).to be_success
|
|
|
|
expect(response.content_type).to eq('text/html')
|
|
|
|
end
|
2012-09-25 23:40:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|