Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit 274a8f3

Browse files
committed
Add accounts and projects controllers and routes.
1 parent df1da07 commit 274a8f3

5 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class AccountsController < ApplicationController
2+
inherit_resources
3+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ProjectsController < ApplicationController
2+
inherit_resources
3+
belongs_to :account
4+
end

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
Example::Application.routes.draw do
2+
resources :accounts do
3+
resources :projects
4+
end
25
end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require 'spec_helper'
2+
3+
describe AccountsController do
4+
describe "routing" do
5+
it '/accounts to Accounts#index' do
6+
path = accounts_path
7+
path.should == '/accounts'
8+
{ :get => path }.should route_to(
9+
:controller => 'accounts',
10+
:action => 'index'
11+
)
12+
end
13+
14+
it '/accounts/new to Account#new' do
15+
path = new_account_path
16+
path.should == '/accounts/new'
17+
{ :get => path }.should route_to(
18+
:controller => 'accounts',
19+
:action => 'new'
20+
)
21+
end
22+
23+
it '/accounts/:account_id to Account#show' do
24+
path = account_path 'foocorp'
25+
path.should == '/accounts/foocorp'
26+
{ :get => path }.should route_to(
27+
:controller => 'accounts',
28+
:action => 'show',
29+
:id => 'foocorp'
30+
)
31+
end
32+
33+
it '/accounts/:account_id/edit to Account#edit' do
34+
path = edit_account_path 'foocorp'
35+
path.should == '/accounts/foocorp/edit'
36+
{ :get => path }.should route_to(
37+
:controller => 'accounts',
38+
:action => 'edit',
39+
:id => 'foocorp'
40+
)
41+
end
42+
end
43+
end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require 'spec_helper'
2+
3+
describe ProjectsController do
4+
describe "routing" do
5+
it '/accounts/:account_id/projects to Projects#index' do
6+
path = account_projects_path 'foocorp'
7+
path.should == '/accounts/foocorp/projects'
8+
{ :get => path }.should route_to(
9+
:controller => 'projects',
10+
:action => 'index',
11+
:account_id => 'foocorp'
12+
)
13+
end
14+
15+
it '/accounts/:account_id/projects/new to Projects#new' do
16+
path = new_account_project_path('foocorp')
17+
path.should == '/accounts/foocorp/projects/new'
18+
{ :get => path }.should route_to(
19+
:controller => 'projects',
20+
:action => 'new',
21+
:account_id => 'foocorp'
22+
)
23+
end
24+
25+
it '/accounts/:account_id/projects/:project_id to Projects#show' do
26+
path = account_project_path 'foocorp', 'widgets'
27+
path.should == '/accounts/foocorp/projects/widgets'
28+
{ :get => path }.should route_to(
29+
:controller => 'projects',
30+
:action => 'show',
31+
:account_id => 'foocorp',
32+
:id => 'widgets'
33+
)
34+
end
35+
36+
it '/accounts/:account_id/projects/:project_id/edit to Projects#edit' do
37+
path = edit_account_project_path 'foocorp', 'widgets'
38+
path.should == '/accounts/foocorp/projects/widgets/edit'
39+
{ :get => path }.should route_to(
40+
:controller => 'projects',
41+
:action => 'edit',
42+
:account_id => 'foocorp',
43+
:id => 'widgets'
44+
)
45+
end
46+
end
47+
end

0 commit comments

Comments
 (0)