File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 # keep track of that by just setting a session variable with their id. If it
2020 # doesn't exist, we just want to return nil.
2121 def current_user
22- return Hacker . first ( :id => session [ :hacker_id ] ) if session [ :hacker_id ]
23- nil
22+ return nil unless session [ :hacker_id ]
23+
24+ # Memoize to make sure code like this works properly:
25+ # current_user.password = 'foo'
26+ # current_user.save
27+ @current_user ||= Hacker . first ( :id => session [ :hacker_id ] ) if session [ :hacker_id ]
2428 end
2529
2630 # This very simple method checks if we've got a logged in user. That's pretty
Original file line number Diff line number Diff line change 9292 page . should have_content "Following: 0"
9393 end
9494
95+ scenario "can change password" do
96+ @andy = Factory ( :hacker , :username => "alindeman" )
97+ log_in @andy
98+
99+ visit "/hackers/alindeman"
100+ fill_in "password[new]" , :with => "abc123"
101+ fill_in "password[confirm]" , :with => "abc123"
102+ click_button "Change password"
103+
104+ page . should have_content "Password updated!"
105+
106+ # Verify password was changed in the underlying datastore
107+ Hacker . authenticate ( "alindeman" , "abc123" ) . should be
108+ end
109+
95110end
You can’t perform that action at this time.
0 commit comments