Skip to content

Commit d3b5393

Browse files
committed
Add a test to ensure an HTML file is generated properly.
1 parent 6bbecac commit d3b5393

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Please redirect away from me and my permalink.
3+
permalink: /tags/our projects/
4+
redirect_to: /tags/our-projects/
5+
---
6+
7+
Bye.

spec/fixtures/tags/how we work.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
redirect_to: "/tags/how-we-work/"
3+
permalink: "/tags/how we work/"
4+
---

spec/jekyll_redirect_from/redirector_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
let(:post_to_redirect) { setup_post("2014-01-03-redirect-me-plz.md") }
66
let(:doc_to_redirect_from) { setup_doc("redirect-me-plz.md") }
77
let(:doc_to_redirect_to) { setup_doc("redirect-somewhere-else-plz.html") }
8+
let(:doc_to_redirect_to_permalnk) { setup_doc("redirect-somewhere-else-im-a-permalink.html") }
89
let(:page_with_one) { setup_page("one_redirect_url.md") }
910
let(:page_with_many) { setup_page("multiple_redirect_urls.md") }
1011
let(:page_with_one_redirect_to) { setup_page("one_redirect_to.md") }
1112
let(:page_with_many_redirect_to) { setup_page("multiple_redirect_tos.md") }
13+
let(:page_to_redirect_to_permlnk) { setup_page("tags/how we work.md") }
1214

1315
it "knows if a page or post is requesting a redirect page" do
1416
if JekyllRedirectFrom.jekyll_3?
@@ -26,6 +28,10 @@
2628
expect(redirector.redirect_to_url(doc_to_redirect_to)).to eql(["http://www.zombo.com"])
2729
end
2830

31+
it "knows if a document is requesting a redirect away" do
32+
expect(redirector.redirect_to_url(doc_to_redirect_to_permalnk)).to eql(["/tags/our-projects/"])
33+
end
34+
2935
it "handles one redirect path" do
3036
expect(redirector.alt_urls(page_with_one)).to eql(["mencius/was/my/father"])
3137
end
@@ -71,6 +77,12 @@
7177
expect(dest_dir("articles", "redirect-somewhere-else-plz.html").read).to include(%|<meta http-equiv="refresh" content="0; url=http://www.zombo.com">|)
7278
end
7379

80+
it "generates the refresh page for the collection with one redirect_to url and a permalink" do
81+
expect(dest_dir("tags", "our projects", "index")).not_to exist
82+
expect(dest_dir("tags", "our projects", "index.html")).to exist
83+
expect(dest_dir("tags", "our projects", "index.html").read).to include(%|<meta http-equiv="refresh" content="0; url=/tags/our-projects/">|)
84+
end
85+
7486
it "generates the refresh page for the page with one redirect_to url" do
7587
expect(dest_dir("one_redirect_to.html")).to exist
7688
expect(dest_dir("one_redirect_to.html").read).to include(%|<meta http-equiv="refresh" content="0; url=https://www.github.com">|)
@@ -85,6 +97,12 @@
8597
expect(dest_dir("multiple_redirect_tos.html")).to exist
8698
expect(dest_dir("multiple_redirect_tos.html").read).not_to include('LAYOUT INCLUDED')
8799
end
100+
101+
it "generates the refresh page for the page with one redirect_to url and a permalink" do
102+
expect(dest_dir("tags", "how we work", "index")).not_to exist
103+
expect(dest_dir("tags", "how we work", "index.html")).to exist
104+
expect(dest_dir("tags", "how we work", "index.html").read).to include(%|<meta http-equiv="refresh" content="0; url=/tags/how-we-work/">|)
105+
end
88106
end
89107

90108
context "prefix" do

0 commit comments

Comments
 (0)