2020-08-26 06:10:34 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe WhatsNewHelper do
|
2020-09-28 18:09:40 +00:00
|
|
|
describe '#whats_new_storage_key' do
|
|
|
|
subject { helper.whats_new_storage_key }
|
|
|
|
|
2020-10-14 18:08:47 +00:00
|
|
|
context 'when version exist' do
|
2020-11-24 18:09:14 +00:00
|
|
|
let(:release_item) { double(:item) }
|
|
|
|
|
2020-11-02 09:08:35 +00:00
|
|
|
before do
|
2020-11-24 18:09:14 +00:00
|
|
|
allow(ReleaseHighlight).to receive(:most_recent_version).and_return(84.0)
|
2020-11-02 09:08:35 +00:00
|
|
|
end
|
2020-09-28 18:09:40 +00:00
|
|
|
|
2020-11-24 18:09:14 +00:00
|
|
|
it { is_expected.to eq('display-whats-new-notification-84.0') }
|
2020-09-28 18:09:40 +00:00
|
|
|
end
|
|
|
|
|
2020-11-24 18:09:14 +00:00
|
|
|
context 'when most recent release highlights do NOT exist' do
|
2020-11-02 09:08:35 +00:00
|
|
|
before do
|
2020-11-24 18:09:14 +00:00
|
|
|
allow(ReleaseHighlight).to receive(:most_recent_version).and_return(nil)
|
2020-11-02 09:08:35 +00:00
|
|
|
end
|
2020-09-28 18:09:40 +00:00
|
|
|
|
|
|
|
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 }
|
|
|
|
|
|
|
|
context 'when recent release items exist' do
|
2020-10-14 18:08:47 +00:00
|
|
|
it 'returns the count from the most recent file' do
|
2020-11-24 18:09:14 +00:00
|
|
|
allow(ReleaseHighlight).to receive(:most_recent_item_count).and_return(1)
|
2020-09-28 18:09:40 +00:00
|
|
|
|
2020-10-14 18:08:47 +00:00
|
|
|
expect(subject).to eq(1)
|
|
|
|
end
|
2020-09-28 18:09:40 +00:00
|
|
|
end
|
2020-08-26 06:10:34 +00:00
|
|
|
|
2020-10-14 18:08:47 +00:00
|
|
|
context 'when recent release items do NOT exist' do
|
2020-11-24 18:09:14 +00:00
|
|
|
it 'returns nil' do
|
|
|
|
allow(ReleaseHighlight).to receive(:most_recent_item_count).and_return(nil)
|
2020-08-26 06:10:34 +00:00
|
|
|
|
2020-10-14 18:08:47 +00:00
|
|
|
expect(subject).to be_nil
|
|
|
|
end
|
2020-08-26 06:10:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|