debian-mirror-gitlab/spec/views/projects/commit/show.html.haml_spec.rb

65 lines
1.9 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe 'projects/commit/show.html.haml' do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2018-03-17 18:26:18 +05:30
let(:commit) { project.commit }
2017-08-17 22:00:37 +05:30
before do
assign(:project, project)
assign(:repository, project.repository)
2018-03-17 18:26:18 +05:30
assign(:commit, commit)
assign(:noteable, commit)
2017-08-17 22:00:37 +05:30
assign(:notes, [])
2018-03-17 18:26:18 +05:30
assign(:diffs, commit.diffs)
2017-08-17 22:00:37 +05:30
allow(view).to receive(:current_user).and_return(nil)
allow(view).to receive(:can?).and_return(false)
allow(view).to receive(:can_collaborate_with_project?).and_return(false)
allow(view).to receive(:current_ref).and_return(project.repository.root_ref)
allow(view).to receive(:diff_btn).and_return('')
end
context 'inline diff view' do
before do
allow(view).to receive(:diff_view).and_return(:inline)
2017-09-10 17:25:29 +05:30
allow(view).to receive(:diff_view).and_return(:inline)
2017-08-17 22:00:37 +05:30
render
end
2017-09-10 17:25:29 +05:30
it 'has limited width' do
expect(rendered).to have_selector('.limit-container-width')
2017-08-17 22:00:37 +05:30
end
end
context 'parallel diff view' do
before do
allow(view).to receive(:diff_view).and_return(:parallel)
2017-09-10 17:25:29 +05:30
allow(view).to receive(:fluid_layout).and_return(true)
2017-08-17 22:00:37 +05:30
render
end
it 'spans full width' do
2017-09-10 17:25:29 +05:30
expect(rendered).not_to have_selector('.limit-container-width')
2017-08-17 22:00:37 +05:30
end
end
2018-03-17 18:26:18 +05:30
context 'in the context of a merge request' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do
assign(:merge_request, merge_request)
render
end
it 'shows that it is in the context of a merge request' do
2019-03-02 22:35:43 +05:30
merge_request_url = diffs_project_merge_request_path(project, merge_request, commit_id: commit.id)
2018-03-17 18:26:18 +05:30
expect(rendered).to have_content("This commit is part of merge request")
2019-03-02 22:35:43 +05:30
expect(rendered).to have_link(merge_request.to_reference, href: merge_request_url)
2018-03-17 18:26:18 +05:30
end
end
2017-08-17 22:00:37 +05:30
end