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