2021-01-18 15:10:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe JiraConnectHelper do
|
|
|
|
describe '#jira_connect_app_data' do
|
2021-01-25 18:09:03 +00:00
|
|
|
let_it_be(:subscription) { create(:jira_connect_subscription) }
|
2021-04-19 18:09:09 +00:00
|
|
|
|
2021-01-28 21:09:04 +00:00
|
|
|
let(:user) { create(:user) }
|
2021-01-25 18:09:03 +00:00
|
|
|
|
|
|
|
subject { helper.jira_connect_app_data([subscription]) }
|
2021-01-18 15:10:42 +00:00
|
|
|
|
2021-01-28 21:09:04 +00:00
|
|
|
context 'user is not logged in' do
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:current_user).and_return(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes Jira Connect app attributes' do
|
|
|
|
is_expected.to include(
|
|
|
|
:groups_path,
|
|
|
|
:subscriptions_path,
|
2021-12-02 09:10:59 +00:00
|
|
|
:users_path,
|
|
|
|
:subscriptions,
|
|
|
|
:gitlab_user_path
|
2021-01-28 21:09:04 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns users_path with value' do
|
|
|
|
expect(subject[:users_path]).to eq(jira_connect_users_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'passes group as "skip_groups" param' do
|
|
|
|
skip_groups_param = CGI.escape('skip_groups[]')
|
|
|
|
|
|
|
|
expect(subject[:groups_path]).to include("#{skip_groups_param}=#{subscription.namespace.id}")
|
|
|
|
end
|
2021-12-02 09:10:59 +00:00
|
|
|
|
|
|
|
it 'assigns gitlab_user_path to nil' do
|
|
|
|
expect(subject[:gitlab_user_path]).to be_nil
|
|
|
|
end
|
2021-01-18 15:10:42 +00:00
|
|
|
end
|
2021-01-25 18:09:03 +00:00
|
|
|
|
2021-01-28 21:09:04 +00:00
|
|
|
context 'user is logged in' do
|
|
|
|
before do
|
|
|
|
allow(view).to receive(:current_user).and_return(user)
|
|
|
|
end
|
2021-01-25 18:09:03 +00:00
|
|
|
|
2021-01-28 21:09:04 +00:00
|
|
|
it 'assigns users_path to nil' do
|
|
|
|
expect(subject[:users_path]).to be_nil
|
|
|
|
end
|
2021-12-02 09:10:59 +00:00
|
|
|
|
|
|
|
it 'assigns gitlab_user_path correctly' do
|
|
|
|
expect(subject[:gitlab_user_path]).to eq(user_path(user))
|
|
|
|
end
|
2021-01-25 18:09:03 +00:00
|
|
|
end
|
2021-01-18 15:10:42 +00:00
|
|
|
end
|
|
|
|
end
|