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/helpers/groups')
-rw-r--r--spec/helpers/groups/group_members_helper_spec.rb15
-rw-r--r--spec/helpers/groups/observability_helper_spec.rb92
2 files changed, 96 insertions, 11 deletions
diff --git a/spec/helpers/groups/group_members_helper_spec.rb b/spec/helpers/groups/group_members_helper_spec.rb
index 0d53225bbcf..4d1280533dd 100644
--- a/spec/helpers/groups/group_members_helper_spec.rb
+++ b/spec/helpers/groups/group_members_helper_spec.rb
@@ -7,16 +7,6 @@ RSpec.describe Groups::GroupMembersHelper do
let_it_be(:group) { create(:group) }
- describe '.group_member_select_options' do
- before do
- helper.instance_variable_set(:@group, group)
- end
-
- it 'returns an options hash' do
- expect(helper.group_member_select_options).to include(multiple: true, scope: :all, email_user: true)
- end
- end
-
describe '#group_members_app_data' do
include_context 'group_group_link'
@@ -36,6 +26,7 @@ RSpec.describe Groups::GroupMembersHelper do
allow(helper).to receive(:group_group_member_path).with(shared_group, ':id').and_return('/groups/foo-bar/-/group_members/:id')
allow(helper).to receive(:group_group_link_path).with(shared_group, ':id').and_return('/groups/foo-bar/-/group_links/:id')
allow(helper).to receive(:can?).with(current_user, :admin_group_member, shared_group).and_return(true)
+ allow(helper).to receive(:can?).with(current_user, :admin_member_access_request, shared_group).and_return(true)
end
subject do
@@ -63,7 +54,8 @@ RSpec.describe Groups::GroupMembersHelper do
it 'returns expected json' do
expected = {
source_id: shared_group.id,
- can_manage_members: true
+ can_manage_members: true,
+ can_manage_access_requests: true
}
expect(subject).to include(expected)
@@ -109,6 +101,7 @@ RSpec.describe Groups::GroupMembersHelper do
allow(helper).to receive(:group_group_member_path).with(sub_shared_group, ':id').and_return('/groups/foo-bar/-/group_members/:id')
allow(helper).to receive(:group_group_link_path).with(sub_shared_group, ':id').and_return('/groups/foo-bar/-/group_links/:id')
allow(helper).to receive(:can?).with(current_user, :admin_group_member, sub_shared_group).and_return(true)
+ allow(helper).to receive(:can?).with(current_user, :admin_member_access_request, sub_shared_group).and_return(true)
allow(helper).to receive(:can?).with(current_user, :export_group_memberships, sub_shared_group).and_return(true)
end
diff --git a/spec/helpers/groups/observability_helper_spec.rb b/spec/helpers/groups/observability_helper_spec.rb
new file mode 100644
index 00000000000..4393f4e9bec
--- /dev/null
+++ b/spec/helpers/groups/observability_helper_spec.rb
@@ -0,0 +1,92 @@
+# frozen_string_literal: true
+
+require "spec_helper"
+
+RSpec.describe Groups::ObservabilityHelper do
+ let(:group) { build_stubbed(:group) }
+ let(:observability_url) { Gitlab::Observability.observability_url }
+
+ describe '#observability_iframe_src' do
+ context 'if observability_path is missing from params' do
+ it 'returns the iframe src for action: dashboards' do
+ allow(helper).to receive(:params).and_return({ action: 'dashboards' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/#{group.id}/")
+ end
+
+ it 'returns the iframe src for action: manage' do
+ allow(helper).to receive(:params).and_return({ action: 'manage' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/#{group.id}/dashboards")
+ end
+
+ it 'returns the iframe src for action: explore' do
+ allow(helper).to receive(:params).and_return({ action: 'explore' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/#{group.id}/explore")
+ end
+ end
+
+ context 'if observability_path exists in params' do
+ context 'if observability_path is valid' do
+ it 'returns the iframe src by injecting the observability path' do
+ allow(helper).to receive(:params).and_return({ action: '/explore', observability_path: '/foo?bar=foobar' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/#{group.id}/foo?bar=foobar")
+ end
+ end
+
+ context 'if observability_path is not valid' do
+ it 'returns the iframe src by injecting the sanitised observability path' do
+ allow(helper).to receive(:params).and_return({
+ action: '/explore',
+ observability_path:
+ "/test?groupId=<script>alert('attack!')</script>"
+ })
+ expect(helper.observability_iframe_src(group)).to eq(
+ "#{observability_url}/#{group.id}/test?groupId=alert('attack!')"
+ )
+ end
+ end
+ end
+
+ context 'when observability ui is standalone' do
+ before do
+ stub_env('STANDALONE_OBSERVABILITY_UI', 'true')
+ end
+
+ it 'returns the iframe src without group.id for action: dashboards' do
+ allow(helper).to receive(:params).and_return({ action: 'dashboards' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/")
+ end
+
+ it 'returns the iframe src without group.id for action: manage' do
+ allow(helper).to receive(:params).and_return({ action: 'manage' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/dashboards")
+ end
+
+ it 'returns the iframe src without group.id for action: explore' do
+ allow(helper).to receive(:params).and_return({ action: 'explore' })
+ expect(helper.observability_iframe_src(group)).to eq("#{observability_url}/explore")
+ end
+ end
+ end
+
+ describe '#observability_page_title' do
+ it 'returns the title for action: dashboards' do
+ allow(helper).to receive(:params).and_return({ action: 'dashboards' })
+ expect(helper.observability_page_title).to eq("Dashboards")
+ end
+
+ it 'returns the title for action: manage' do
+ allow(helper).to receive(:params).and_return({ action: 'manage' })
+ expect(helper.observability_page_title).to eq("Manage Dashboards")
+ end
+
+ it 'returns the title for action: explore' do
+ allow(helper).to receive(:params).and_return({ action: 'explore' })
+ expect(helper.observability_page_title).to eq("Explore")
+ end
+
+ it 'returns the default title for unknown action' do
+ allow(helper).to receive(:params).and_return({ action: 'unknown' })
+ expect(helper.observability_page_title).to eq("Dashboards")
+ end
+ end
+end