debian-mirror-gitlab/spec/views/projects/diffs/_viewer.html.haml_spec.rb

66 lines
1.6 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'projects/diffs/_viewer.html.haml' do
2017-09-10 17:25:29 +05:30
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') }
2020-03-13 15:44:24 +05:30
let(:viewer) { diff_file.simple_viewer }
2017-09-10 17:25:29 +05:30
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
2020-03-13 15:44:24 +05:30
expect(view).to render_template('projects/diffs/viewers/_collapsed')
2017-09-10 17:25:29 +05:30
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