forked from thoughtbot/high_voltage
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use HighVoltage::content_path for generated routes too
- Loading branch information
Xavier Spriet
committed
Sep 19, 2011
1 parent
97b73f8
commit 634cbbc
Showing
2 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Rails.application.routes.draw do | ||
match '/pages/*id' => 'high_voltage/pages#show', :as => :page, :format => false | ||
match "/#{HighVoltage::content_path}*id" => 'high_voltage/pages#show', :as => :page, :format => false | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,62 @@ | ||
require 'spec_helper' | ||
|
||
describe 'routes' do | ||
context "using default configuration" do | ||
|
||
it "should generate normal resource route with id" do | ||
page_path(:id => "one").should == "/pages/one" | ||
end | ||
it "should generate normal resource route with id" do | ||
page_path(:id => "one").should == "/pages/one" | ||
end | ||
|
||
it "should generate normal resource route with string" do | ||
page_path("one").should == "/pages/one" | ||
end | ||
it "should generate normal resource route with string" do | ||
page_path("one").should == "/pages/one" | ||
end | ||
|
||
it "should generate nested route with string" do | ||
page_path("one/two").should == "/pages/one/two" | ||
end | ||
it "should generate nested route with string" do | ||
page_path("one/two").should == "/pages/one/two" | ||
end | ||
|
||
it "should recognize nested route" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one/two" }, "/pages/one/two") | ||
end | ||
it "should recognize nested route" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one/two" }, "/pages/one/two") | ||
end | ||
|
||
it "should recognize normal route" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one" }, "/pages/one") | ||
end | ||
|
||
it "should recognize normal route" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one" }, "/pages/one") | ||
it "should recognize normal route with dots" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one.two.three" }, "/pages/one.two.three") | ||
end | ||
end | ||
|
||
it "should recognize normal route with dots" do | ||
assert_recognizes({ :controller => "high_voltage/pages", :action => "show", :id => "one.two.three" }, "/pages/one.two.three") | ||
context "using a custom content_path" do | ||
|
||
before(:all) do | ||
HighVoltage::content_path = "other_pages/" | ||
Rails.application.reload_routes! | ||
end | ||
|
||
it "should generate normal resource route with id" do | ||
page_path(:id => "one").should == "/other_pages/one" | ||
end | ||
|
||
it "should generate normal resource route with string" do | ||
page_path("one").should == "/other_pages/one" | ||
end | ||
|
||
it "should generate nested route with string" do | ||
page_path("one/two").should == "/other_pages/one/two" | ||
end | ||
|
||
it "should recognize nested route" do | ||
assert_recognizes({:controller => "high_voltage/pages", :action => "show", :id => "one/two"}, "/other_pages/one/two") | ||
end | ||
|
||
it "should recognize normal route" do | ||
assert_recognizes({:controller => "high_voltage/pages", :action => "show", :id => "one"}, "/other_pages/one") | ||
end | ||
|
||
it "should recognize normal route with dots" do | ||
assert_recognizes({:controller => "high_voltage/pages", :action => "show", :id => "one.two.three"}, "/other_pages/one.two.three") | ||
end | ||
end | ||
|
||
end |