Commit 4d433c20 authored by Michael Kozono's avatar Michael Kozono

Move cheap calls first

parent 0275c26e
...@@ -42,14 +42,14 @@ module EE ...@@ -42,14 +42,14 @@ module EE
end end
def show_enable_hashed_storage_warning? def show_enable_hashed_storage_warning?
return if user_dismissed?(GEO_ENABLE_HASHED_STORAGE) return if hashed_storage_enabled?
!hashed_storage_enabled? !user_dismissed?(GEO_ENABLE_HASHED_STORAGE)
end end
def show_migrate_hashed_storage_warning? def show_migrate_hashed_storage_warning?
return if user_dismissed?(GEO_MIGRATE_HASHED_STORAGE)
return unless hashed_storage_enabled? return unless hashed_storage_enabled?
return if user_dismissed?(GEO_MIGRATE_HASHED_STORAGE)
any_project_not_in_hashed_storage? any_project_not_in_hashed_storage?
end end
......
...@@ -79,36 +79,31 @@ describe EE::UserCalloutsHelper do ...@@ -79,36 +79,31 @@ describe EE::UserCalloutsHelper do
subject { helper.show_enable_hashed_storage_warning? } subject { helper.show_enable_hashed_storage_warning? }
let(:user) { create(:user) } let(:user) { create(:user) }
before do context 'when hashed storage is disabled' do
expect(helper).to receive(:current_user).and_return(user) before do
end stub_application_setting(hashed_storage_enabled: false)
expect(helper).to receive(:current_user).and_return(user)
context 'when the enable warning has not been dismissed' do end
context 'when hashed storage is disabled' do
before do
stub_application_setting(hashed_storage_enabled: false)
end
context 'when the enable warning has not been dismissed' do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
context 'when hashed storage is enabled' do context 'when the enable warning was dismissed' do
before do before do
stub_application_setting(hashed_storage_enabled: true) create(:user_callout, user: user, feature_name: described_class::GEO_ENABLE_HASHED_STORAGE)
end end
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
end end
end end
context 'when the enable warning was dismissed' do context 'when hashed storage is enabled' do
it 'does not render the enable warning' do before do
create(:user_callout, user: user, feature_name: described_class::GEO_ENABLE_HASHED_STORAGE) stub_application_setting(hashed_storage_enabled: true)
expect(helper).not_to receive(:render_flash_user_callout)
helper.render_enable_hashed_storage_warning
end end
it { is_expected.to be_falsy }
end end
end end
...@@ -116,24 +111,21 @@ describe EE::UserCalloutsHelper do ...@@ -116,24 +111,21 @@ describe EE::UserCalloutsHelper do
subject { helper.show_migrate_hashed_storage_warning? } subject { helper.show_migrate_hashed_storage_warning? }
let(:user) { create(:user) } let(:user) { create(:user) }
before do context 'when hashed storage is disabled' do
expect(helper).to receive(:current_user).and_return(user) before do
end stub_application_setting(hashed_storage_enabled: false)
end
context 'when the migrate warning has not been dismissed' do it { is_expected.to be_falsy }
context 'when hashed storage is disabled' do end
before do
expect(helper).to receive(:hashed_storage_enabled?).and_return(false)
end
it { is_expected.to be_falsy } context 'when hashed storage is enabled' do
before do
stub_application_setting(hashed_storage_enabled: true)
expect(helper).to receive(:current_user).and_return(user)
end end
context 'when hashed storage is enabled' do context 'when the enable warning has not been dismissed' do
before do
expect(helper).to receive(:hashed_storage_enabled?).and_return(true)
end
context 'when there is a project in non-hashed-storage' do context 'when there is a project in non-hashed-storage' do
before do before do
create(:project, :legacy_storage) create(:project, :legacy_storage)
...@@ -146,14 +138,13 @@ describe EE::UserCalloutsHelper do ...@@ -146,14 +138,13 @@ describe EE::UserCalloutsHelper do
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
end end
end end
end
context 'when the migrate warning was dismissed' do context 'when the enable warning was dismissed' do
it 'does not render the migrate warning' do before do
create(:user_callout, user: user, feature_name: described_class::GEO_ENABLE_HASHED_STORAGE) create(:user_callout, user: user, feature_name: described_class::GEO_MIGRATE_HASHED_STORAGE)
expect(helper).not_to receive(:render_flash_user_callout) end
helper.render_migrate_hashed_storage_warning it { is_expected.to be_falsy }
end 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