Commit 767f7d171de42b84621a375f9249a1c9b832ce0a
- Date: Tue Jan 15 08:57:07 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: 767f7d171de42b84621a375f9249a1c9b832ce0a
- Tree SHA1: c131efda8fe3e5f9f0ae102ed5d65594905b9f4c
- spec/controllers/users_controller_spec.rb 15 +++++++++++++++
- config/routes.rb 3 --+
- app/controllers/users_controller.rb 2 ++
Commit diff
- Diff rendering mode:
- inline
- side by side
app/controllers/users_controller.rb
|   | ||
| 27 | 27 | current_user.activate |
| 28 | 28 | flash[:notice] = "Your account has been activated, welcome!" |
| 29 | 29 | end |
| 30 | else | |
| 31 | flash[:error] = "Invalid activation code" | |
| 30 | 32 | end |
| 31 | 33 | redirect_back_or_default('/') |
| 32 | 34 | end |
| toggle raw diff | ||
config/routes.rb
|   | ||
| 23 | 23 | map.resource :account, :member => {:password => :get, :update_password => :put} do |account| |
| 24 | 24 | account.resources :keys |
| 25 | 25 | end |
| 26 | map.connect "users/activate/:activation_code", :controller => "users", :action => "activate" | |
| 26 | 27 | map.resources :users, :requirements => {:id => /.+/} |
| 27 | 28 | map.resource :sessions |
| 28 | 29 | map.with_options(:controller => "projects", :action => "category") do |project_cat| |
| … | … | |
| 63 | 63 | session.logout '/logout', :action => 'destroy' |
| 64 | 64 | end |
| 65 | 65 | |
| 66 | ||
| 67 | ||
| 68 | 66 | map.about "about", :controller => "site", :action => "about" |
| 69 | 67 | |
| 70 | 68 | # Install the default route as the lowest priority. |
| toggle raw diff | ||
spec/controllers/users_controller_spec.rb
|   | ||
| 66 | 66 | User.authenticate('moe@example.com', 'test').should == users(:moe) |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | it "flashes a message when the activation code is invalid" do | |
| 70 | get :activate, :activation_code => "fubar" | |
| 71 | response.should redirect_to('/') | |
| 72 | flash[:notice].should be(nil) | |
| 73 | flash[:error].should == "Invalid activation code" | |
| 74 | User.authenticate('moe@example.com', 'test').should == nil | |
| 75 | end | |
| 76 | ||
| 69 | 77 | it "shows the user" do |
| 70 | 78 | get :show, :id => users(:johan).login |
| 71 | 79 | response.should be_success |
| … | … | |
| 83 | 83 | it "recognizes routing with dots in it" do |
| 84 | 84 | params_from(:get, "/users/j.s")[:id].should == "j.s" |
| 85 | 85 | end |
| 86 | ||
| 87 | it "recognizes activate routes" do | |
| 88 | p = params_from(:get, "/users/activate/abc123") | |
| 89 | p[:controller].should == "users" | |
| 90 | p[:action].should == "activate" | |
| 91 | p[:activation_code].should == "abc123" | |
| 92 | end | |
| 86 | 93 | |
| 87 | 94 | end |
| toggle raw diff | ||
