mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 12:09:27 +08:00
Compute releaseDate and supportEndDate as the last Tuesday of the relevant month (a fully-specified YYYY-MM-DD) instead of an approximate YYYY-MM month, and convert the remaining vague values in versions.json to their precise last-Tuesday equivalents. --------- Co-authored-by: Loïc Guitaut <loic@discourse.org>
45 lines
1.1 KiB
Ruby
Vendored
45 lines
1.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
require "release_utils"
|
|
|
|
RSpec.describe ReleaseUtils do
|
|
describe ".last_tuesday_of_month" do
|
|
subject(:last_tuesday) { described_class.last_tuesday_of_month(date) }
|
|
|
|
context "with a month ending mid-week" do
|
|
let(:date) { Date.new(2026, 7) }
|
|
|
|
it { is_expected.to eq(Date.new(2026, 7, 28)) }
|
|
end
|
|
|
|
context "when the month ends on a Tuesday" do
|
|
let(:date) { Date.new(2026, 6) }
|
|
|
|
it { is_expected.to eq(Date.new(2026, 6, 30)) }
|
|
end
|
|
|
|
context "when the following month starts on a Tuesday" do
|
|
let(:date) { Date.new(2026, 8) }
|
|
|
|
it { is_expected.to eq(Date.new(2026, 8, 25)) }
|
|
end
|
|
|
|
context "with a leap February ending on a Tuesday" do
|
|
let(:date) { Date.new(2028, 2) }
|
|
|
|
it { is_expected.to eq(Date.new(2028, 2, 29)) }
|
|
end
|
|
|
|
context "with December (year rollover)" do
|
|
let(:date) { Date.new(2026, 12) }
|
|
|
|
it { is_expected.to eq(Date.new(2026, 12, 29)) }
|
|
end
|
|
|
|
context "with a date mid-month" do
|
|
let(:date) { Date.new(2026, 7, 15) }
|
|
|
|
it { is_expected.to eq(Date.new(2026, 7, 28)) }
|
|
end
|
|
end
|
|
end
|