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>2023-10-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/support/shared_examples/models/issuable_link_shared_examples.rb
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/support/shared_examples/models/issuable_link_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/models/issuable_link_shared_examples.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/support/shared_examples/models/issuable_link_shared_examples.rb b/spec/support/shared_examples/models/issuable_link_shared_examples.rb
index af96b77edaf..f28abb35128 100644
--- a/spec/support/shared_examples/models/issuable_link_shared_examples.rb
+++ b/spec/support/shared_examples/models/issuable_link_shared_examples.rb
@@ -52,6 +52,45 @@ RSpec.shared_examples 'issuable link' do
end
end
+ context 'when max number of links is exceeded' do
+ subject(:link) { create_issuable_link(issuable, issuable2) }
+
+ shared_examples 'invalid due to exceeding max number of links' do
+ let(:stubbed_limit) { 1 }
+ let(:issuable_name) { described_class.issuable_name }
+ let(:error_msg) do
+ "This #{issuable_name} would exceed the maximum number of " \
+ "linked #{issuable_name.pluralize} (#{stubbed_limit})."
+ end
+
+ before do
+ create(issuable_link_factory, source: source, target: target)
+ stub_const("IssuableLink::MAX_LINKS_COUNT", stubbed_limit)
+ end
+
+ specify do
+ is_expected.to be_invalid
+ expect(link.errors.messages[error_item]).to include(error_msg)
+ end
+ end
+
+ context 'when source exceeds max' do
+ let(:source) { issuable }
+ let(:target) { issuable3 }
+ let(:error_item) { :source }
+
+ it_behaves_like 'invalid due to exceeding max number of links'
+ end
+
+ context 'when target exceeds max' do
+ let(:source) { issuable2 }
+ let(:target) { issuable3 }
+ let(:error_item) { :target }
+
+ it_behaves_like 'invalid due to exceeding max number of links'
+ end
+ end
+
def create_issuable_link(source, target)
build(issuable_link_factory, source: source, target: target)
end