Allow configuring future metadata for individual collecti...
kcdragon
·
2026-03-11
·
via Recent Commits to jekyll:master
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "helper" |
| 4 | + |
| 5 | +class TestPublisher < JekyllUnitTest |
| 6 | +context "default configuration" do |
| 7 | +setup do |
| 8 | +site = fixture_site |
| 9 | +collection = Jekyll::Collection.new(site, "methods") |
| 10 | +@thing = Jekyll::Document.new( |
| 11 | +source_dir("methods/method.md"), |
| 12 | +:site => site, |
| 13 | +:collection => collection |
| 14 | +) |
| 15 | +@thing.data["date"] = (Time.now + (60 * 60 * 24)).to_i # tomorrow |
| 16 | +@publisher = Jekyll::Publisher.new(site) |
| 17 | +end |
| 18 | + |
| 19 | +should "be hidden in the future" do |
| 20 | +assert @publisher.hidden_in_the_future?(@thing) |
| 21 | +end |
| 22 | +end |
| 23 | + |
| 24 | +context "when a thing's collection is configured to show future posts" do |
| 25 | +setup do |
| 26 | +site = fixture_site |
| 27 | +collection = Jekyll::Collection.new(site, "methods") |
| 28 | +collection.metadata["future"] = true |
| 29 | +@thing = Jekyll::Document.new( |
| 30 | +source_dir("methods/method.md"), |
| 31 | +:site => site, |
| 32 | +:collection => collection |
| 33 | +) |
| 34 | +@thing.data["date"] = (Time.now + (60 * 60 * 24)).to_i # tomorrow |
| 35 | +@publisher = Jekyll::Publisher.new(site) |
| 36 | +end |
| 37 | + |
| 38 | +should "not be hidden in the future" do |
| 39 | +refute @publisher.hidden_in_the_future?(@thing) |
| 40 | +end |
| 41 | +end |
| 42 | +end |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。