public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Fixed edit test
Refactored login_as
Michael Hartl (author)
Thu Feb 21 12:30:51 -0800 2008
commit  a88d484a4bad8959464479571431218b257e36db
tree    fbdf07f3148d74818172d859e796d389038b1d92
parent  ee0767fb44704ca61af682a493b4290abcba5418
...
13
14
15
 
16
17
18
...
30
31
32
 
33
34
35
...
42
43
44
 
 
45
...
13
14
15
16
17
18
19
...
31
32
33
34
35
36
37
...
44
45
46
47
48
49
0
@@ -13,6 +13,7 @@ class PeopleController < ApplicationController
0
   end
0
   
0
   def new
0
+ @person = Person.new
0
   end
0
 
0
   def create
0
@@ -30,6 +31,7 @@ class PeopleController < ApplicationController
0
 
0
 
0
   def edit
0
+ @person = Person.find(params[:id])
0
   end
0
 
0
   def update
0
@@ -42,4 +44,6 @@ class PeopleController < ApplicationController
0
       end
0
     end
0
   end
0
+
0
+ private
0
 end
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
 
0
 <h2>Name</h2>
0
 
0
-<% form_for(current_person) do |f| %>
0
+<% form_for @person do |f| %>
0
   <div class="form_row">
0
     <%= f.text_field :name, :maxlength => Person::NAME_LENGTH %>
0
   </div>
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 <%= error_messages_for :person %>
0
 
0
-<% form_for :person, :url => people_path do |f| -%>
0
+<% form_for @person do |f| -%>
0
 <div class="form_row">
0
   <label for="email">Email address (never made public)</label>
0
   <br />
...
1
2
 
3
4
 
 
 
 
 
 
 
 
 
 
5
6
7
...
1
2
3
4
 
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1,7 +1,17 @@
0
 module AuthenticatedTestHelper
0
   # Sets the current person in the session from the person fixtures.
0
+ # Returns the person to allow @person = login_as(:quentin) construction.
0
   def login_as(person)
0
- @request.session[:person_id] = person ? people(person).id : nil
0
+ if person.is_a?(Person)
0
+ id = person.id
0
+ elsif person.is_a?(Symbol)
0
+ person = people(person)
0
+ id = person.id
0
+ elsif person.nil?
0
+ id = nil
0
+ end
0
+ @request.session[:person_id] = id
0
+ person
0
   end
0
 
0
   def authorize_as(user)
...
2
3
4
5
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
...
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
...
64
65
66
67
68
69
70
71
72
73
74
...
2
3
4
 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
62
63
64
 
 
 
 
 
 
 
 
 
 
65
66
67
68
69
 
70
71
72
73
...
81
82
83
 
 
 
 
 
84
85
86
0
@@ -2,8 +2,35 @@ require File.dirname(__FILE__) + '/../spec_helper'
0
 
0
 describe PeopleController do
0
   
0
- describe "signup" do
0
+ describe "people pages" do
0
     integrate_views
0
+
0
+ it "should have a working index" do
0
+ get :index
0
+ response.should be_success
0
+ response.should render_template("index")
0
+ end
0
+
0
+ it "should have a working new page" do
0
+ get :new
0
+ response.should be_success
0
+ response.should render_template("new")
0
+ end
0
+
0
+ it "should have a working show page" do
0
+ get :show, :id => people(:quentin)
0
+ response.should be_success
0
+ response.should render_template("show")
0
+ end
0
+
0
+ it "should have a working edit page" do
0
+ get :edit, :id => people(:quentin)
0
+ response.should be_success
0
+ response.should render_template("edit")
0
+ end
0
+ end
0
+
0
+ describe "signup" do
0
 
0
     it 'allows signup' do
0
       lambda do
0
@@ -35,22 +62,12 @@ describe PeopleController do
0
         response.should be_success
0
       end.should_not change(Person, :count)
0
     end
0
-
0
- it "should have a working index" do
0
- get :index
0
- response.should be_success
0
- end
0
-
0
- it "should show a person" do
0
- get :show, :id => people(:quentin)
0
- response.should be_success
0
- end
0
   end
0
   
0
   describe "edit" do
0
     
0
     before(:each) do
0
- @person = create_person
0
+ @person = login_as(:quentin)
0
     end
0
     
0
     it "should allow mass assignment to name" do
0
@@ -64,11 +81,6 @@ describe PeopleController do
0
       assigns(:current_person).description.should == "Me!"
0
       response.should redirect_to(person_url(assigns(:current_person)))
0
     end
0
-
0
- it "should have a working edit page" do
0
- get :edit, :id => @person
0
- response.should be_success
0
- end
0
   end
0
   
0
   def create_person(options = {})

Comments

    No one has commented yet.