diff options
Diffstat (limited to 'spec/helpers/whats_new_helper_spec.rb')
-rw-r--r-- | spec/helpers/whats_new_helper_spec.rb | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/spec/helpers/whats_new_helper_spec.rb b/spec/helpers/whats_new_helper_spec.rb index 017826921ff..0e4b4621560 100644 --- a/spec/helpers/whats_new_helper_spec.rb +++ b/spec/helpers/whats_new_helper_spec.rb @@ -3,25 +3,15 @@ require 'spec_helper' RSpec.describe WhatsNewHelper do - describe '#whats_new_storage_key' do - subject { helper.whats_new_storage_key } + include Devise::Test::ControllerHelpers - context 'when version exist' do - let(:release_item) { double(:item) } + describe '#whats_new_version_digest' do + let(:digest) { 'digest' } - before do - allow(ReleaseHighlight).to receive(:versions).and_return([84.0]) - end - - it { is_expected.to eq('display-whats-new-notification-84.0') } - end + it 'calls ReleaseHighlight.most_recent_version_digest' do + expect(ReleaseHighlight).to receive(:most_recent_version_digest).and_return(digest) - context 'when most recent release highlights do NOT exist' do - before do - allow(ReleaseHighlight).to receive(:versions).and_return(nil) - end - - it { is_expected.to be_nil } + expect(helper.whats_new_version_digest).to eq(digest) end end @@ -45,13 +35,29 @@ RSpec.describe WhatsNewHelper do end end - describe '#whats_new_versions' do - let(:versions) { [84.0] } + describe '#display_whats_new?' do + subject { helper.display_whats_new? } + + it 'returns true when gitlab.com' do + allow(Gitlab).to receive(:dev_env_org_or_com?).and_return(true) - it 'returns ReleaseHighlight.versions' do - expect(ReleaseHighlight).to receive(:versions).and_return(versions) + expect(subject).to be true + end + + context 'when self-managed' do + before do + allow(Gitlab).to receive(:dev_env_org_or_com?).and_return(false) + end - expect(helper.whats_new_versions).to eq(versions) + it 'returns true if user is signed in' do + sign_in(create(:user)) + + expect(subject).to be true + end + + it "returns false if user isn't signed in" do + expect(subject).to be false + end end end end |