Commit d84d4df7 authored by Doug Stull's avatar Doug Stull Committed by Ash McKenzie

Rename dev, org and com env detection helper

- before this was named so it looked like it only covered
  dev and com, but it also has org in it.
- so we'll rename it so we can add a future method that only
  checks for dev and com
parent bcc53e6b
...@@ -146,7 +146,7 @@ module EE ...@@ -146,7 +146,7 @@ module EE
end end
def should_check_namespace_plan? def should_check_namespace_plan?
check_namespace_plan? && (Rails.env.test? || ::Gitlab.dev_env_or_com?) check_namespace_plan? && (Rails.env.test? || ::Gitlab.dev_env_org_or_com?)
end end
def elasticsearch_indexing def elasticsearch_indexing
......
- return unless ::Gitlab.dev_env_or_com? - return unless ::Gitlab.dev_env_org_or_com?
- form = local_assigns.fetch(:form) - form = local_assigns.fetch(:form)
......
...@@ -9,7 +9,7 @@ describe Groups::BillingsController do ...@@ -9,7 +9,7 @@ describe Groups::BillingsController do
describe 'GET index' do describe 'GET index' do
before do before do
stub_application_setting(check_namespace_plan: true) stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:dev_env_or_com?) { true } allow(Gitlab).to receive(:dev_env_org_or_com?) { true }
end end
context 'authorized' do context 'authorized' do
...@@ -48,7 +48,7 @@ describe Groups::BillingsController do ...@@ -48,7 +48,7 @@ describe Groups::BillingsController do
end end
it 'renders 404 when it is not gitlab.com' do it 'renders 404 when it is not gitlab.com' do
allow(Gitlab).to receive(:dev_env_or_com?) { false } allow(Gitlab).to receive(:dev_env_org_or_com?) { false }
group.add_owner(user) group.add_owner(user)
sign_in(user) sign_in(user)
......
...@@ -80,11 +80,11 @@ describe ApplicationSetting do ...@@ -80,11 +80,11 @@ describe ApplicationSetting do
describe '#should_check_namespace_plan?' do describe '#should_check_namespace_plan?' do
before do before do
stub_application_setting(check_namespace_plan: check_namespace_plan_column) stub_application_setting(check_namespace_plan: check_namespace_plan_column)
allow(::Gitlab).to receive(:dev_env_or_com?) { gl_com } allow(::Gitlab).to receive(:dev_env_org_or_com?) { gl_com }
# This stub was added in order to force a fallback to Gitlab.dev_env_or_com? # This stub was added in order to force a fallback to Gitlab.dev_env_org_or_com?
# call testing. # call testing.
# Gitlab.dev_env_or_com? responds to `false` on test envs # Gitlab.dev_env_org_or_com? responds to `false` on test envs
# and we want to make sure we're still testing # and we want to make sure we're still testing
# should_check_namespace_plan? method through the test-suite (see # should_check_namespace_plan? method through the test-suite (see
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18461#note_69322821). # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18461#note_69322821).
......
...@@ -55,7 +55,7 @@ module Gitlab ...@@ -55,7 +55,7 @@ module Gitlab
SUBDOMAIN_REGEX === Gitlab.config.gitlab.url SUBDOMAIN_REGEX === Gitlab.config.gitlab.url
end end
def self.dev_env_or_com? def self.dev_env_org_or_com?
Rails.env.development? || org? || com? Rails.env.development? || org? || com?
end end
......
...@@ -98,6 +98,33 @@ describe Gitlab do ...@@ -98,6 +98,33 @@ describe Gitlab do
end end
end end
describe '.dev_env_org_or_com?' do
it 'is true when on .com' do
allow(described_class).to receive_messages(com?: true, org?: false)
expect(described_class.dev_env_org_or_com?).to eq true
end
it 'is true when org' do
allow(described_class).to receive_messages(com?: false, org?: true)
expect(described_class.dev_env_org_or_com?).to eq true
end
it 'is true when dev env' do
allow(described_class).to receive_messages(com?: false, org?: false)
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
expect(described_class.dev_env_org_or_com?).to eq true
end
it 'is false when not dev, org or com' do
allow(described_class).to receive_messages(com?: false, org?: false)
expect(described_class.dev_env_org_or_com?).to eq false
end
end
describe '.ee?' do describe '.ee?' do
before do before do
described_class.instance_variable_set(:@is_ee, nil) described_class.instance_variable_set(:@is_ee, nil)
......
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