implement redirect support
This commit is contained in:
parent
912b33929f
commit
d86dffa7c6
8 changed files with 271 additions and 127 deletions
60
middleman-core/features/redirects.feature
Normal file
60
middleman-core/features/redirects.feature
Normal file
|
@ -0,0 +1,60 @@
|
|||
Feature: Meta redirects
|
||||
|
||||
Scenario: Redirect to unknown file
|
||||
Given a fixture app "large-build-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
redirect "hello.html", :to => "world.html"
|
||||
"""
|
||||
And the Server is running at "large-build-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see '<meta http-equiv=refresh content="0; url=world.html"'
|
||||
|
||||
Scenario: Redirect to external site
|
||||
Given a fixture app "large-build-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
redirect "hello.html", :to => "http://example.com"
|
||||
"""
|
||||
And the Server is running at "large-build-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see '<meta http-equiv=refresh content="0; url=http://example.com"'
|
||||
|
||||
Scenario: Redirect to a resource
|
||||
Given a fixture app "large-build-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
ready do
|
||||
r = sitemap.find_resource_by_path("static.html")
|
||||
redirect "hello.html", :to => r
|
||||
end
|
||||
"""
|
||||
And the Server is running at "large-build-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see '<meta http-equiv=refresh content="0; url=/static.html"'
|
||||
|
||||
Scenario: Redirect to a path with directory index
|
||||
Given a fixture app "large-build-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
activate :directory_indexes
|
||||
redirect "hello.html", :to => "link_test.html"
|
||||
redirect "hello2.html", :to => "services/index.html"
|
||||
"""
|
||||
And the Server is running at "large-build-app"
|
||||
When I go to "/hello/index.html"
|
||||
Then I should see '<meta http-equiv=refresh content="0; url=/link_test/"'
|
||||
When I go to "/hello2/index.html"
|
||||
Then I should see '<meta http-equiv=refresh content="0; url=/services/"'
|
||||
|
||||
Scenario: Redirect with custom html
|
||||
Given a fixture app "large-build-app"
|
||||
And a file named "config.rb" with:
|
||||
"""
|
||||
redirect "hello.html", :to => "world.html" do |from, to|
|
||||
"#{from} to #{to}"
|
||||
end
|
||||
"""
|
||||
And the Server is running at "large-build-app"
|
||||
When I go to "/hello.html"
|
||||
Then I should see 'hello.html to world.html'
|
Loading…
Add table
Add a link
Reference in a new issue