summaryrefslogtreecommitdiff
path: root/spec/models/packages/package_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/packages/package_spec.rb')
-rw-r--r--spec/models/packages/package_spec.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb
index 705a1991845..16764673474 100644
--- a/spec/models/packages/package_spec.rb
+++ b/spec/models/packages/package_spec.rb
@@ -111,6 +111,24 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.not_to allow_value('%foo%bar').for(:name) }
end
+ context 'debian package' do
+ subject { build(:debian_package) }
+
+ it { is_expected.to allow_value('0ad').for(:name) }
+ it { is_expected.to allow_value('g++').for(:name) }
+ it { is_expected.not_to allow_value('a_b').for(:name) }
+ end
+
+ context 'debian incoming' do
+ subject { create(:debian_incoming) }
+
+ # Only 'incoming' is accepted
+ it { is_expected.to allow_value('incoming').for(:name) }
+ it { is_expected.not_to allow_value('0ad').for(:name) }
+ it { is_expected.not_to allow_value('g++').for(:name) }
+ it { is_expected.not_to allow_value('a_b').for(:name) }
+ end
+
context 'generic package' do
subject { build_stubbed(:generic_package) }
@@ -180,6 +198,21 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.to allow_value('2.x-dev').for(:version) }
end
+ context 'debian package' do
+ subject { build(:debian_package) }
+
+ it { is_expected.to allow_value('2:4.9.5+dfsg-5+deb10u1').for(:version) }
+ it { is_expected.not_to allow_value('1_0').for(:version) }
+ end
+
+ context 'debian incoming' do
+ subject { create(:debian_incoming) }
+
+ it { is_expected.to allow_value(nil).for(:version) }
+ it { is_expected.not_to allow_value('2:4.9.5+dfsg-5+deb10u1').for(:version) }
+ it { is_expected.not_to allow_value('1_0').for(:version) }
+ end
+
context 'maven package' do
subject { build_stubbed(:maven_package) }
@@ -621,6 +654,46 @@ RSpec.describe Packages::Package, type: :model do
end
end
+ describe '#debian_incoming?' do
+ let(:package) { build(:package) }
+
+ subject { package.debian_incoming? }
+
+ it { is_expected.to eq(false) }
+
+ context 'with debian_incoming' do
+ let(:package) { create(:debian_incoming) }
+
+ it { is_expected.to eq(true) }
+ end
+
+ context 'with debian_package' do
+ let(:package) { create(:debian_package) }
+
+ it { is_expected.to eq(false) }
+ end
+ end
+
+ describe '#debian_package?' do
+ let(:package) { build(:package) }
+
+ subject { package.debian_package? }
+
+ it { is_expected.to eq(false) }
+
+ context 'with debian_incoming' do
+ let(:package) { create(:debian_incoming) }
+
+ it { is_expected.to eq(false) }
+ end
+
+ context 'with debian_package' do
+ let(:package) { create(:debian_package) }
+
+ it { is_expected.to eq(true) }
+ end
+ end
+
describe 'plan_limits' do
Packages::Package.package_types.keys.without('composer').each do |pt|
plan_limit_name = if pt == 'generic'