Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe "On a SessionsController, a visitor" do
- tests SessionsController
- it "should see a login form" do
- get :new
- status.should.be :success
- template.should.be 'sessions/new'
- end
- it "should be able to create a new session" do
- post :create, :member => valid_credentials
- assigns(:unauthenticated).should == members(:kelly)
- should.be.authenticated
- should.redirect_to root_url
- end
- it "should be redirected back to the page she originally requested" do
- lambda {
- post :create, :member => valid_credentials
- should.be.authenticated
- }.should.redirect_back_to event_url(events(:supernatural))
- end
- it "should see an explanation if the username or password was wrong" do
- post :create, :member => valid_credentials.merge(:password => 'wrong')
- should.not.be.authenticated
- status.should.be :success
- assert_select 'p[class=errors]'
- end
- private
- def valid_credentials
- { :username => members(:kelly).username, :password => 'secret' }
- end
- end
- describe "On a SessionsController, a member" do
- tests SessionsController
- before do
- login members(:adrian)
- end
- it "should be able to clear the logged in session" do
- get :clear
- should.not.be.authenticated
- should.redirect_to root_url
- end
- end
Add Comment
Please, Sign In to add comment