diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-19 11:15:08 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-19 13:48:21 +0100 |
commit | 6809ea1e7c5cb540d6d81ce0a47f3f0f5d761e8e (patch) | |
tree | 7833708d48af56b6d4f7aa61067e2a3f1f59bc0b /hugolib/site_test.go | |
parent | a0b3d9db1689ea69ea5c23915df5b07d4fd9bb5c (diff) |
hugolib: Fix .Site.LastChange
This commit makes sure that the `.Site.LastChange` is fetched from the latest page modification date.
Previously, this value was fetched from the last page in the default page sort, which may not be the last by date
if weight is set.
Fixes #2909
Closes #2910
Diffstat (limited to 'hugolib/site_test.go')
-rw-r--r-- | hugolib/site_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 9629f763a..7919ba377 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -184,6 +184,23 @@ func TestFutureExpirationRender(t *testing.T) { } } +func TestLastChange(t *testing.T) { + t.Parallel() + + cfg, fs := newTestCfg() + + writeSource(t, fs, filepath.Join("content", "sect/doc1.md"), "---\ntitle: doc1\nweight: 1\ndate: 2014-05-29\n---\n# doc1\n*some content*") + writeSource(t, fs, filepath.Join("content", "sect/doc2.md"), "---\ntitle: doc2\nweight: 2\ndate: 2015-05-29\n---\n# doc2\n*some content*") + writeSource(t, fs, filepath.Join("content", "sect/doc3.md"), "---\ntitle: doc3\nweight: 3\ndate: 2017-05-29\n---\n# doc3\n*some content*") + writeSource(t, fs, filepath.Join("content", "sect/doc4.md"), "---\ntitle: doc4\nweight: 4\ndate: 2016-05-29\n---\n# doc4\n*some content*") + writeSource(t, fs, filepath.Join("content", "sect/doc5.md"), "---\ntitle: doc5\nweight: 3\n---\n# doc5\n*some content*") + + s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true}) + + require.False(t, s.Info.LastChange.IsZero(), "Site.LastChange is zero") + require.Equal(t, 2017, s.Info.LastChange.Year(), "Site.LastChange should be set to the page with latest Lastmod (year 2017)") +} + // Issue #957 func TestCrossrefs(t *testing.T) { t.Parallel() |