debian-mirror-gitlab/spec/models/blob_viewer/license_spec.rb

38 lines
890 B
Ruby
Raw Permalink Normal View History

2019-07-07 11:18:12 +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 BlobViewer::License do
2017-09-10 17:25:29 +05:30
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
let(:blob) { fake_blob(path: 'LICENSE') }
2020-03-09 13:42:32 +05:30
2017-09-10 17:25:29 +05:30
subject { described_class.new(blob) }
describe '#license' do
it 'returns the blob project repository license' do
expect(subject.license).not_to be_nil
expect(subject.license).to eq(project.repository.license)
end
end
describe '#render_error' do
context 'when there is no license' do
before do
allow(project.repository).to receive(:license).and_return(nil)
end
it 'returns :unknown_license' do
expect(subject.render_error).to eq(:unknown_license)
end
end
context 'when there is a license' do
it 'returns nil' do
expect(subject.render_error).to be_nil
end
end
end
end