Commit 01cfa570 authored by Mathieu Parent's avatar Mathieu Parent Committed by Kerri Miller

Add Debian scopes to Packages::Package

parent cc9b1e7f
......@@ -91,6 +91,12 @@ class Packages::Package < ApplicationRecord
joins(:conan_metadatum).where(packages_conan_metadata: { package_username: package_username })
end
scope :with_debian_codename, -> (codename) do
debian
.joins(:debian_distribution)
.where(Packages::Debian::ProjectDistribution.table_name => { codename: codename })
end
scope :preload_debian_file_metadata, -> { preload(package_files: :debian_file_metadatum) }
scope :with_composer_target, -> (target) do
includes(:composer_metadatum)
.joins(:composer_metadatum)
......
......@@ -22,6 +22,14 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.to have_one(:rubygems_metadatum).inverse_of(:package) }
end
describe '.with_debian_codename' do
let_it_be(:publication) { create(:debian_publication) }
subject { described_class.with_debian_codename(publication.distribution.codename).to_a }
it { is_expected.to contain_exactly(publication.package) }
end
describe '.with_composer_target' do
let!(:package1) { create(:composer_package, :with_metadatum, sha: '123') }
let!(:package2) { create(:composer_package, :with_metadatum, sha: '123') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment