Created
October 27, 2010 16:45
-
-
Save thedelchop/649430 to your computer and use it in GitHub Desktop.
Here are my routes for this app.
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
require "spec_helper" | |
describe PagesController do | |
describe "routing" do | |
it "recognizes and generates #home" do | |
{ :get => "/pages/home" }.should route_to(:controller => "pages", :action => "home") | |
end | |
context "when no user is signed in" do | |
it "routes the root route to pages#home" do | |
RootConstraints.stub!(:matches?).and_return(false) | |
{ :get => '/' }.should route_to(:controller => "pages", :action => "home") | |
end | |
end | |
context "when a user is already signed in" do | |
it "routes the root route to 'lists#show/master" do | |
RootConstraints.stub!(:matches?).and_return(true) | |
{ :get => '/' }.should route_to(:controller => "lists", :action => "show", :id => "master") | |
end | |
end | |
end | |
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
class RootConstraints | |
def self.matches?(request) | |
if request.env['warden'].authenticated?(:user) | |
return true | |
else | |
return false | |
end | |
end | |
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
require 'lib/root_constraints' | |
Tuhmayta::Application.routes.draw do | |
get "pages/home" | |
constraints(RootConstraints) do | |
root :controller => "lists", :action => "show", :id => "master" | |
end | |
root :to => "pages#home" | |
devise_for :users do | |
resources :tasks | |
resources :lists do | |
member do | |
post :sort | |
post :add | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment