|
5 | 5 | let(:post_to_redirect) { setup_post("2014-01-03-redirect-me-plz.md") } |
6 | 6 | let(:doc_to_redirect_from) { setup_doc("redirect-me-plz.md") } |
7 | 7 | 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") } |
8 | 9 | let(:page_with_one) { setup_page("one_redirect_url.md") } |
9 | 10 | let(:page_with_many) { setup_page("multiple_redirect_urls.md") } |
10 | 11 | let(:page_with_one_redirect_to) { setup_page("one_redirect_to.md") } |
11 | 12 | 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") } |
12 | 14 |
|
13 | 15 | it "knows if a page or post is requesting a redirect page" do |
14 | 16 | if JekyllRedirectFrom.jekyll_3? |
|
26 | 28 | expect(redirector.redirect_to_url(doc_to_redirect_to)).to eql(["http://www.zombo.com"]) |
27 | 29 | end |
28 | 30 |
|
| 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 | + |
29 | 35 | it "handles one redirect path" do |
30 | 36 | expect(redirector.alt_urls(page_with_one)).to eql(["mencius/was/my/father"]) |
31 | 37 | end |
|
71 | 77 | expect(dest_dir("articles", "redirect-somewhere-else-plz.html").read).to include(%|<meta http-equiv="refresh" content="0; url=http://www.zombo.com">|) |
72 | 78 | end |
73 | 79 |
|
| 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 | + |
74 | 86 | it "generates the refresh page for the page with one redirect_to url" do |
75 | 87 | expect(dest_dir("one_redirect_to.html")).to exist |
76 | 88 | expect(dest_dir("one_redirect_to.html").read).to include(%|<meta http-equiv="refresh" content="0; url=https://www.github.com">|) |
|
85 | 97 | expect(dest_dir("multiple_redirect_tos.html")).to exist |
86 | 98 | expect(dest_dir("multiple_redirect_tos.html").read).not_to include('LAYOUT INCLUDED') |
87 | 99 | 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 |
88 | 106 | end |
89 | 107 |
|
90 | 108 | context "prefix" do |
|
0 commit comments