Skip to content

Commit

Permalink
Use HighVoltage::content_path for generated routes too
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Spriet committed Sep 19, 2011
1 parent 97b73f8 commit 634cbbc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 18 deletions.
3 changes: 2 additions & 1 deletion config/routes.rb
@@ -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
67 changes: 50 additions & 17 deletions spec/routing/routes_spec.rb
@@ -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

0 comments on commit 634cbbc

Please sign in to comment.