Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

section 5.5 - completed layout section

  • Loading branch information...
commit 2d3732d07bed782aa58d7f3e2f595e2c81a13f2e 1 parent 24e9595
Jacob Danner authored May 31, 2012
81  app/controllers/users_controller.rb
... ...
@@ -1,85 +1,4 @@
1 1
 class UsersController < ApplicationController
2  
-  # GET /users
3  
-  # GET /users.json
4  
-  def index
5  
-    @users = User.all
6  
-
7  
-    respond_to do |format|
8  
-      format.html # index.html.erb
9  
-      format.json { render json: @users }
10  
-      format.xml { render xml: @users }
11  
-    end
12  
-  end
13  
-
14  
-  # GET /users/1
15  
-  # GET /users/1.json
16  
-  def show
17  
-    @user = User.find(params[:id])
18  
-
19  
-    respond_to do |format|
20  
-      format.html # show.html.erb
21  
-      format.json { render json: @user }
22  
-      format.xml { render xml: @user }
23  
-    end
24  
-  end
25  
-
26  
-  # GET /users/new
27  
-  # GET /users/new.json
28 2
   def new
29  
-    @user = User.new
30  
-
31  
-    respond_to do |format|
32  
-      format.html # new.html.erb
33  
-      format.json { render json: @user }
34  
-    end
35  
-  end
36  
-
37  
-  # GET /users/1/edit
38  
-  def edit
39  
-    @user = User.find(params[:id])
40  
-  end
41  
-
42  
-  # POST /users
43  
-  # POST /users.json
44  
-  def create
45  
-    @user = User.new(params[:user])
46  
-
47  
-    respond_to do |format|
48  
-      if @user.save
49  
-        format.html { redirect_to @user, notice: 'User was successfully created.' }
50  
-        format.json { render json: @user, status: :created, location: @user }
51  
-      else
52  
-        format.html { render action: "new" }
53  
-        format.json { render json: @user.errors, status: :unprocessable_entity }
54  
-      end
55  
-    end
56  
-  end
57  
-
58  
-  # PUT /users/1
59  
-  # PUT /users/1.json
60  
-  def update
61  
-    @user = User.find(params[:id])
62  
-
63  
-    respond_to do |format|
64  
-      if @user.update_attributes(params[:user])
65  
-        format.html { redirect_to @user, notice: 'User was successfully updated.' }
66  
-        format.json { head :no_content }
67  
-      else
68  
-        format.html { render action: "edit" }
69  
-        format.json { render json: @user.errors, status: :unprocessable_entity }
70  
-      end
71  
-    end
72  
-  end
73  
-
74  
-  # DELETE /users/1
75  
-  # DELETE /users/1.json
76  
-  def destroy
77  
-    @user = User.find(params[:id])
78  
-    @user.destroy
79  
-
80  
-    respond_to do |format|
81  
-      format.html { redirect_to users_url }
82  
-      format.json { head :no_content }
83  
-    end
84 3
   end
85 4
 end
2  app/views/static_pages/home.html.erb
@@ -5,6 +5,6 @@ This is the home page for the
5 5
 <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
6 6
 sample Application
7 7
 </h2>
8  
-<%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary" %>
  8
+<%= link_to "Sign up now!", signup_path, class: "btn btn-large btn-primary" %>
9 9
 </div>
10 10
 <%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/'%>
8  app/views/users/new.html.erb
... ...
@@ -1,5 +1,3 @@
1  
-<h1>New user</h1>
2  
-
3  
-<%= render 'form' %>
4  
-
5  
-<%= link_to 'Back', users_path %>
  1
+<% provide(:title, 'Sign up') %>
  2
+<h1>Sign up</h1>
  3
+<p>Find me</p>
6  config/routes.rb
... ...
@@ -1,5 +1,7 @@
1 1
 AgileWeb::Application.routes.draw do
2  
-  
  2
+  get "users/new"
  3
+  match '/signup', to: 'users#new'
  4
+
3 5
   #get "static_pages/home"
4 6
   #match '/home', to: 'static_pages#home'
5 7
   root to: 'static_pages#home'
@@ -10,6 +12,8 @@
10 12
   #get "static_pages/contact"
11 13
   match '/contact', to: 'static_pages#contact'
12 14
 
  15
+  
  16
+
13 17
   resources :microposts
14 18
 
15 19
   resources :users
13  spec/requests/static_pages_spec.rb
@@ -2,11 +2,10 @@
2 2
 
3 3
 describe "Static pages" do
4 4
   let(:base_title) {"Ruby on Rails Tutorial |"}
  5
+  subject { page }
5 6
   describe "Home page" do
6 7
     before { visit root_path } # /static_pages/home
7  
-    it "should have the h1 'Sample App'" do
8  
-      page.should have_selector('h1', :text=>'Sample App')
9  
-    end
  8
+    it { should have_selector('h1', :text=>'Sample App')}
10 9
     it "should have the base title'" do
11 10
       page.should have_selector('title', 
12 11
                                 :text => "Ruby on Rails Tutorial")
@@ -20,32 +19,28 @@
20 19
   describe "Help page" do
21 20
     before { visit help_path }
22 21
     it "should have the h1 'Help'" do
23  
-      visit help_path #'/static_pages/help'
24 22
       page.should have_selector('h1', :text=>'Help')
25 23
     end 
26 24
     it "should have the title 'Help'" do
27  
-      visit help_path #'/static_pages/help'
28 25
       page.should have_selector('title', :text=>"#{base_title} Help")
29 26
     end
30 27
   end
31 28
 
32 29
   describe "About page" do
  30
+    before { visit about_path }
33 31
     it "should have the h1 'About Us'" do
34  
-      visit about_path #'/static_pages/about'
35 32
       page.should have_selector('h1', :text =>'About Us')
36 33
     end 
37 34
     it "should have the title 'About Us'" do
38  
-      visit about_path #'/static_pages/about'
39 35
       page.should have_selector('title', :text=>"#{base_title} About Us")
40 36
     end
41 37
   end
42 38
   describe "Contact page" do
  39
+    before { visit contact_path }
43 40
     it "should have the h1 'Contact'" do
44  
-      visit contact_path #'/static_pages/contact'
45 41
       page.should have_selector('h1', text:'Contact')
46 42
     end 
47 43
     it "should have the title 'Contact'" do
48  
-      visit contact_path #'/static_pages/contact'
49 44
       page.should have_selector('title', :text=>"#{base_title} Contact")
50 45
     end
51 46
   end
11  spec/requests/user_pages_spec.rb
... ...
@@ -0,0 +1,11 @@
  1
+require 'spec_helper'
  2
+
  3
+describe "User pages" do
  4
+  subject { page }
  5
+
  6
+  describe "signup page" do
  7
+    before {visit signup_path}
  8
+    it { should have_selector('h1', text: 'Sign up')}
  9
+    it { should have_selector('title', text: 'Sign up')}
  10
+  end
  11
+end

0 notes on commit 2d3732d

Please sign in to comment.
Something went wrong with that request. Please try again.