debian-mirror-gitlab/spec/helpers/whats_new_helper_spec.rb

58 lines
1.5 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe WhatsNewHelper do
2021-01-03 14:25:43 +05:30
describe '#whats_new_storage_key' do
subject { helper.whats_new_storage_key }
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
context 'when version exist' do
2021-02-22 17:27:13 +05:30
let(:release_item) { double(:item) }
2021-01-29 00:20:46 +05:30
before do
2021-02-22 17:27:13 +05:30
allow(ReleaseHighlight).to receive(:versions).and_return([84.0])
2021-01-29 00:20:46 +05:30
end
2021-01-03 14:25:43 +05:30
2021-02-22 17:27:13 +05:30
it { is_expected.to eq('display-whats-new-notification-84.0') }
2021-01-03 14:25:43 +05:30
end
2021-02-22 17:27:13 +05:30
context 'when most recent release highlights do NOT exist' do
2021-01-29 00:20:46 +05:30
before do
2021-02-22 17:27:13 +05:30
allow(ReleaseHighlight).to receive(:versions).and_return(nil)
2021-01-29 00:20:46 +05:30
end
2021-01-03 14:25:43 +05:30
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 }
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
context 'when recent release items exist' do
it 'returns the count from the most recent file' do
2021-02-22 17:27:13 +05:30
allow(ReleaseHighlight).to receive(:most_recent_item_count).and_return(1)
2021-01-03 14:25:43 +05:30
expect(subject).to eq(1)
end
2020-11-24 15:15:51 +05:30
end
2021-01-03 14:25:43 +05:30
context 'when recent release items do NOT exist' do
2021-02-22 17:27:13 +05:30
it 'returns nil' do
allow(ReleaseHighlight).to receive(:most_recent_item_count).and_return(nil)
2021-01-03 14:25:43 +05:30
expect(subject).to be_nil
end
2020-11-24 15:15:51 +05:30
end
end
2021-01-29 00:20:46 +05:30
2021-02-22 17:27:13 +05:30
describe '#whats_new_versions' do
let(:versions) { [84.0] }
it 'returns ReleaseHighlight.versions' do
expect(ReleaseHighlight).to receive(:versions).and_return(versions)
2021-01-29 00:20:46 +05:30
2021-02-22 17:27:13 +05:30
expect(helper.whats_new_versions).to eq(versions)
2021-01-29 00:20:46 +05:30
end
end
2020-11-24 15:15:51 +05:30
end