Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-14 00:11:00 +0300
commitacba9e99b4f8bfeaaed143b72b07170a8506f893 (patch)
tree3f79c9c68e59c42c79dec7d4b353a3bbb3e118e0 /spec/support
parent716896e8cac8a516cd36efada8c8c5f383b63f62 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_examples/models/packages/debian/architecture_shared_examples.rb48
-rw-r--r--spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb2
2 files changed, 50 insertions, 0 deletions
diff --git a/spec/support/shared_examples/models/packages/debian/architecture_shared_examples.rb b/spec/support/shared_examples/models/packages/debian/architecture_shared_examples.rb
new file mode 100644
index 00000000000..38983f752f4
--- /dev/null
+++ b/spec/support/shared_examples/models/packages/debian/architecture_shared_examples.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.shared_examples 'Debian Distribution Architecture' do |factory, container, can_freeze|
+ let_it_be_with_refind(:architecture) { create(factory) } # rubocop:disable Rails/SaveBang
+ let_it_be(:architecture_same_distribution, freeze: can_freeze) { create(factory, distribution: architecture.distribution) }
+ let_it_be(:architecture_same_name, freeze: can_freeze) { create(factory, name: architecture.name) }
+
+ subject { architecture }
+
+ describe 'relationships' do
+ it { is_expected.to belong_to(:distribution).class_name("Packages::Debian::#{container.capitalize}Distribution").inverse_of(:architectures) }
+ end
+
+ describe 'validations' do
+ describe "#distribution" do
+ it { is_expected.to validate_presence_of(:distribution) }
+ end
+
+ describe '#name' do
+ it { is_expected.to validate_presence_of(:name) }
+
+ it { is_expected.to allow_value('amd64').for(:name) }
+ it { is_expected.to allow_value('kfreebsd-i386').for(:name) }
+ it { is_expected.not_to allow_value('-a').for(:name) }
+ it { is_expected.not_to allow_value('AMD64').for(:name) }
+ end
+ end
+
+ describe 'scopes' do
+ describe '.with_distribution' do
+ subject { described_class.with_distribution(architecture.distribution) }
+
+ it 'does not return other distributions' do
+ expect(subject.to_a).to eq([architecture, architecture_same_distribution])
+ end
+ end
+
+ describe '.with_name' do
+ subject { described_class.with_name(architecture.name) }
+
+ it 'does not return other distributions' do
+ expect(subject.to_a).to eq([architecture, architecture_same_name])
+ end
+ end
+ end
+end
diff --git a/spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb b/spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb
index fcb537c4f17..0befa54d6b2 100644
--- a/spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb
+++ b/spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb
@@ -15,6 +15,8 @@ RSpec.shared_examples 'Debian Distribution' do |factory, container, can_freeze|
describe 'relationships' do
it { is_expected.to belong_to(container) }
it { is_expected.to belong_to(:creator).class_name('User') }
+
+ it { is_expected.to have_many(:architectures).class_name("Packages::Debian::#{container.capitalize}Architecture").inverse_of(:distribution) }
end
describe 'validations' do