Commit 8be435b0 authored by Ash McKenzie's avatar Ash McKenzie

Don't show gold trial callout for readonly DB's

parent e2eb1d8e
......@@ -12,7 +12,8 @@ module EE
end
def show_gold_trial_suitable_env?
::Gitlab.com? || Rails.env.development?
(::Gitlab.com? || Rails.env.development?) &&
!::Gitlab::Database.read_only?
end
def users_namespaces_clean?(user)
......
......@@ -64,32 +64,59 @@ describe EE::UserCalloutsHelper do
before do
allow(Gitlab).to receive(:com?).and_return(gitlab_com)
allow(Rails.env).to receive(:development?).and_return(rails_dev_env)
allow(Gitlab::Database).to receive(:read_only?).and_return(db_read_only)
end
context "when we're neither GitLab.com or a Rails development env" do
let(:gitlab_com) { false }
let(:rails_dev_env) { false }
context 'with a writable DB' do
let(:db_read_only) { false }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_falsey
context "when we're neither GitLab.com or a Rails development env" do
let(:gitlab_com) { false }
let(:rails_dev_env) { false }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_falsey
end
end
end
context "when we're GitLab.com" do
let(:gitlab_com) { true }
let(:rails_dev_env) { false }
context "when we're GitLab.com" do
let(:gitlab_com) { true }
let(:rails_dev_env) { false }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_truthy
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_truthy
end
end
context "when we're a Rails development env" do
let(:gitlab_com) { false }
let(:rails_dev_env) { true }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_truthy
end
end
end
context "when we're a Rails development env" do
let(:gitlab_com) { false }
let(:rails_dev_env) { true }
context 'with a readonly DB' do
let(:db_read_only) { true }
context "when we're GitLab.com" do
let(:gitlab_com) { true }
let(:rails_dev_env) { false }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_truthy
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_falsey
end
end
context "when we're a Rails development env" do
let(:gitlab_com) { false }
let(:rails_dev_env) { true }
it 'returns true' do
expect(helper.show_gold_trial_suitable_env?).to be_falsey
end
end
end
end
......
......@@ -53,5 +53,11 @@ shared_examples 'gold trial callout' do
expect(page).not_to have_selector '.promotion-callout'
end
it 'hides promotion callout if database is in a readonly state' do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(page).not_to have_selector '.promotion-callout'
end
end
end
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