diff options
Diffstat (limited to 'spec/helpers/whats_new_helper_spec.rb')
-rw-r--r-- | spec/helpers/whats_new_helper_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/helpers/whats_new_helper_spec.rb b/spec/helpers/whats_new_helper_spec.rb index db880163454..7d8fb236b1e 100644 --- a/spec/helpers/whats_new_helper_spec.rb +++ b/spec/helpers/whats_new_helper_spec.rb @@ -3,6 +3,52 @@ require 'spec_helper' RSpec.describe WhatsNewHelper do + describe '#whats_new_storage_key' do + subject { helper.whats_new_storage_key } + + before do + allow(helper).to receive(:whats_new_most_recent_release_items).and_return(json) + end + + context 'when recent release items exist' do + let(:json) { [{ release: 84.0 }].to_json } + + it { is_expected.to eq('display-whats-new-notification-84.0') } + + context 'when the release items are missing the release key' do + let(:json) { [{ title: 'bells!' }].to_json } + + it { is_expected.to eq('display-whats-new-notification') } + end + end + + context 'when recent release items do NOT exist' do + let(:json) { WhatsNewHelper::EMPTY_JSON } + + it { is_expected.to be_nil } + end + end + + describe '#whats_new_most_recent_release_items_count' do + subject { helper.whats_new_most_recent_release_items_count } + + before do + allow(helper).to receive(:whats_new_most_recent_release_items).and_return(json) + end + + context 'when recent release items exist' do + let(:json) { [:bells, :and, :whistles].to_json } + + it { is_expected.to eq(3) } + end + + context 'when recent release items do NOT exist' do + let(:json) { WhatsNewHelper::EMPTY_JSON } + + it { is_expected.to be_nil } + end + end + describe '#whats_new_most_recent_release_items' do let(:fixture_dir_glob) { Dir.glob(File.join('spec', 'fixtures', 'whats_new', '*.yml')) } |