public
Description: Gitorious aims to provide a great way of doing distributed opensource code collaboration.
Homepage: http://gitorious.org/projects/gitorious
Clone URL: git://github.com/dysinger/gitorious.git
Search Repo:
- added show routes task
- added basic project controller
Johan Sørensen (author)
Sun Aug 19 14:38:25 -0700 2007
commit  0512492644a253fcc9b32d57ea46363b4d835943
tree    1fc009db959148f01edcebe7c052eee7b7685b95
parent  b4213073d864981ecea5322fde2639fafc6c4a28
...
2
3
4
5
6
 
 
7
...
2
3
4
 
 
5
6
7
0
@@ -2,6 +2,6 @@
0
 # Likewise, all the methods added will be available for all controllers.
0
 
0
 class ApplicationController < ActionController::Base
0
- # Pick a unique cookie name to distinguish our session data from others'
0
- session :session_key => '_ks1_session_id'
0
+ session :session_key => '_ks1_session_id', :secret => "TODO:CHANGEME!!!"
0
+ include AuthenticatedSystem
0
 end
...
1
2
3
4
5
6
7
...
1
 
 
 
2
3
4
0
@@ -1,7 +1,4 @@
0
 class UsersController < ApplicationController
0
- # Be sure to include AuthenticationSystem in Application Controller instead
0
- include AuthenticatedSystem
0
-
0
   # render new.rhtml
0
   def new
0
   end
...
31
32
33
34
 
35
36
37
...
31
32
33
 
34
35
36
37
0
@@ -31,7 +31,7 @@
0
       </div>
0
       
0
       <ul id="mainmenu" class="column span-14 first last">
0
- <li class="first"><%= link_to "Projects" -%></li>
0
+ <li class="first"><%= link_to "Projects", projects_path -%></li>
0
         <li><%= link_to "Tasks" -%></li>
0
         <li><%= link_to "Repositories" -%></li>
0
         <li><%= link_to "Members" -%></li>
...
17
18
19
20
 
21
22
23
 
 
 
 
24
25
26
27
 
 
28
29
30
...
17
18
19
 
20
21
22
23
24
25
26
27
28
29
 
 
30
31
32
33
34
0
@@ -17,14 +17,18 @@ ActionController::Routing::Routes.draw do |map|
0
   # instead of a file named 'wsdl'
0
   #map.connect ':controller/service.wsdl', :action => 'wsdl'
0
   
0
- map.home "", :controller => "sessions", :action => "new" # TODO change eventually
0
+ map.home "", :controller => "projects", :action => "new" # TODO change eventually
0
   
0
   map.resources :users
0
   map.resource :sessions
0
+ map.resources :projects #, :has_many => [:tasks, :repositories, :milestones, :pages] do |project|
0
+ # project.resources :tasks
0
+ # project.resources :repositories
0
+ #end
0
   
0
   map.with_options :controller => 'sessions' do |session|
0
- session.login 'login', :action => 'new'
0
- session.logout 'logout', :action => 'destroy'
0
+ session.login '/login', :action => 'new'
0
+ session.logout '/logout', :action => 'destroy'
0
   end
0
 
0
   # Install the default route as the lowest priority.
...
64
65
66
67
 
68
69
70
...
64
65
66
 
67
68
69
70
0
@@ -64,7 +64,7 @@ module AuthenticatedSystem
0
       respond_to do |accepts|
0
         accepts.html do
0
           store_location
0
- redirect_to :controller => '/sessions', :action => 'login'
0
+ redirect_to :controller => '/sessions', :action => 'new'
0
         end
0
         accepts.xml do
0
           headers["Status"] = "Unauthorized"
...
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
37
38
 
39
40
41
42
43
 
44
45
46
47
48
49
50
 
 
51
52
53
54
55
56
57
58
 
 
 
59
60
61
62
63
64
 
65
66
67
...
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
37
 
38
39
40
41
42
 
43
44
45
46
47
48
 
 
49
50
51
52
53
54
55
 
 
 
56
57
58
59
60
61
62
63
 
64
65
66
67
0
@@ -11,57 +11,57 @@ describe SessionsController do
0
   end
0
 
0
   it "should login and redirect" do
0
- post :create, :login => "quentin", :password => "test"
0
+ post :create, :login => "johan", :password => "test"
0
     session[:user].should_not be(nil)
0
     response.should be_redirect
0
   end
0
     
0
   it "should fail login and not redirect" do
0
- post :create, :login => 'quentin', :password => 'bad password'
0
+ post :create, :login => 'johan', :password => 'bad password'
0
     session[:user].should be(nil)
0
     response.should be_success
0
   end
0
     
0
   it "should logout" do
0
- login_as :quentin
0
+ login_as :johan
0
     get :destroy
0
     session[:user].should be(nil)
0
     response.should be_redirect
0
   end
0
   
0
   it "should remember me" do
0
- post :create, :login => 'quentin', :password => 'test', :remember_me => "1"
0
+ post :create, :login => 'johan', :password => 'test', :remember_me => "1"
0
     response.cookies["auth_token"].should_not be(nil)
0
   end
0
   
0
   it "should should not remember me" do
0
- post :create, :login => 'quentin', :password => 'test', :remember_me => "0"
0
+ post :create, :login => 'johan', :password => 'test', :remember_me => "0"
0
     response.cookies["auth_token"].should be(nil)
0
   end
0
     
0
   it "should delete token on logout" do
0
- login_as :quentin
0
+ login_as :johan
0
     get :destroy
0
     response.cookies["auth_token"].should == []
0
   end
0
   
0
   it "should login with cookie" do
0
- users(:quentin).remember_me
0
- request.cookies["auth_token"] = cookie_for(:quentin)
0
+ users(:johan).remember_me
0
+ request.cookies["auth_token"] = cookie_for(:johan)
0
     get :new
0
     controller.send(:logged_in?).should be(true)
0
   end
0
     
0
   it "should fail when trying to login with with expired cookie" do
0
- users(:quentin).remember_me
0
- users(:quentin).update_attribute :remember_token_expires_at, 5.minutes.ago.utc
0
- request.cookies["auth_token"] = cookie_for(:quentin)
0
+ users(:johan).remember_me
0
+ users(:johan).update_attribute :remember_token_expires_at, 5.minutes.ago.utc
0
+ request.cookies["auth_token"] = cookie_for(:johan)
0
     get :new
0
     controller.send(:logged_in?).should be(false)
0
   end
0
     
0
   it "should fail cookie login" do
0
- users(:quentin).remember_me
0
+ users(:johan).remember_me
0
     @request.cookies["auth_token"] = auth_token('invalid_auth_token')
0
     get :new
0
     @controller.send(:logged_in?).should be(false)
...
47
48
49
50
51
 
 
52
53
54
 
55
56
57
...
47
48
49
 
 
50
51
52
53
 
54
55
56
57
0
@@ -47,11 +47,11 @@ describe UsersController do
0
   end
0
     
0
   it "should activate user" do
0
- User.authenticate('aaron', 'test').should be(nil)
0
- get :activate, :activation_code => users(:aaron).activation_code
0
+ User.authenticate('moe', 'test').should be(nil)
0
+ get :activate, :activation_code => users(:moe).activation_code
0
     response.should redirect_to '/'
0
     flash[:notice].should_not be(nil)
0
- User.authenticate('aaron', 'test').should == users(:aaron)
0
+ User.authenticate('moe', 'test').should == users(:moe)
0
   end
0
 
0
 end
...
1
2
 
3
4
5
 
 
 
6
7
8
9
10
11
12
13
14
15
 
...
1
 
2
3
 
 
4
5
6
7
 
 
 
 
 
 
 
 
 
8
0
@@ -1,15 +1,8 @@
0
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
0
-one:
0
+johans_project:
0
   id: 1
0
- name: MyString
0
- description: MyText
0
+ name: johans project
0
+ updated_at: <%= 2.days.ago.to_s(:db) %>
0
+ description: this is johans project yo
0
   user_id: 1
0
- created_at: 2007-08-19 16:56:36
0
- updated_at: 2007-08-19 16:56:36
0
-two:
0
- id: 2
0
- name: MyString
0
- description: MyText
0
- user_id: 1
0
- created_at: 2007-08-19 16:56:36
0
- updated_at: 2007-08-19 16:56:36
0
+ created_at: <%= 5.days.ago.to_s(:db) %>
...
1
 
2
3
4
 
 
5
6
7
8
9
10
 
11
12
13
 
 
14
15
16
...
 
1
2
 
 
3
4
5
6
7
8
9
 
10
11
 
 
12
13
14
15
16
0
@@ -1,16 +1,16 @@
0
-quentin:
0
+johan:
0
   id: 1
0
- login: quentin
0
- email: quentin@example.com
0
+ login: johan
0
+ email: johan@johansorensen.com
0
   salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
0
   crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
0
   created_at: <%= 5.days.ago.to_s :db %>
0
   activation_code: 8f24789ae988411ccf33ab0c30fe9106fab32e9b
0
   activated_at: <%= 5.days.ago.to_s :db %>
0
-aaron:
0
+moe:
0
   id: 2
0
- login: aaron
0
- email: aaron@example.com
0
+ login: moe
0
+ email: moe@example.com
0
   salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
0
   crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
0
   created_at: <%= 1.days.ago.to_s :db %>
...
45
46
47
48
49
 
 
50
51
52
53
54
 
 
55
56
57
58
 
59
60
61
62
63
64
 
 
 
65
66
67
68
69
70
71
 
 
 
 
72
73
74
75
76
 
77
78
79
80
 
 
 
81
82
83
84
85
86
87
88
 
 
 
 
89
90
91
92
93
 
94
95
96
97
 
 
 
98
99
100
...
45
46
47
 
 
48
49
50
51
52
 
 
53
54
55
56
57
 
58
59
60
61
 
 
 
62
63
64
65
66
67
 
 
 
 
68
69
70
71
72
73
74
75
 
76
77
 
 
 
78
79
80
81
82
83
84
 
 
 
 
85
86
87
88
89
90
91
92
 
93
94
 
 
 
95
96
97
98
99
100
0
@@ -45,56 +45,56 @@ describe User do
0
   end
0
   
0
   it "should reset password" do
0
- users(:quentin).update_attributes(:password => "newpass", :password_confirmation => "newpass")
0
- User.authenticate("quentin", "newpass").should == users(:quentin)
0
+ users(:johan).update_attributes(:password => "newpass", :password_confirmation => "newpass")
0
+ User.authenticate("johan", "newpass").should == users(:johan)
0
   end
0
   
0
   it "should not rehash the password" do
0
- users(:quentin).update_attributes(:login => 'quentin2')
0
- User.authenticate("quentin2", "test").should == users(:quentin)
0
+ users(:johan).update_attributes(:login => 'johan2')
0
+ User.authenticate("johan2", "test").should == users(:johan)
0
   end
0
   
0
   it "should authenticate user" do
0
- User.authenticate("quentin", "test").should == users(:quentin)
0
+ User.authenticate("johan", "test").should == users(:johan)
0
   end
0
   
0
   it "should set remember token" do
0
- users(:quentin).remember_me
0
- users(:quentin).remember_token.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.should_not be(nil)
0
+ users(:johan).remember_me
0
+ users(:johan).remember_token.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.should_not be(nil)
0
   end
0
   
0
   it "should unset remember token" do
0
- users(:quentin).remember_me
0
- users(:quentin).remember_token.should_not be(nil)
0
- users(:quentin).forget_me
0
- users(:quentin).remember_token.should be(nil)
0
+ users(:johan).remember_me
0
+ users(:johan).remember_token.should_not be(nil)
0
+ users(:johan).forget_me
0
+ users(:johan).remember_token.should be(nil)
0
   end
0
   
0
   it "should remember user for one week" do
0
     before = 1.week.from_now.utc
0
- users(:quentin).remember_me_for 1.week
0
+ users(:johan).remember_me_for 1.week
0
     after = 1.week.from_now.utc
0
- users(:quentin).remember_token.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.between?(before, after).should be(true)
0
+ users(:johan).remember_token.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.between?(before, after).should be(true)
0
   end
0
   
0
   it "should remember me until one week later" do
0
     time = 1.week.from_now.utc
0
- users(:quentin).remember_me_until time
0
- users(:quentin).remember_token.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.should == time
0
+ users(:johan).remember_me_until time
0
+ users(:johan).remember_token.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.should == time
0
   end
0
   
0
   it "should remember me default two weeks" do
0
     before = 2.weeks.from_now.utc
0
- users(:quentin).remember_me
0
+ users(:johan).remember_me
0
     after = 2.weeks.from_now.utc
0
- users(:quentin).remember_token.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.should_not be(nil)
0
- users(:quentin).remember_token_expires_at.between?(before, after).should be(true)
0
+ users(:johan).remember_token.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.should_not be(nil)
0
+ users(:johan).remember_token_expires_at.between?(before, after).should be(true)
0
   end
0
   
0
   protected
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ Spec::Runner.configure do |config|
0
   # Alternatively, if you prefer to declare them only once, you can
0
   # do so here, like so ...
0
   #
0
- config.global_fixtures = :users
0
+ config.global_fixtures = :users, :projects
0
   #
0
   # If you declare global fixtures, be aware that they will be declared
0
   # for all of your examples, even those that don't use them.

Comments

    No one has commented yet.