Commit fb3e0c9c authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Ignore namespaces.plan_id because it's unused

We already removed all the code that was using this column so we
ignore this column in preparation for removal
parent fa89dc28
......@@ -11,6 +11,9 @@ class Namespace < ApplicationRecord
include FeatureGate
include FromUnion
include Gitlab::Utils::StrongMemoize
include IgnorableColumns
ignore_column :plan_id, remove_with: '13.1', remove_after: '2020-06-22'
# Prevent users from creating unreasonably deep level of nesting.
# The number 20 was taken based on maximum nesting level of
......
......@@ -239,7 +239,6 @@ tables:
- repository_size_limit
- require_two_factor_authentication
- two_factor_grace_period
- plan_id
- project_creation_level
members:
whitelist:
......
......@@ -27,8 +27,6 @@ module EE
attr_writer :root_ancestor
belongs_to :plan
has_one :namespace_statistics
has_one :gitlab_subscription, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
......@@ -62,7 +60,6 @@ module EE
# Opportunistically clear the +file_template_project_id+ if invalid
before_validation :clear_file_template_project_id
validate :validate_plan_name
validate :validate_shared_runner_minutes_support
validates :max_pages_size,
......@@ -294,16 +291,6 @@ module EE
end
# These helper methods are required to not break the Namespace API.
def plan=(plan_name)
if plan_name.is_a?(String)
@plan_name = plan_name # rubocop:disable Gitlab/ModuleWithInstanceVariables
super(Plan.find_by(name: @plan_name)) # rubocop:disable Gitlab/ModuleWithInstanceVariables
else
super
end
end
def memoized_plans=(plans)
@plans = plans # rubocop: disable Gitlab/ModuleWithInstanceVariables
end
......@@ -396,12 +383,6 @@ module EE
private
def validate_plan_name
if defined?(@plan_name) && @plan_name.present? && PLANS.exclude?(@plan_name) # rubocop:disable Gitlab/ModuleWithInstanceVariables
errors.add(:plan, 'is not included in the list')
end
end
def validate_shared_runner_minutes_support
return if shared_runner_minutes_supported?
......
......@@ -5,7 +5,7 @@ module EE
extend ActiveSupport::Concern
prepended do
scope :with_logging_info, -> { includes(project: [:route, { namespace: [:plan, :gitlab_subscription] }]) }
scope :with_logging_info, -> { includes(project: [:route, { namespace: :gitlab_subscription }]) }
end
end
end
......@@ -13,7 +13,6 @@ class Plan < ApplicationRecord
DEFAULT_PLANS = [DEFAULT, FREE].freeze
ALL_HOSTED_PLANS = (PAID_HOSTED_PLANS + [EARLY_ADOPTER]).freeze
has_many :namespaces
has_many :hosted_subscriptions, class_name: 'GitlabSubscription', foreign_key: 'hosted_plan_id'
has_one :limits, class_name: 'PlanLimits'
......
......@@ -14,7 +14,6 @@ describe Namespace do
it { is_expected.to have_one(:namespace_statistics) }
it { is_expected.to have_one(:gitlab_subscription).dependent(:destroy) }
it { is_expected.to belong_to(:plan) }
it { is_expected.to delegate_method(:extra_shared_runners_minutes).to(:namespace_statistics) }
it { is_expected.to delegate_method(:shared_runners_minutes).to(:namespace_statistics) }
......@@ -262,33 +261,6 @@ describe Namespace do
end
describe 'custom validations' do
describe '#validate_plan_name' do
let(:group) { build(:group) }
context 'with a valid plan name' do
it 'is valid' do
group.plan = create(:bronze_plan)
expect(group).to be_valid
end
end
context 'with an invalid plan name' do
it 'is invalid when `unknown`' do
group.plan = 'unknown'
expect(group).not_to be_valid
expect(group.errors[:plan]).to include('is not included in the list')
end
it 'is valid for blank strings' do
group.plan = ' '
expect(group).to be_valid
end
end
end
describe '#validate_shared_runner_minutes_support' do
context 'when changing :shared_runners_minutes_limit' do
before do
......
......@@ -3,10 +3,6 @@
require 'spec_helper'
describe Plan do
describe 'associations' do
it { is_expected.to have_many(:namespaces) }
end
describe '#default?' do
subject { plan.default? }
......
......@@ -49,7 +49,6 @@ RSpec.shared_examples 'dashboard gold trial callout' do
it 'hides promotion callout if a gold plan is active', :js do
group = create(:group_with_plan, name: 'gold group', plan: :gold_plan)
group.update(plan: group.gitlab_subscription.hosted_plan)
group.add_owner(user)
visit page_path
......
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