40 lines
877 B
Ruby
40 lines
877 B
Ruby
require 'spec_helper'
|
|
|
|
describe SessionsController, type: :controller do
|
|
render_views
|
|
|
|
let(:user) { FactoryGirl.create(:user) }
|
|
|
|
describe "GET 'new'" do
|
|
it "should work" do
|
|
get :signin
|
|
response.should be_success
|
|
end
|
|
|
|
it "should have the right title" do
|
|
get :signin
|
|
response.body.should have_title("JamKazam | Sign in")
|
|
end
|
|
end
|
|
|
|
|
|
describe "POST 'create'" do
|
|
before(:each) do
|
|
@user = FactoryGirl.create(:user)
|
|
@attr = { :email => @user.email, :password => @user.password }
|
|
end
|
|
|
|
it "should sign the user in" do
|
|
post :create, :session => @attr
|
|
controller.current_user.should == @user
|
|
controller.signed_in?.should == true
|
|
end
|
|
|
|
it "should redirect the user to the proper page" do
|
|
post :create, :session => @attr
|
|
response.should redirect_to(client_url)
|
|
end
|
|
end
|
|
|
|
end
|