Commit 789afc4f authored by Max Woolf's avatar Max Woolf

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

Ensure specs are under saas context when needed

See merge request gitlab-org/gitlab!72753
parents 74ac9880 1e2626ad
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External, :saas do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:subscription) { create(:gitlab_subscription, :default, namespace: user.namespace) } let_it_be(:subscription) { create(:gitlab_subscription, :default, namespace: user.namespace) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Activity do RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Activity, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project, reload: true) { create(:project, namespace: namespace) } let_it_be(:project, reload: true) { create(:project, namespace: namespace) }
let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) } let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::JobActivity do RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::JobActivity, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project, reload: true) { create(:project, namespace: namespace) } let_it_be(:project, reload: true) { create(:project, namespace: namespace) }
let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) } let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Size do RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Size, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) } let_it_be(:ultimate_plan, reload: true) { create(:ultimate_plan) }
let_it_be(:project, reload: true) { create(:project, :repository, namespace: namespace) } let_it_be(:project, reload: true) { create(:project, :repository, namespace: namespace) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project) { create(:project, namespace: namespace) } let_it_be(:project) { create(:project, namespace: namespace) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project) { create(:project, namespace: namespace) } let_it_be(:project) { create(:project, namespace: namespace) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size, :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:project, reload: true) { create(:project, :repository, namespace: namespace) } let_it_be(:project, reload: true) { create(:project, :repository, namespace: namespace) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::CreatePipelineService, '#execute' do RSpec.describe Ci::CreatePipelineService, '#execute', :saas do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:ultimate_plan) { create(:ultimate_plan) } let_it_be(:ultimate_plan) { create(:ultimate_plan) }
let_it_be(:plan_limits) { create(:plan_limits, plan: ultimate_plan) } let_it_be(:plan_limits) { create(:plan_limits, plan: ultimate_plan) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::Minutes::TrackLiveConsumptionService do RSpec.describe Ci::Minutes::TrackLiveConsumptionService, :saas do
let(:project) { create(:project, :private, shared_runners_enabled: true, namespace: namespace) } let(:project) { create(:project, :private, shared_runners_enabled: true, namespace: namespace) }
let(:namespace) { create(:namespace, shared_runners_minutes_limit: 100) } let(:namespace) { create(:namespace, shared_runners_minutes_limit: 100) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -20,8 +20,6 @@ RSpec.describe Ci::RetryBuildService do ...@@ -20,8 +20,6 @@ RSpec.describe Ci::RetryBuildService do
describe '#clone!' do describe '#clone!' do
context 'when user has ability to execute build' do context 'when user has ability to execute build' do
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
let_it_be(:ultimate_plan) { create(:ultimate_plan) }
let_it_be(:plan_limits) { create(:plan_limits, plan: ultimate_plan) }
let(:project) { create(:project, namespace: namespace, creator: user) } let(:project) { create(:project, namespace: namespace, creator: user) }
...@@ -68,10 +66,6 @@ RSpec.describe Ci::RetryBuildService do ...@@ -68,10 +66,6 @@ RSpec.describe Ci::RetryBuildService do
end end
describe 'credit card requirement' do describe 'credit card requirement' do
before do
create(:gitlab_subscription, namespace: namespace, hosted_plan: ultimate_plan)
end
shared_examples 'creates a retried build' do shared_examples 'creates a retried build' do
it 'creates a retried build' do it 'creates a retried build' do
build build
...@@ -85,10 +79,16 @@ RSpec.describe Ci::RetryBuildService do ...@@ -85,10 +79,16 @@ RSpec.describe Ci::RetryBuildService do
end end
end end
context 'when credit card is required' do context 'when credit card is required', :saas do
let_it_be(:ultimate_plan) { create(:ultimate_plan) }
let_it_be(:plan_limits) { create(:plan_limits, plan: ultimate_plan) }
before do
create(:gitlab_subscription, namespace: namespace, hosted_plan: ultimate_plan)
end
context 'when project is on free plan' do context 'when project is on free plan' do
before do before do
allow(::Gitlab).to receive(:com?).and_return(true)
namespace.gitlab_subscription.update!(hosted_plan: create(:free_plan)) namespace.gitlab_subscription.update!(hosted_plan: create(:free_plan))
user.created_at = ::Users::CreditCardValidation::RELEASE_DAY user.created_at = ::Users::CreditCardValidation::RELEASE_DAY
end end
......
...@@ -83,7 +83,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do ...@@ -83,7 +83,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do
end end
end end
it 'respects the defined payload schema' do it 'respects the defined payload schema', :saas do
expect(::Gitlab::HTTP).to receive(:post) do |_url, params| expect(::Gitlab::HTTP).to receive(:post) do |_url, params|
expect(params[:body]).to match_schema('/external_validation') expect(params[:body]).to match_schema('/external_validation')
expect(params[:timeout]).to eq(described_class::DEFAULT_VALIDATION_REQUEST_TIMEOUT) expect(params[:timeout]).to eq(described_class::DEFAULT_VALIDATION_REQUEST_TIMEOUT)
......
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