Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- context "POST create" do
- context "with just an email" do
- setup do
- post :create, :user_session => {:email => "josh.m.shgsdarpe@gmail.com"}
- end
- should_render_template :new
- should "have one error" do
- assert_select "div [class=errorExplanation]" do
- assert_select "li", {:count => 1, :text => "Password cannot be blank"}
- end
- end
- should_wrap_labels_correctly(["Password"], ["Email"])
- should "not define current_user" do
- assert_nil @response.session[:user_credentials_id]
- end
- end
- context "with just a password" do
- setup do
- post :create, :user_session => {:password => "asdf"}
- end
- should_render_template :new
- should "have one error" do
- assert_select "div [class=errorExplanation]" do
- assert_select "li", {:count => 1, :text => "Email cannot be blank"}
- end
- end
- should_wrap_labels_correctly(["Email"], ["Password"])
- should "not define current_user" do
- assert_nil @response.session[:user_credentials_id]
- end
- end
- context "with invalid credentials" do
- setup do
- post :create, :user_session => {:email => "josh.m.sharpe@gmail.com", :password => "asdf"}
- end
- should_render_template :new
- should "have one error" do
- assert_select "div [class=errorExplanation]" do
- assert_select "li", {:count => 1, :text => "Your email or password is incorrect. Please try again."}
- end
- end
- should_wrap_labels_correctly([], ["Password", "Email"])
- should "not define current_user" do
- assert_nil @response.session[:user_credentials_id]
- end
- end
- context "with an unconfirmed user" do
- setup do
- @user = users(:josh)
- assert @user.update_attribute(:confirmed_at, nil)
- post :create, :user_session => {:email => @user.email, :password => "asdf1234"}
- end
- should_render_template :new
- should "not define current_user" do
- assert_nil @response.session[:user_credentials_id]
- end
- should "have one error" do
- assert_select "div [class=errorExplanation]" do
- assert_select "li", {:count => 1}
- end
- end
- should_wrap_labels_correctly([], ["Password", "Email"])
- should "have the unconfirmed error" do
- # assert @response.body.include?("This account has not been confirmed.<br />Click <a href=\"/users/#{users(:josh).id}/send_repeat_confirmation_email\">here</a> to send another confirmation email.")
- end
- should "have the correct width for the error box" do
- assert_match (/<div class='errorWrapper' style='width:232px;'>/), @response.body
- end
- end
- context "with valid credentials" do
- setup do
- post :create, :user_session => {:email => "josh.m.sharpe@gmail.com", :password => "asdf1234"}
- end
- should "redirect_to root_path" do
- assert_redirected_to root_path
- end
- should "define current_user" do
- assert_equal users(:josh).id, @response.session[:user_credentials_id]
- end
- end
- end
Add Comment
Please, Sign In to add comment