Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add accounts and projects controllers and routes.

  • Loading branch information...
jasoncodes committed Apr 4, 2011
1 parent df1da07 commit 274a8f34c702afce8e22dcb532eb2c805da4df21
@@ -0,0 +1,3 @@
class AccountsController < ApplicationController
inherit_resources
end
@@ -0,0 +1,4 @@
class ProjectsController < ApplicationController
inherit_resources
belongs_to :account
end
@@ -1,2 +1,5 @@
Example::Application.routes.draw do
resources :accounts do
resources :projects
end
end
@@ -0,0 +1,43 @@
require 'spec_helper'

describe AccountsController do
describe "routing" do
it '/accounts to Accounts#index' do
path = accounts_path
path.should == '/accounts'
{ :get => path }.should route_to(
:controller => 'accounts',
:action => 'index'
)
end

it '/accounts/new to Account#new' do
path = new_account_path
path.should == '/accounts/new'
{ :get => path }.should route_to(
:controller => 'accounts',
:action => 'new'
)
end

it '/accounts/:account_id to Account#show' do
path = account_path 'foocorp'
path.should == '/accounts/foocorp'
{ :get => path }.should route_to(
:controller => 'accounts',
:action => 'show',
:id => 'foocorp'
)
end

it '/accounts/:account_id/edit to Account#edit' do
path = edit_account_path 'foocorp'
path.should == '/accounts/foocorp/edit'
{ :get => path }.should route_to(
:controller => 'accounts',
:action => 'edit',
:id => 'foocorp'
)
end
end
end
@@ -0,0 +1,47 @@
require 'spec_helper'

describe ProjectsController do
describe "routing" do
it '/accounts/:account_id/projects to Projects#index' do
path = account_projects_path 'foocorp'
path.should == '/accounts/foocorp/projects'
{ :get => path }.should route_to(
:controller => 'projects',
:action => 'index',
:account_id => 'foocorp'
)
end

it '/accounts/:account_id/projects/new to Projects#new' do
path = new_account_project_path('foocorp')
path.should == '/accounts/foocorp/projects/new'
{ :get => path }.should route_to(
:controller => 'projects',
:action => 'new',
:account_id => 'foocorp'
)
end

it '/accounts/:account_id/projects/:project_id to Projects#show' do
path = account_project_path 'foocorp', 'widgets'
path.should == '/accounts/foocorp/projects/widgets'
{ :get => path }.should route_to(
:controller => 'projects',
:action => 'show',
:account_id => 'foocorp',
:id => 'widgets'
)
end

it '/accounts/:account_id/projects/:project_id/edit to Projects#edit' do
path = edit_account_project_path 'foocorp', 'widgets'
path.should == '/accounts/foocorp/projects/widgets/edit'
{ :get => path }.should route_to(
:controller => 'projects',
:action => 'edit',
:account_id => 'foocorp',
:id => 'widgets'
)
end
end
end

0 comments on commit 274a8f3

Please sign in to comment.
You can’t perform that action at this time.