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

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSarah German <sgerman@gitlab.com>2023-10-16 23:57:21 +0300
committerAsh McKenzie <amckenzie@gitlab.com>2023-10-16 23:57:21 +0300
commitf3942a4736d0d0fad57059b51e0b9496fa071264 (patch)
treefe372e74f04ee88fcbd9f598368f360c5a408012 /spec
parent53516f4934c2cde34d95603810ac4779bef94ef3 (diff)
Load deprecation release dates from the www-gitlab-com project
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/helpers/generic_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/helpers/generic_spec.rb b/spec/lib/helpers/generic_spec.rb
index f8b4436a..a96f05d4 100644
--- a/spec/lib/helpers/generic_spec.rb
+++ b/spec/lib/helpers/generic_spec.rb
@@ -228,4 +228,35 @@ RSpec.describe Nanoc::Helpers::Generic do
end
end
end
+
+ describe '#get_release_dates' do
+ subject { mock_class.get_release_dates }
+
+ valid_yaml_content = "- version: '18.0'\n date: '2025-05-15'"
+ invalid_yaml_content = "version: '18.0'date: 2025-05-15'"
+
+ it 'returns a JSON array when the YAML is valid' do
+ allow(Net::HTTP).to receive(:get_response).and_return(Net::HTTPSuccess.new('1.1', '200', 'OK'))
+ allow_any_instance_of(Net::HTTPSuccess).to receive(:body).and_return(valid_yaml_content)
+ expect(subject).to be_a(String)
+ end
+
+ it 'returns an empty JSON array when the YAML is invalid' do
+ allow(Net::HTTP).to receive(:get_response).and_return(Net::HTTPSuccess.new('1.1', '200', 'OK'))
+ allow_any_instance_of(Net::HTTPSuccess).to receive(:body).and_return(invalid_yaml_content)
+ allow(mock_class).to receive(:warn).with('Error getting release dates - (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1')
+ expect(subject).to eq("[]")
+ end
+
+ it 'returns an empty JSON array on HTTP error' do
+ allow(Net::HTTP).to receive(:get_response).and_return(Net::HTTPServerError.new('1.1', '500', 'Internal Server Error'))
+ expect(subject).to eq("[]")
+ end
+
+ it 'returns an empty JSON array on other errors' do
+ allow(Net::HTTP).to receive(:get_response).and_raise(StandardError.new('Some error message'))
+ allow(mock_class).to receive(:warn).with('Error getting release dates - Some error message')
+ expect(subject).to eq("[]")
+ end
+ end
end