Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/whats_new_helper_spec.rb')
-rw-r--r--spec/helpers/whats_new_helper_spec.rb47
1 files changed, 38 insertions, 9 deletions
diff --git a/spec/helpers/whats_new_helper_spec.rb b/spec/helpers/whats_new_helper_spec.rb
index db880163454..80d4ca8ddea 100644
--- a/spec/helpers/whats_new_helper_spec.rb
+++ b/spec/helpers/whats_new_helper_spec.rb
@@ -3,20 +3,49 @@
require 'spec_helper'
RSpec.describe WhatsNewHelper do
- describe '#whats_new_most_recent_release_items' do
- let(:fixture_dir_glob) { Dir.glob(File.join('spec', 'fixtures', 'whats_new', '*.yml')) }
+ describe '#whats_new_storage_key' do
+ subject { helper.whats_new_storage_key }
- it 'returns json from the most recent file' do
- allow(Dir).to receive(:glob).with(Rails.root.join('data', 'whats_new', '*.yml')).and_return(fixture_dir_glob)
+ before do
+ allow(helper).to receive(:whats_new_most_recent_version).and_return(version)
+ end
+
+ context 'when version exist' do
+ let(:version) { '84.0' }
+
+ it { is_expected.to eq('display-whats-new-notification-84.0') }
+ end
+
+ context 'when recent release items do NOT exist' do
+ let(:version) { nil }
+
+ 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 }
- expect(helper.whats_new_most_recent_release_items).to include({ title: "bright and sunshinin' day" }.to_json)
+ context 'when recent release items exist' do
+ let(:fixture_dir_glob) { Dir.glob(File.join('spec', 'fixtures', 'whats_new', '*.yml')) }
+
+ it 'returns the count from the most recent file' do
+ expect(Dir).to receive(:glob).with(Rails.root.join('data', 'whats_new', '*.yml')).and_return(fixture_dir_glob)
+
+ expect(subject).to eq(1)
+ end
end
- it 'fails gracefully and logs an error' do
- allow(YAML).to receive(:load_file).and_raise
+ context 'when recent release items do NOT exist' do
+ before do
+ allow(YAML).to receive(:safe_load).and_raise
+
+ expect(Gitlab::ErrorTracking).to receive(:track_exception)
+ end
- expect(Gitlab::ErrorTracking).to receive(:track_exception)
- expect(helper.whats_new_most_recent_release_items).to eq(''.to_json)
+ it 'fails gracefully and logs an error' do
+ expect(subject).to be_nil
+ end
end
end
end