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

46 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe LfsObjectsProject do
2020-03-09 13:42:32 +05:30
let_it_be(:project) { create(:project) }
2018-03-17 18:26:18 +05:30
subject do
create(:lfs_objects_project, project: project)
end
2017-08-17 22:00:37 +05:30
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:lfs_object) }
end
describe 'validation' do
it { is_expected.to validate_presence_of(:lfs_object_id) }
it { is_expected.to validate_presence_of(:project_id) }
2018-03-17 18:26:18 +05:30
it 'validates object id' do
is_expected.to validate_uniqueness_of(:lfs_object_id)
2019-09-04 21:01:54 +05:30
.scoped_to(:project_id, :repository_type)
.with_message("already exists in repository")
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
end
describe '#update_project_statistics' do
it 'updates project statistics when the object is added' do
expect(ProjectCacheWorker).to receive(:perform_async)
.with(project.id, [], [:lfs_objects_size])
subject.save!
end
it 'updates project statistics when the object is removed' do
subject.save!
expect(ProjectCacheWorker).to receive(:perform_async)
.with(project.id, [], [:lfs_objects_size])
subject.destroy
end
end
end