Permalink
Browse files

Use HighVoltage::content_path for generated routes too

  • Loading branch information...
1 parent 97b73f8 commit 634cbbca97762c6f50f15a2a0826bf34be97fbad Xavier Spriet committed Sep 19, 2011
Showing with 52 additions and 18 deletions.
  1. +2 −1 config/routes.rb
  2. +50 −17 spec/routing/routes_spec.rb
View
@@ -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
@@ -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.