debian-mirror-gitlab/spec/models/release_spec.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2019-05-18 00:54:41 +05:30
# frozen_string_literal: true
2015-11-26 14:37:03 +05:30
require 'rails_helper'
2017-09-10 17:25:29 +05:30
RSpec.describe Release do
2019-02-15 15:39:39 +05:30
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:release) { create(:release, project: project, author: user) }
2015-11-26 14:37:03 +05:30
it { expect(release).to be_valid }
describe 'associations' do
it { is_expected.to belong_to(:project) }
2019-02-15 15:39:39 +05:30
it { is_expected.to belong_to(:author).class_name('User') }
it { is_expected.to have_many(:links).class_name('Releases::Link') }
2015-11-26 14:37:03 +05:30
end
describe 'validation' do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:description) }
end
2019-02-15 15:39:39 +05:30
describe '#assets_count' do
subject { release.assets_count }
it 'returns the number of sources' do
is_expected.to eq(Releases::Source::FORMATS.count)
end
context 'when a links exists' do
let!(:link) { create(:release_link, release: release) }
it 'counts the link as an asset' do
is_expected.to eq(1 + Releases::Source::FORMATS.count)
end
end
end
describe '#sources' do
subject { release.sources }
it 'returns sources' do
is_expected.to all(be_a(Releases::Source))
end
end
2015-11-26 14:37:03 +05:30
end