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.rb27
1 files changed, 18 insertions, 9 deletions
diff --git a/spec/helpers/whats_new_helper_spec.rb b/spec/helpers/whats_new_helper_spec.rb
index 80d4ca8ddea..1c8684de75c 100644
--- a/spec/helpers/whats_new_helper_spec.rb
+++ b/spec/helpers/whats_new_helper_spec.rb
@@ -3,21 +3,23 @@
require 'spec_helper'
RSpec.describe WhatsNewHelper 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 }
- before do
- allow(helper).to receive(:whats_new_most_recent_version).and_return(version)
- end
-
context 'when version exist' do
- let(:version) { '84.0' }
+ before do
+ allow(Dir).to receive(:glob).with(Rails.root.join('data', 'whats_new', '*.yml')).and_return(fixture_dir_glob)
+ end
- it { is_expected.to eq('display-whats-new-notification-84.0') }
+ it { is_expected.to eq('display-whats-new-notification-01.05') }
end
context 'when recent release items do NOT exist' do
- let(:version) { nil }
+ before do
+ allow(helper).to receive(:whats_new_release_items).and_return(nil)
+ end
it { is_expected.to be_nil }
end
@@ -27,8 +29,6 @@ RSpec.describe WhatsNewHelper do
subject { helper.whats_new_most_recent_release_items_count }
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)
@@ -48,4 +48,13 @@ RSpec.describe WhatsNewHelper do
end
end
end
+
+ # Testing this important private method here because the request spec required multiple confusing mocks and felt wrong and overcomplicated
+ describe '#whats_new_items_cache_key' do
+ it 'returns a key containing the most recent file name and page parameter' do
+ allow(Dir).to receive(:glob).with(Rails.root.join('data', 'whats_new', '*.yml')).and_return(fixture_dir_glob)
+
+ expect(helper.send(:whats_new_items_cache_key, 2)).to eq('whats_new:release_items:file-20201225_01_05:page-2')
+ end
+ end
end