Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

Commit 4cb3af2

Browse files
committed
Create a skeleton AdminController and re-route all People requests there
1 parent 32c8a53 commit 4cb3af2

File tree

12 files changed

+74
-10
lines changed

12 files changed

+74
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/admin.css.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Admin controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/admin_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class AdminController < ApplicationController
2+
def index
3+
end
4+
end

app/helpers/admin_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module AdminHelper
2+
end

app/views/admin/index.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Admin#index</h1>
2+
<p>Find me in app/views/admin/index.html.erb</p>

app/views/layouts/application.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<%= menu_item "People", people_path %>
5252
<%= menu_item "Projects", projects_path %>
5353
<% end %>
54+
<%= menu_group :pull => :right do %>
55+
<% menu_item "Admin", admin_path %>
56+
<% end %>
5457
</div>
5558
</div>
5659
</div>

config/routes.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
# Example resource route (maps HTTP verbs to controller actions automatically):
2222
# resources :products
2323

24-
resources :people do
25-
get :auto_complete_search, :on => :collection
24+
scope :admin do
25+
get "/", :to => "admin#index", :as => :admin
26+
27+
resources :people do
28+
get :auto_complete_search, :on => :collection
29+
end
30+
get "/people/search/:name", :to => "people#search_by_name"
2631
end
27-
get "/people/search/:name", :to => "people#search_by_name"
2832

2933
resources :projects do
3034
get :auto_complete_search, :on => :collection
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe AdminController, :type => :controller do
4+
5+
describe "GET index" do
6+
it "returns http success" do
7+
get :index
8+
expect(response).to have_http_status(:success)
9+
end
10+
end
11+
12+
end

spec/helpers/admin_helper_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'rails_helper'
2+
3+
# Specs in this file have access to a helper object that includes
4+
# the AdminHelper. For example:
5+
#
6+
# describe AdminHelper do
7+
# describe "string concat" do
8+
# it "concats two strings with spaces" do
9+
# expect(helper.concat_strings("this","that")).to eq("this that")
10+
# end
11+
# end
12+
# end
13+
RSpec.describe AdminHelper, :type => :helper do
14+
pending "add some examples to (or delete) #{__FILE__}"
15+
end

spec/routing/admin_routing_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "rails_helper"
2+
3+
RSpec.describe AdminController, :type => :routing do
4+
describe "routing" do
5+
6+
it "routes to #index" do
7+
expect(:get => "/admin").to route_to("admin#index")
8+
end
9+
10+
end
11+
end

spec/routing/people_routing_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
describe "routing" do
55

66
it "routes to #index" do
7-
expect(:get => "/people").to route_to("people#index")
7+
expect(:get => "/admin/people").to route_to("people#index")
88
end
99

1010
it "routes to #new" do
11-
expect(:get => "/people/new").to route_to("people#new")
11+
expect(:get => "/admin/people/new").to route_to("people#new")
1212
end
1313

1414
it "routes to #show" do
15-
expect(:get => "/people/1").to route_to("people#show", :id => "1")
15+
expect(:get => "/admin/people/1").to route_to("people#show", :id => "1")
1616
end
1717

1818
it "routes to #edit" do
19-
expect(:get => "/people/1/edit").to route_to("people#edit", :id => "1")
19+
expect(:get => "/admin/people/1/edit").to route_to("people#edit", :id => "1")
2020
end
2121

2222
it "routes to #create" do
23-
expect(:post => "/people").to route_to("people#create")
23+
expect(:post => "/admin/people").to route_to("people#create")
2424
end
2525

2626
it "routes to #update" do
27-
expect(:put => "/people/1").to route_to("people#update", :id => "1")
27+
expect(:put => "/admin/people/1").to route_to("people#update", :id => "1")
2828
end
2929

3030
it "routes to #destroy" do
31-
expect(:delete => "/people/1").to route_to("people#destroy", :id => "1")
31+
expect(:delete => "/admin/people/1").to route_to("people#destroy", :id => "1")
3232
end
3333

3434
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe "admin/index.html.erb", :type => :view do
4+
pending "add some examples to (or delete) #{__FILE__}"
5+
end

0 commit comments

Comments
 (0)