Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/feature_management.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
class FeatureManagement
ENVS_WHERE_PREFILLING_GPO_CODE_ALLOWED = %w[
idp.dev.login.gov idp.int.login.gov idp.qa.login.gov idp.pt.login.gov
idp.dev.identitysandbox.gov idp.qa.identitysandbox.gov idp.int.identitysandbox.gov
idp.pt.identitysandbox.gov
].freeze

def self.telephony_test_adapter?
IdentityConfig.store.telephony_adapter == 'test'
end
Expand Down Expand Up @@ -63,7 +57,7 @@ def self.reveal_gpo_code?
end

def self.current_env_allowed_to_see_gpo_code?
ENVS_WHERE_PREFILLING_GPO_CODE_ALLOWED.include?(IdentityConfig.store.domain_name)
Identity::Hostdata.domain == 'identitysandbox.gov'
end

def self.show_demo_banner?
Expand Down
43 changes: 27 additions & 16 deletions spec/lib/feature_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,41 @@
end

describe '#reveal_gpo_code?' do
context 'server domain name is dev, qa, or int' do
it 'returns true' do
%w[idp.dev.login.gov idp.int.login.gov idp.qa.login.gov].each do |domain|
allow(IdentityConfig.store).to receive(:domain_name).and_return(domain)
context 'domain is set to identitysandbox.gov' do
before do
allow(Identity::Hostdata).to receive(:domain).and_return('identitysandbox.gov')
end

context 'Rails env is development' do
before do
allow(Rails.env).to receive(:development?).and_return(true)
allow(Rails.env).to receive(:production?).and_return(false)
end
it 'returns true' do
expect(FeatureManagement.reveal_gpo_code?).to eq(true)
end
end
end

context 'Rails env is development' do
it 'returns true' do
allow(Rails.env).to receive(:development?).and_return(true)

expect(FeatureManagement.reveal_gpo_code?).to eq(true)
context 'Rails env is production' do
before do
allow(Rails.env).to receive(:development?).and_return(false)
allow(Rails.env).to receive(:production?).and_return(true)
end
it 'returns true' do
expect(FeatureManagement.reveal_gpo_code?).to eq(true)
end
end
end

context 'Rails env is not development and server is not dev, qa, or int' do
it 'returns false' do
allow(Rails.env).to receive(:development?).and_return(false)
allow(IdentityConfig.store).to receive(:domain_name).and_return('foo.login.gov')

expect(FeatureManagement.reveal_gpo_code?).to eq(false)
context 'domain is set to login.gov' do
context 'Rails env is production' do
before do
allow(Rails.env).to receive(:development?).and_return(false)
allow(Rails.env).to receive(:production?).and_return(true)
end
it 'returns false' do
expect(FeatureManagement.reveal_gpo_code?).to eq(false)
end
end
end
end
Expand Down