Commit d20cb5a7 authored by Robert Speicher's avatar Robert Speicher

Update specs to create Plans on-demand

parent 9c177d23
......@@ -77,7 +77,7 @@ describe Projects::Settings::IntegrationsController do
end
context 'and namespace has a plan' do
let(:namespace) { create(:group, :private, plan: Namespace::BRONZE_PLAN) }
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it_behaves_like 'endpoint without disabled services'
end
......
......@@ -60,7 +60,7 @@ describe Projects::IssuesController do
context 'licensed by namespace' do
let(:globally_licensed) { true }
let(:namespace) { create(:group, :private, plan: Namespace::BRONZE_PLAN) }
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
let(:project) { create(:project, namespace: namespace) }
before do
......
require 'spec_helper'
describe EE::Gitlab::Ci::Pipeline::Quota::Activity do
set(:namespace) { create(:namespace, plan: EE::Namespace::GOLD_PLAN) }
set(:namespace) { create(:namespace, plan: :gold_plan) }
set(:project) { create(:project, namespace: namespace) }
let(:limit) { described_class.new(namespace, project) }
......
......@@ -15,7 +15,7 @@ describe Namespace do
let!(:namespace) { create :namespace, plan: namespace_plan }
context 'plan is set' do
let(:namespace_plan) { EE::Namespace::BRONZE_PLAN }
let(:namespace_plan) { :bronze_plan }
it 'returns namespaces with plan' do
expect(described_class.with_plan).to eq([namespace])
......@@ -48,7 +48,7 @@ describe Namespace do
context 'with a valid plan name' do
it 'is valid' do
group.plan = Namespace::BRONZE_PLAN
group.plan = create(:bronze_plan)
expect(group).to be_valid
end
......@@ -123,7 +123,7 @@ describe Namespace do
end
describe '#feature_available?' do
let(:plan_license) { Namespace::BRONZE_PLAN }
let(:plan_license) { :bronze_plan }
let(:group) { create(:group, plan: plan_license) }
let(:feature) { :service_desk }
......@@ -155,7 +155,7 @@ describe Namespace do
end
context 'when feature available on the plan' do
let(:plan_license) { Namespace::GOLD_PLAN }
let(:plan_license) { :gold_plan }
context 'when feature available for current group' do
it 'returns true' do
......@@ -176,7 +176,7 @@ describe Namespace do
context 'when feature not available in the plan' do
let(:feature) { :deploy_board }
let(:plan_license) { Namespace::BRONZE_PLAN }
let(:plan_license) { :bronze_plan }
it 'returns false' do
is_expected.to be_falsy
......@@ -194,8 +194,7 @@ describe Namespace do
context 'when free plan has limit defined' do
before do
Plan.find_by(name: Namespace::FREE_PLAN)
.update_column(:active_pipelines_limit, 40)
create(:free_plan, active_pipelines_limit: 40)
end
it 'returns a free plan limits' do
......@@ -205,7 +204,7 @@ describe Namespace do
context 'when associated plan has no limit defined' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
end
it 'returns zero' do
......@@ -215,7 +214,7 @@ describe Namespace do
context 'when limit is defined' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
namespace.plan.update_column(:active_pipelines_limit, 10)
end
......@@ -234,8 +233,7 @@ describe Namespace do
context 'when free plan has limit defined' do
before do
Plan.find_by(name: Namespace::FREE_PLAN)
.update_column(:pipeline_size_limit, 40)
create(:free_plan, pipeline_size_limit: 40)
end
it 'returns a free plan limits' do
......@@ -245,7 +243,7 @@ describe Namespace do
context 'when associated plan has no limits defined' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
end
it 'returns zero' do
......@@ -255,7 +253,7 @@ describe Namespace do
context 'when limit is defined' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
namespace.plan.update_column(:pipeline_size_limit, 15)
end
......@@ -482,7 +480,7 @@ describe Namespace do
describe '#actual_plan' do
context 'when namespace has a plan associated' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
end
it 'returns an associated plan' do
......@@ -492,6 +490,10 @@ describe Namespace do
end
context 'when namespace does not have plan associated' do
before do
create(:free_plan)
end
it 'returns a free plan object' do
expect(namespace.plan).to be_nil
expect(namespace.actual_plan.name).to eq 'free'
......@@ -502,7 +504,7 @@ describe Namespace do
describe '#actual_plan_name' do
context 'when namespace has a plan associated' do
before do
namespace.plan = Namespace::GOLD_PLAN
namespace.plan = create(:gold_plan)
end
it 'returns an associated plan name' do
......
......@@ -174,7 +174,7 @@ describe Project do
context 'allowed by Plan License AND Global License' do
let(:allowed_on_global_license) { true }
let(:plan_license) { Plan.find_by(name: 'gold') }
let(:plan_license) { create(:gold_plan) }
it 'returns true' do
is_expected.to eq(true)
......@@ -183,7 +183,7 @@ describe Project do
context 'not allowed by Plan License but project and namespace are public' do
let(:allowed_on_global_license) { true }
let(:plan_license) { Plan.find_by(name: 'bronze') }
let(:plan_license) { create(:bronze_plan) }
it 'returns true' do
allow(namespace).to receive(:public?) { true }
......@@ -196,7 +196,7 @@ describe Project do
unless License.plan_includes_feature?(License::STARTER_PLAN, feature_sym)
context 'not allowed by Plan License' do
let(:allowed_on_global_license) { true }
let(:plan_license) { Plan.find_by(name: 'bronze') }
let(:plan_license) { create(:bronze_plan) }
it 'returns false' do
is_expected.to eq(false)
......@@ -206,7 +206,7 @@ describe Project do
context 'not allowed by Global License' do
let(:allowed_on_global_license) { false }
let(:plan_license) { Plan.find_by(name: 'gold') }
let(:plan_license) { create(:gold_plan) }
it 'returns false' do
is_expected.to eq(false)
......@@ -679,7 +679,7 @@ describe Project do
end
context 'Service Desk available in namespace plan' do
let(:namespace) { create(:namespace, plan: Namespace::SILVER_PLAN) }
let(:namespace) { create(:namespace, plan: :silver_plan) }
it 'is enabled' do
expect(project.service_desk_enabled?).to be_truthy
......@@ -1163,7 +1163,7 @@ describe Project do
end
context 'and namespace has a plan' do
let(:namespace) { create(:group, :private, plan: Namespace::BRONZE_PLAN) }
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it_behaves_like 'project without disabled services'
end
......
......@@ -96,7 +96,8 @@ describe Projects::CreateService, '#execute' do
context 'when licensed on a namespace' do
it 'allows enabling mirrors' do
user.namespace.update!(plan: Plan.find_by(name: 'gold'))
plan = create(:gold_plan)
user.namespace.update!(plan: plan)
project = create_project(user, opts)
......
......@@ -28,7 +28,7 @@ FactoryGirl.define do
end
before :create do |namespace, evaluator|
if evaluator.plan
if evaluator.plan.present?
namespace.plan = create(evaluator.plan)
end
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Billing plan pages', :feature do
let(:user) { create(:user) }
let(:bronze_plan) { Plan.find_by(name: 'bronze') }
let(:bronze_plan) { create(:bronze_plan) }
let(:plans_data) do
[
{
......@@ -141,9 +141,9 @@ describe 'Billing plan pages', :feature do
end
context 'on sub-group', :nested_groups do
let(:group) { create(:group, plan: Namespace::BRONZE_PLAN) }
let(:group) { create(:group, plan: :bronze_plan) }
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
let(:subgroup1) { create(:group, parent: group, plan: Namespace::SILVER_PLAN) }
let(:subgroup1) { create(:group, parent: group, plan: :silver_plan) }
let!(:subgroup1_member) { create(:group_member, :owner, group: subgroup1, user: user) }
let(:subgroup2) { create(:group, parent: subgroup1) }
let!(:subgroup2_member) { create(:group_member, :owner, group: subgroup2, user: user) }
......
......@@ -30,8 +30,8 @@ feature 'Projects > Push Rules', :js do
end
context 'licensed' do
let(:bronze_plan) { Plan.find_by!(name: 'bronze') }
let(:gold_plan) { Plan.find_by!(name: 'gold') }
let(:bronze_plan) { create(:bronze_plan) }
let(:gold_plan) { create(:gold_plan) }
before do
stub_licensed_features(rule_attr => true)
......
......@@ -165,7 +165,7 @@ eos
end
context 'when namespace has a plan' do
let(:namespace) { create(:group, :private, plan: Namespace::BRONZE_PLAN) }
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it_behaves_like 'an enabled jenkins deprecated service'
end
......
......@@ -192,7 +192,7 @@ describe JenkinsService do
end
context 'when namespace has a plan' do
let(:namespace) { create(:group, :private, plan: Namespace::BRONZE_PLAN) }
let(:namespace) { create(:group, :private, plan: :bronze_plan) }
it 'adds default web hook headers to the request' do
jenkins_service.execute(push_sample_data)
......
......@@ -169,7 +169,7 @@ describe PushRule do
end
context 'with GL.com plans' do
let(:group) { create(:group, plan: Plan.find_by!(name: gl_plan)) }
let(:group) { create(:group, plan: plan) }
let(:project) { create(:project, namespace: group) }
let(:push_rule) { create(:push_rule, project: project) }
......@@ -179,19 +179,19 @@ describe PushRule do
end
context 'with a Bronze plan' do
let(:gl_plan) { ::EE::Namespace::BRONZE_PLAN }
let(:plan) { :bronze_plan }
it_behaves_like 'an unavailable push_rule'
end
context 'with a Silver plan' do
let(:gl_plan) { ::EE::Namespace::SILVER_PLAN }
let(:plan) { :silver_plan }
it_behaves_like 'an available push_rule'
end
context 'with a Gold plan' do
let(:gl_plan) { ::EE::Namespace::GOLD_PLAN }
let(:plan) { :gold_plan }
it_behaves_like 'an available push_rule'
end
......
......@@ -95,6 +95,10 @@ describe API::Namespaces do
end
describe 'PUT /namespaces/:id' do
before do
create(:silver_plan)
end
context 'when authenticated as admin' do
it 'updates namespace using full_path' do
put api("/namespaces/#{group1.full_path}", admin), plan: 'silver', shared_runners_minutes_limit: 9001
......
......@@ -75,7 +75,7 @@ describe API::V3::Github do
end
it 'filters unlicensed namespace projects' do
silver_plan = Plan.find_by!(name: 'silver')
silver_plan = create(:silver_plan)
licensed_project = create(:project, :empty_repo)
licensed_project.add_reporter(user)
licensed_project.namespace.update!(plan_id: silver_plan.id)
......
......@@ -60,7 +60,7 @@ describe UpdateAllMirrorsWorker do
context 'licensed' do
def scheduled_mirror(at:, licensed:)
namespace = create(:group, :public, plan: (Namespace::BRONZE_PLAN if licensed))
namespace = create(:group, :public, plan: (:bronze_plan if licensed))
project = create(:project, :public, :mirror, namespace: namespace)
project.mirror_data.update!(next_execution_timestamp: at)
......
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