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:
Diffstat (limited to 'spec/serializers/jira_connect/app_data_serializer_spec.rb')
-rw-r--r--spec/serializers/jira_connect/app_data_serializer_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/serializers/jira_connect/app_data_serializer_spec.rb b/spec/serializers/jira_connect/app_data_serializer_spec.rb
new file mode 100644
index 00000000000..9c10a8a54a1
--- /dev/null
+++ b/spec/serializers/jira_connect/app_data_serializer_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe JiraConnect::AppDataSerializer do
+ describe '#as_json' do
+ subject(:app_data_json) { described_class.new(subscriptions, signed_in).as_json }
+
+ let_it_be(:subscriptions) { create_list(:jira_connect_subscription, 2) }
+
+ let(:signed_in) { false }
+
+ it 'uses the subscription entity' do
+ expect(JiraConnect::SubscriptionEntity).to receive(:represent).with(subscriptions)
+
+ app_data_json
+ end
+
+ it 'includes a group path with already subscribed namespaces as skip_groups' do
+ expected_path = "/api/v4/groups?min_access_level=40&skip_groups%5B%5D=#{subscriptions.first.namespace_id}&skip_groups%5B%5D=#{subscriptions.last.namespace_id}"
+
+ expect(app_data_json).to include(groups_path: expected_path)
+ end
+
+ it { is_expected.to include(subscriptions_path: '/-/jira_connect/subscriptions') }
+ it { is_expected.to include(login_path: '/-/jira_connect/users') }
+
+ context 'when signed in' do
+ let(:signed_in) { true }
+
+ it { is_expected.to include(login_path: nil) }
+ end
+ end
+end