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

94 lines
2.4 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
describe Projects::CommitsController do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2014-09-02 18:07:02 +05:30
let(:user) { create(:user) }
before do
sign_in(user)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
end
describe "GET commits_root" do
context "no ref is provided" do
it 'should redirect to the default branch of the project' do
get(:commits_root,
namespace_id: project.namespace,
project_id: project)
expect(response).to redirect_to project_commits_path(project)
end
end
2014-09-02 18:07:02 +05:30
end
describe "GET show" do
2018-03-17 18:26:18 +05:30
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' }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid file" do
let(:id) { 'invalid-branch/README.md' }
2016-11-03 12:29:30 +05:30
2018-03-17 18:26:18 +05:30
it { is_expected.to respond_with(:not_found) }
end
end
context "when the ref name ends in .atom" do
2016-11-03 12:29:30 +05:30
context "when the ref does not exist with the suffix" do
2018-03-17 18:26:18 +05:30
before do
2016-11-03 12:29:30 +05:30
get(:show,
2017-08-17 22:00:37 +05:30
namespace_id: project.namespace,
project_id: project,
2016-11-03 12:29:30 +05:30
id: "master.atom")
2018-03-17 18:26:18 +05:30
end
2016-11-03 12:29:30 +05:30
2018-03-17 18:26:18 +05:30
it "renders as atom" do
2016-11-03 12:29:30 +05:30
expect(response).to be_success
expect(response.content_type).to eq('application/atom+xml')
end
2018-03-17 18:26:18 +05:30
it 'renders summary with type=html' do
expect(response.body).to include('<summary type="html">')
end
2016-11-03 12:29:30 +05:30
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-08-17 22:00:37 +05:30
namespace_id: project.namespace,
project_id: project,
2016-11-03 12:29:30 +05:30
id: "master.atom")
end
it "renders as HTML" do
expect(response).to be_success
expect(response.content_type).to eq('text/html')
end
2014-09-02 18:07:02 +05:30
end
end
end
end