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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-31 18:07:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-31 18:07:20 +0300
commitfab00cd7efb84b369dfb45cabb797f7feace4b66 (patch)
treefd3eb7509bf3947ddd818214350a06d16822c78a /spec/models/release_highlight_spec.rb
parent07f6ded1cb698550284e5f348de8f1b884e715ae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/release_highlight_spec.rb')
-rw-r--r--spec/models/release_highlight_spec.rb42
1 files changed, 26 insertions, 16 deletions
diff --git a/spec/models/release_highlight_spec.rb b/spec/models/release_highlight_spec.rb
index 0391acc3781..d51998cc556 100644
--- a/spec/models/release_highlight_spec.rb
+++ b/spec/models/release_highlight_spec.rb
@@ -15,20 +15,14 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
ReleaseHighlight.instance_variable_set(:@file_paths, nil)
end
- describe '.paginated' do
- let(:dot_com) { false }
-
- before do
- allow(Gitlab).to receive(:com?).and_return(dot_com)
- end
-
+ describe '.paginated_query' do
context 'with page param' do
- subject { ReleaseHighlight.paginated(page: page) }
+ subject { ReleaseHighlight.paginated_query(page: page) }
context 'when there is another page of results' do
let(:page) { 3 }
- it 'responds with paginated results' do
+ it 'responds with paginated query results' do
expect(subject[:items].first['name']).to eq('bright')
expect(subject[:next_page]).to eq(4)
end
@@ -37,7 +31,7 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
context 'when there is NOT another page of results' do
let(:page) { 4 }
- it 'responds with paginated results and no next_page' do
+ it 'responds with paginated query results and no next_page' do
expect(subject[:items].first['name']).to eq("It's gonna be a bright")
expect(subject[:next_page]).to eq(nil)
end
@@ -51,7 +45,9 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
end
end
end
+ end
+ describe '.paginated' do
context 'with no page param' do
subject { ReleaseHighlight.paginated }
@@ -73,15 +69,15 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
end
it 'logs an error if theres an error parsing markdown for an item, and skips it' do
+ whats_new_items_count = 6
+
allow(Banzai).to receive(:render).and_raise
- expect(Gitlab::ErrorTracking).to receive(:track_exception)
+ expect(Gitlab::ErrorTracking).to receive(:track_exception).exactly(whats_new_items_count).times
expect(subject[:items]).to be_empty
end
- context 'when Gitlab.com' do
- let(:dot_com) { true }
-
+ context 'when Gitlab.com', :saas do
it 'responds with a different set of data' do
expect(subject[:items].count).to eq(1)
expect(subject[:items].first['name']).to eq("I think I can make it now the pain is gone")
@@ -90,10 +86,12 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
context 'YAML parsing throws an exception' do
it 'fails gracefully and logs an error' do
+ whats_new_files_count = 4
+
allow(YAML).to receive(:safe_load).and_raise(Psych::Exception)
- expect(Gitlab::ErrorTracking).to receive(:track_exception)
- expect(subject).to be_nil
+ expect(Gitlab::ErrorTracking).to receive(:track_exception).exactly(whats_new_files_count).times
+ expect(subject[:items]).to be_empty
end
end
end
@@ -175,6 +173,18 @@ RSpec.describe ReleaseHighlight, :clean_gitlab_redis_cache, feature_category: :r
expect(items.first['name']).to eq("View epics on a board")
end
end
+
+ context 'YAML parsing throws an exception' do
+ it 'fails gracefully and logs an error' do
+ allow(YAML).to receive(:safe_load).and_raise(Psych::Exception)
+
+ expect(Gitlab::ErrorTracking).to receive(:track_exception)
+
+ items = described_class.load_items(page: 2)
+
+ expect(items).to be_empty
+ end
+ end
end
describe 'QueryResult' do