diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/models/jira_connect_installation_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/models/jira_connect_installation_spec.rb')
-rw-r--r-- | spec/models/jira_connect_installation_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/jira_connect_installation_spec.rb b/spec/models/jira_connect_installation_spec.rb new file mode 100644 index 00000000000..8ef96114c45 --- /dev/null +++ b/spec/models/jira_connect_installation_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe JiraConnectInstallation do + describe 'associations' do + it { is_expected.to have_many(:subscriptions).class_name('JiraConnectSubscription') } + end + + describe 'validations' do + it { is_expected.to validate_presence_of(:client_key) } + it { is_expected.to validate_uniqueness_of(:client_key) } + it { is_expected.to validate_presence_of(:shared_secret) } + it { is_expected.to validate_presence_of(:base_url) } + + it { is_expected.to allow_value('https://test.atlassian.net').for(:base_url) } + it { is_expected.not_to allow_value('not/a/url').for(:base_url) } + end + + describe '.for_project' do + let(:other_group) { create(:group) } + let(:parent_group) { create(:group) } + let(:group) { create(:group, parent: parent_group) } + let(:project) { create(:project, group: group) } + + subject { described_class.for_project(project) } + + it 'returns installations with subscriptions for project' do + sub_on_project_namespace = create(:jira_connect_subscription, namespace: group) + sub_on_ancestor_namespace = create(:jira_connect_subscription, namespace: parent_group) + + # Subscription on other group that shouldn't be returned + create(:jira_connect_subscription, namespace: other_group) + + expect(subject).to contain_exactly(sub_on_project_namespace.installation, sub_on_ancestor_namespace.installation) + end + + it 'returns distinct installations' do + subscription = create(:jira_connect_subscription, namespace: group) + create(:jira_connect_subscription, namespace: parent_group, installation: subscription.installation) + + expect(subject).to contain_exactly(subscription.installation) + end + end +end |