Commit 6dbf037c authored by James Fargher's avatar James Fargher

Merge branch '214434-fix-1' into 'master'

Ensure specs are under saas context when needed

See merge request gitlab-org/gitlab!72481
parents b0267c1c 20b587a3
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Groups::BillingsController do
RSpec.describe Groups::BillingsController, :saas do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :private) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Projects::RunnersController do
RSpec.describe Projects::RunnersController, :saas do
let_it_be(:user) { create(:user) }
let_it_be(:namespace) { create(:namespace) }
......@@ -19,7 +19,6 @@ RSpec.describe Projects::RunnersController do
before do
create(:gitlab_subscription, namespace: namespace, hosted_plan: create(:free_plan))
allow(::Gitlab).to receive(:com?).and_return(true)
sign_in(user)
project.add_maintainer(user)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Projects::Settings::AccessTokensController do
RSpec.describe Projects::Settings::AccessTokensController, :saas do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group_with_plan, plan: :bronze_plan) }
let_it_be(:project) { create(:project, group: group) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe TrialsController do
RSpec.describe TrialsController, :saas do
let_it_be(:user) { create(:user, email_opted_in: true, last_name: 'Doe') }
let_it_be(:remove_known_trial_form_fields_context) do
{
......
# frozen_string_literal: true
FactoryBot.modify do
factory :plan_limits do
trait :free_plan do
plan factory: :free_plan
end
end
end
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Billings > Qrtly Reconciliation Alert', :js do
RSpec.describe 'Billings > Qrtly Reconciliation Alert', :js, :saas do
include SubscriptionPortalHelpers
let_it_be(:user) { create(:user) }
......
......@@ -37,7 +37,7 @@ RSpec.describe 'Boards licensed features', :js do
let_it_be(:list) { create(:backlog_list, board: board) }
end
context "GitLab SaaS" do
context "GitLab SaaS", :saas do
let_it_be(:plan_license) { :free }
let_it_be(:global_license) { create(:license) }
......
......@@ -21,7 +21,7 @@ RSpec.describe 'Dashboard operations', :js do
expect(page).to have_text(pipeline.status)
end
context 'when opened on gitlab.com' do
context 'when opened on gitlab.com', :sass do
before do
stub_application_setting(check_namespace_plan: true)
stub_licensed_features(operations_dashboard: true)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Groups > Billing', :js do
RSpec.describe 'Groups > Billing', :js, :saas do
include StubRequests
include SubscriptionPortalHelpers
......@@ -23,7 +23,6 @@ RSpec.describe 'Groups > Billing', :js do
end
before do
allow(Gitlab).to receive(:com?).and_return(true)
stub_application_setting(check_namespace_plan: true)
sign_in(user)
......
......@@ -34,7 +34,7 @@ RSpec.describe 'Group information', :js, :aggregate_failures do
let(:user) { create(:user, group_view: :security_dashboard) }
context 'and Security Dashboard feature is not available for a group' do
context 'and Security Dashboard feature is not available for a group', :saas do
let(:group) { create(:group_with_plan, plan: :bronze_plan) }
it 'displays the "Security Dashboard unavailable" empty state' do
......@@ -58,7 +58,7 @@ RSpec.describe 'Group information', :js, :aggregate_failures do
it_behaves_like 'a hidden qrtly reconciliation alert'
end
context 'on dotcom' do
context 'on dotcom', :saas do
before do
stub_ee_application_setting(should_check_namespace_plan: true)
end
......
......@@ -42,7 +42,7 @@ RSpec.describe 'Groups > Push Rules', :js do
expect(page).to have_content(title)
end
describe 'with GL.com plans' do
describe 'with GL.com plans', :saas do
before do
stub_application_setting(check_namespace_plan: true)
end
......
......@@ -125,7 +125,7 @@ RSpec.describe 'Epic in issue sidebar', :js do
it_behaves_like 'epic in issue sidebar'
context 'with namespaced plans' do
context 'with namespaced plans', :saas do
before do
stub_application_setting(check_namespace_plan: true)
end
......
......@@ -360,7 +360,7 @@ RSpec.describe 'New project', :js do
end
end
context 'when namespace is supposed to be checked' do
context 'when namespace is supposed to be checked', :saas do
context 'when in proper plan' do
context 'when creating project from top-level group with templates' do
let(:url) { new_project_path(namespace_id: group1.id) }
......
......@@ -34,7 +34,7 @@ RSpec.describe GroupProjectsFinder do
let!(:project_with_security_scans) { create(:project, :with_security_scans, :public, group: group) }
let!(:project_without_security_scans) { create(:project, :public, group: group) }
context 'when security dashboard is enabled for a group' do
context 'when security dashboard is enabled for a group', :saas do
let(:group) { create(:group_with_plan, plan: :ultimate_plan) } # overriding group from 'GroupProjectsFinder context'
before do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe GroupsWithTemplatesFinder do
RSpec.describe GroupsWithTemplatesFinder, :saas do
let_it_be(:group_1, reload: true) { create(:group, name: 'group-1') }
let_it_be(:group_2, reload: true) { create(:group, name: 'group-2') }
let_it_be(:group_3, reload: true) { create(:group, name: 'group-3') }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe BillingPlansHelper do
RSpec.describe BillingPlansHelper, :saas do
include Devise::Test::ControllerHelpers
before do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe EE::SubscribableBannerHelper do
RSpec.describe EE::SubscribableBannerHelper, :saas do
describe '#renew_subscription_path' do
it 'does not raise error if available project is not persisted' do
assign(:project, Project.new)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::ExpiringSubscriptionMessage do
RSpec.describe Gitlab::ExpiringSubscriptionMessage, :saas do
include ActionView::Helpers::SanitizeHelper
describe 'message' do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::GroupPlansPreloader do
RSpec.describe Gitlab::GroupPlansPreloader, :saas do
describe '#preload' do
let!(:plan1) { create(:free_plan, name: 'plan-1') }
let!(:plan2) { create(:free_plan, name: 'plan-2') }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Ci::Build do
RSpec.describe Ci::Build, :saas do
let_it_be(:group) { create(:group_with_plan, plan: :bronze_plan) }
let(:project) { create(:project, :repository, group: group) }
......
......@@ -675,7 +675,7 @@ RSpec.describe Group do
is_expected.to be true
end
context 'when in need of checking plan' do
context 'when in need of checking plan', :saas do
before do
allow(Gitlab::CurrentSettings.current_application_settings)
.to receive(:should_check_namespace_plan?).and_return(true)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe EE::Namespace::RootStorageSize do
RSpec.describe EE::Namespace::RootStorageSize, :saas do
let(:namespace) { create(:namespace) }
let(:current_size) { 50.megabytes }
let(:model) { described_class.new(namespace) }
......
......@@ -140,7 +140,7 @@ RSpec.describe GroupMember do
end
end
context 'group member webhooks', :sidekiq_inline do
context 'group member webhooks', :sidekiq_inline, :saas do
let_it_be_with_refind(:group) { create(:group_with_plan, plan: :ultimate_plan) }
let_it_be(:group_hook) { create(:group_hook, group: group, member_events: true) }
let_it_be(:user) { create(:user) }
......@@ -247,7 +247,7 @@ RSpec.describe GroupMember do
end
end
context 'group member welcome email', :sidekiq_inline do
context 'group member welcome email', :sidekiq_inline, :saas do
let_it_be(:group) { create(:group_with_plan, plan: :ultimate_plan) }
let(:user) { create(:user) }
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
RSpec.describe EE::ProjectHook do
describe '#rate_limit' do
let_it_be(:default_limits) { create(:plan_limits, :default_plan, web_hook_calls: 100) }
describe '#rate_limit', :saas do
let_it_be(:default_limits) { create(:plan_limits, :free_plan, web_hook_calls: 100) }
let_it_be(:ultimate_limits) { create(:plan_limits, plan: create(:ultimate_plan), web_hook_calls: 500) }
let_it_be(:group) { create(:group) }
......
......@@ -11,8 +11,8 @@ RSpec.describe GroupHook do
subject { build(:group_hook, group: create(:group)) }
end
describe '#rate_limit' do
let_it_be(:default_limits) { create(:plan_limits, :default_plan, web_hook_calls: 100) }
describe '#rate_limit', :saas do
let_it_be(:default_limits) { create(:plan_limits, :free_plan, web_hook_calls: 100) }
let_it_be(:ultimate_limits) { create(:plan_limits, plan: create(:ultimate_plan), web_hook_calls: 500) }
let_it_be(:group) { create(:group) }
......
......@@ -1838,7 +1838,7 @@ RSpec.describe Project do
end
end
describe '#licensed_features' do
describe '#licensed_features', :saas do
let(:plan_license) { :free }
let(:global_license) { create(:license) }
let(:group) { create(:group) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe PushRule do
RSpec.describe PushRule, :saas do
using RSpec::Parameterized::TableSyntax
let(:global_push_rule) { create(:push_rule_sample) }
......
......@@ -404,7 +404,7 @@ RSpec.describe GroupPolicy do
end
end
context 'when group_saml_group_sync is licensed' do
context 'when group_saml_group_sync is licensed', :saas do
before do
stub_group_saml_config(true)
stub_application_setting(check_namespace_plan: true)
......@@ -1411,7 +1411,7 @@ RSpec.describe GroupPolicy do
end
end
it_behaves_like 'model with wiki policies' do
it_behaves_like 'model with wiki policies', :saas do
let_it_be_with_refind(:container) { create(:group_with_plan, plan: :premium_plan) }
let_it_be(:user) { owner }
......@@ -1447,16 +1447,12 @@ RSpec.describe GroupPolicy do
it_behaves_like 'update namespace limit policy'
context 'group access tokens' do
context 'group access tokens', :saas do
it_behaves_like 'GitLab.com Core resource access tokens'
context 'on GitLab.com paid' do
let_it_be(:group) { create(:group_with_plan, plan: :bronze_plan) }
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'with owner' do
let(:current_user) { owner }
......
......@@ -1734,14 +1734,10 @@ RSpec.describe ProjectPolicy do
context 'project access tokens' do
it_behaves_like 'GitLab.com Core resource access tokens'
context 'on GitLab.com paid' do
context 'on GitLab.com paid', :saas do
let_it_be(:group) { create(:group_with_plan, plan: :bronze_plan) }
let_it_be(:project) { create(:project, group: group) }
before do
allow(::Gitlab).to receive(:com?).and_return(true)
end
context 'with maintainer access' do
let(:current_user) { maintainer }
......
......@@ -608,7 +608,7 @@ RSpec.describe API::Groups do
subject { get api("/groups/#{group.id}/projects", user), params: { with_security_reports: true } }
context 'when security dashboard is enabled for a group' do
context 'when security dashboard is enabled for a group', :saas do
let(:group) { create(:group_with_plan, plan: :ultimate_plan) } # overriding group from parent context
before do
......@@ -889,7 +889,7 @@ RSpec.describe API::Groups do
end
end
it 'does not mark the group for deletion when the group has a paid gitlab.com subscription' do
it 'does not mark the group for deletion when the group has a paid gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subject
......@@ -900,7 +900,7 @@ RSpec.describe API::Groups do
expect(group.deleting_user).to be_nil
end
it 'marks for deletion a subgroup of a group with a paid gitlab.com subscription' do
it 'marks for deletion a subgroup of a group with a paid gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......@@ -928,7 +928,7 @@ RSpec.describe API::Groups do
it_behaves_like 'immediately enqueues the job to delete the group'
it 'does not delete the group when the group has a paid gitlab.com subscription' do
it 'does not delete the group when the group has a paid gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
expect { subject }.not_to change(GroupDestroyWorker.jobs, :size)
......@@ -936,7 +936,7 @@ RSpec.describe API::Groups do
expect(json_response['message']).to eq("This group can't be removed because it is linked to a subscription.")
end
it 'deletes a subgroup of a group with a paid gitlab.com subscription' do
it 'deletes a subgroup of a group with a paid gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......
......@@ -546,7 +546,7 @@ RSpec.describe API::Members do
expect(json_response).to eq({ 'message' => '404 Group Not Found' })
end
it 'returns not found when the user is not billable' do
it 'returns not found when the user is not billable', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
get api("/groups/#{group.id}/billable_members/#{guest.id}/memberships", owner)
......
......@@ -205,7 +205,7 @@ RSpec.describe API::Users do
describe 'GET /user/:id' do
context 'when authenticated' do
context 'as an admin' do
context 'and user has a plan' do
context 'and user has a plan', :saas do
let!(:subscription) { create(:gitlab_subscription, :ultimate, namespace: user.namespace) }
context 'and user is not a trial user' do
......
......@@ -335,7 +335,7 @@ RSpec.describe GroupsController, type: :request do
end
end
describe 'PUT #transfer' do
describe 'PUT #transfer', :saas do
let(:new_parent_group) { create(:group) }
before do
......@@ -373,7 +373,7 @@ RSpec.describe GroupsController, type: :request do
login_as(user)
end
it 'does not delete a group with a gitlab.com subscription' do
it 'does not delete a group with a gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
Sidekiq::Testing.fake! do
......@@ -382,7 +382,7 @@ RSpec.describe GroupsController, type: :request do
end
end
it 'deletes a subgroup with a parent group with a gitlab.com subscription' do
it 'deletes a subgroup with a parent group with a gitlab.com subscription', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......
......@@ -87,7 +87,7 @@ RSpec.describe Dashboard::Projects::ListService do
end
end
describe 'checking plans' do
describe 'checking plans', :saas do
let(:projects) { [project] }
using RSpec::Parameterized::TableSyntax
......@@ -124,7 +124,7 @@ RSpec.describe Dashboard::Projects::ListService do
end
end
describe 'checking availability of public projects on GitLab.com' do
describe 'checking availability of public projects on GitLab.com', :saas do
let(:projects) { [project] }
using RSpec::Parameterized::TableSyntax
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Members::InviteService, :aggregate_failures do
RSpec.describe Members::InviteService, :aggregate_failures, :saas do
let_it_be(:user) { create(:user) }
let_it_be(:root_ancestor) { create(:group) }
let_it_be(:project, reload: true) { create(:project, group: root_ancestor) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe GitlabSubscriptions::CheckFutureRenewalService, :use_clean_rails_memory_store_caching do
RSpec.describe GitlabSubscriptions::CheckFutureRenewalService, :use_clean_rails_memory_store_caching, :saas do
using RSpec::Parameterized::TableSyntax
describe '#execute' do
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute' do
RSpec.describe Namespaces::InProductMarketingEmailsService, '#execute', :saas do
let(:frozen_time) { Time.zone.parse('23 Mar 2021 10:14:40 UTC') }
let_it_be(:user) { create(:user, email_opted_in: true) }
......
......@@ -144,7 +144,7 @@ RSpec.describe Projects::CreateService, '#execute' do
end
end
context 'when licensed on a namespace' do
context 'when licensed on a namespace', :saas do
it 'allows enabling mirrors' do
create(:gitlab_subscription, :ultimate, namespace: user.namespace)
......
......@@ -114,11 +114,11 @@ RSpec.describe Projects::TransferService do
end
describe 'updating paid features' do
let_it_be(:premium_group) { create(:group_with_plan, plan: :premium_plan) }
let(:premium_group) { create(:group_with_plan, plan: :premium_plan) }
let_it_be(:free_group) { create(:group) }
before do
premium_group.add_owner(user)
free_group.add_owner(user)
end
......@@ -143,8 +143,9 @@ RSpec.describe Projects::TransferService do
end
end
context 'with GL.com' do
context 'with GL.com', :saas do
before do
premium_group.add_owner(user)
stub_ee_application_setting(should_check_namespace_plan: true)
end
......@@ -164,12 +165,13 @@ RSpec.describe Projects::TransferService do
end
end
describe 'pipeline subscriptions' do
describe 'pipeline subscriptions', :saas do
let_it_be(:project_2) { create(:project, :public) }
before do
project.upstream_project_subscriptions.create!(upstream_project: project_2)
stub_ee_application_setting(should_check_namespace_plan: true)
premium_group.add_owner(user)
end
context 'when target namespace has a premium plan' do
......@@ -191,7 +193,7 @@ RSpec.describe Projects::TransferService do
end
end
describe 'test cases' do
describe 'test cases', :saas do
before do
create(:quality_test_case, project: project, author: user)
stub_ee_application_setting(should_check_namespace_plan: true)
......
......@@ -9,7 +9,7 @@ RSpec.describe Projects::UpdateService, '#execute' do
let(:admin) { create(:user, :admin) }
let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) }
context 'shared runners' do
context 'shared runners', :saas do
let(:opts) { { shared_runners_enabled: enabled } }
let(:enabled) { true }
......
......@@ -14,7 +14,7 @@ RSpec.describe 'groups/settings/_remove.html.haml' do
expect(rendered).not_to have_selector '[data-testid="group-has-linked-subscription-alert"]'
end
it 'disables the Remove group button and shows an alert for a group with a paid gitlab.com plan' do
it 'disables the Remove group button and shows an alert for a group with a paid gitlab.com plan', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
render 'groups/settings/remove', group: group
......@@ -23,7 +23,7 @@ RSpec.describe 'groups/settings/_remove.html.haml' do
expect(rendered).to have_selector '[data-testid="group-has-linked-subscription-alert"]'
end
it 'disables the Remove group button and shows an alert for a group with a legacy paid gitlab.com plan' do
it 'disables the Remove group button and shows an alert for a group with a legacy paid gitlab.com plan', :saas do
create(:gitlab_subscription, :gold, namespace: group)
render 'groups/settings/remove', group: group
......@@ -32,7 +32,7 @@ RSpec.describe 'groups/settings/_remove.html.haml' do
expect(rendered).to have_selector '[data-testid="group-has-linked-subscription-alert"]'
end
it 'enables the Remove group button and does not show an alert for a subgroup' do
it 'enables the Remove group button and does not show an alert for a subgroup', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......@@ -56,7 +56,7 @@ RSpec.describe 'groups/settings/_remove.html.haml' do
expect(rendered).not_to have_selector '[data-testid="group-has-linked-subscription-alert"]'
end
it 'disables the Remove group button and shows an alert for a group with a paid gitlab.com plan' do
it 'disables the Remove group button and shows an alert for a group with a paid gitlab.com plan', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
render 'groups/settings/remove', group: group
......@@ -65,7 +65,7 @@ RSpec.describe 'groups/settings/_remove.html.haml' do
expect(rendered).to have_selector '[data-testid="group-has-linked-subscription-alert"]'
end
it 'enables the Remove group button and does not show an alert for a subgroup' do
it 'enables the Remove group button and does not show an alert for a subgroup', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......
......@@ -14,7 +14,7 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
expect(rendered).not_to have_selector '[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
it 'disables the Select parent group dropdown and shows an alert for a group with a paid gitlab.com plan' do
it 'disables the Select parent group dropdown and shows an alert for a group with a paid gitlab.com plan', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
render 'groups/settings/transfer', group: group
......@@ -23,7 +23,7 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do
expect(rendered).to have_selector '[data-testid="group-to-transfer-has-linked-subscription-alert"]'
end
it 'enables the Select parent group dropdown and does not show an alert for a subgroup' do
it 'enables the Select parent group dropdown and does not show an alert for a subgroup', :saas do
create(:gitlab_subscription, :ultimate, namespace: group)
subgroup = create(:group, parent: group)
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'shared/billings/_trial_status.html.haml' do
RSpec.describe 'shared/billings/_trial_status.html.haml', :saas do
include ApplicationHelper
let_it_be(:group) { create(:group) }
......@@ -12,6 +12,8 @@ RSpec.describe 'shared/billings/_trial_status.html.haml' do
let(:trial) { false }
before do
allow(group).to receive(:eligible_for_trial?).and_return(false)
create(:gitlab_subscription, namespace: group, hosted_plan: plan, trial_ends_on: trial_ends_on, trial: trial)
end
......@@ -80,7 +82,7 @@ RSpec.describe 'shared/billings/_trial_status.html.haml' do
context 'when eligible for trial' do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
allow(group).to receive(:eligible_for_trial?).and_return(true)
end
it 'offers a trial' do
......
......@@ -162,7 +162,7 @@ RSpec.describe UpdateAllMirrorsWorker do
end
end
context 'when the instance checks namespace plans' do
context 'when the instance checks namespace plans', :saas do
def scheduled_mirror(at:, licensed:, public: false, subgroup: nil)
group_args = [:group, :public, subgroup && :nested].compact
namespace = create(*group_args) # rubocop:disable Rails/SaveBang
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment