diff options
Diffstat (limited to 'spec/helpers/projects')
-rw-r--r-- | spec/helpers/projects/alert_management_helper_spec.rb | 33 | ||||
-rw-r--r-- | spec/helpers/projects/incidents_helper_spec.rb | 49 | ||||
-rw-r--r-- | spec/helpers/projects/security/configuration_helper_spec.rb | 2 |
3 files changed, 40 insertions, 44 deletions
diff --git a/spec/helpers/projects/alert_management_helper_spec.rb b/spec/helpers/projects/alert_management_helper_spec.rb index 2450f7838b3..0a5c4bedaa6 100644 --- a/spec/helpers/projects/alert_management_helper_spec.rb +++ b/spec/helpers/projects/alert_management_helper_spec.rb @@ -34,7 +34,6 @@ RSpec.describe Projects::AlertManagementHelper do 'empty-alert-svg-path' => match_asset_path('/assets/illustrations/alert-management-empty-state.svg'), 'user-can-enable-alert-management' => 'true', 'alert-management-enabled' => 'false', - 'has-managed-prometheus' => 'false', 'text-query': nil, 'assignee-username-query': nil ) @@ -45,52 +44,26 @@ RSpec.describe Projects::AlertManagementHelper do let_it_be(:prometheus_integration) { create(:prometheus_integration, project: project) } context 'when manual prometheus integration is active' do - it "enables alert management and doesn't show managed prometheus" do + it "enables alert management" do prometheus_integration.update!(manual_configuration: true) expect(data).to include( 'alert-management-enabled' => 'true' ) - expect(data).to include( - 'has-managed-prometheus' => 'false' - ) - end - end - - context 'when a cluster prometheus is available' do - let(:cluster) { create(:cluster, projects: [project]) } - - it 'has managed prometheus' do - create(:clusters_integrations_prometheus, cluster: cluster) - - expect(data).to include( - 'has-managed-prometheus' => 'true' - ) end end - context 'when prometheus integration is inactive' do - it 'disables alert management and hides managed prometheus' do + context 'when prometheus service is inactive' do + it 'disables alert management' do prometheus_integration.update!(manual_configuration: false) expect(data).to include( 'alert-management-enabled' => 'false' ) - expect(data).to include( - 'has-managed-prometheus' => 'false' - ) end end end - context 'without prometheus integration' do - it "doesn't have managed prometheus" do - expect(data).to include( - 'has-managed-prometheus' => 'false' - ) - end - end - context 'with http integration' do let_it_be(:integration) { create(:alert_management_http_integration, project: project) } diff --git a/spec/helpers/projects/incidents_helper_spec.rb b/spec/helpers/projects/incidents_helper_spec.rb index 7a8a6d5222f..d0dc18d56b0 100644 --- a/spec/helpers/projects/incidents_helper_spec.rb +++ b/spec/helpers/projects/incidents_helper_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe Projects::IncidentsHelper do include Gitlab::Routing.url_helpers - let(:project) { create(:project) } + let(:user) { build_stubbed(:user) } + let(:project) { build_stubbed(:project) } let(:project_path) { project.full_path } let(:new_issue_path) { new_project_issue_path(project) } let(:issue_path) { project_issues_path(project) } @@ -17,21 +18,43 @@ RSpec.describe Projects::IncidentsHelper do } end + before do + allow(helper).to receive(:current_user).and_return(user) + allow(helper).to receive(:can?) + .with(user, :create_incident, project) + .and_return(can_create_incident) + end + describe '#incidents_data' do subject(:data) { helper.incidents_data(project, params) } - it 'returns frontend configuration' do - expect(data).to include( - 'project-path' => project_path, - 'new-issue-path' => new_issue_path, - 'incident-template-name' => 'incident', - 'incident-type' => 'incident', - 'issue-path' => issue_path, - 'empty-list-svg-path' => match_asset_path('/assets/illustrations/incident-empty-state.svg'), - 'text-query': 'search text', - 'author-username-query': 'root', - 'assignee-username-query': 'max.power' - ) + shared_examples 'frontend configuration' do + it 'returns frontend configuration' do + expect(data).to include( + 'project-path' => project_path, + 'new-issue-path' => new_issue_path, + 'incident-template-name' => 'incident', + 'incident-type' => 'incident', + 'issue-path' => issue_path, + 'empty-list-svg-path' => match_asset_path('/assets/illustrations/incident-empty-state.svg'), + 'text-query': 'search text', + 'author-username-query': 'root', + 'assignee-username-query': 'max.power', + 'can-create-incident': can_create_incident.to_s + ) + end + end + + context 'when user can create incidents' do + let(:can_create_incident) { true } + + include_examples 'frontend configuration' + end + + context 'when user cannot create incidents' do + let(:can_create_incident) { false } + + include_examples 'frontend configuration' end end end diff --git a/spec/helpers/projects/security/configuration_helper_spec.rb b/spec/helpers/projects/security/configuration_helper_spec.rb index c5049bd87f0..4c30ba87897 100644 --- a/spec/helpers/projects/security/configuration_helper_spec.rb +++ b/spec/helpers/projects/security/configuration_helper_spec.rb @@ -8,6 +8,6 @@ RSpec.describe Projects::Security::ConfigurationHelper do describe 'security_upgrade_path' do subject { security_upgrade_path } - it { is_expected.to eq('https://about.gitlab.com/pricing/') } + it { is_expected.to eq("https://#{ApplicationHelper.promo_host}/pricing/") } end end |