blob: 305c44190b483520822bdded7c86565fb5b99710 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'projects/diffs/_viewer.html.haml' do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
let(:viewer) { diff_file.simple_viewer }
before do
assign(:project, project)
controller.params[:controller] = 'projects/commit'
controller.params[:action] = 'show'
controller.params[:namespace_id] = project.namespace.to_param
controller.params[:project_id] = project.to_param
controller.params[:id] = commit.id
end
def render_view
render partial: 'projects/diffs/viewer', locals: { viewer: viewer }
end
context 'when there is a render error' do
before do
allow(viewer).to receive(:render_error).and_return(:too_large)
end
it 'renders the error' do
render_view
expect(view).to render_template('projects/diffs/_render_error')
end
end
context 'when the viewer is collapsed' do
before do
allow(diff_file).to receive(:collapsed?).and_return(true)
end
it 'renders the collapsed view' do
render_view
expect(view).to render_template('projects/diffs/viewers/_collapsed')
end
end
context 'when there is no render error' do
it 'prepares the viewer' do
expect(viewer).to receive(:prepare!)
render_view
end
it 'renders the viewer' do
render_view
expect(view).to render_template('projects/diffs/viewers/_text')
end
end
end
|