Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## raise errors 2
- 1) User authenticates user
- Failure/Error: User.authenticate('jdoe@example.com', 'secret').should == user
- RuntimeError:
- $2a$10$HibLgI46WOViVu1cV2LoFuo.ddUdzuElQ6aS/PwtyiLv1Q7MWUWp.
- $2a$10$HibLgI46WOViVu1cV2LoFuuu0xrDbBP3C295p8Qsw6FGkQ.tF1yN.
- # ./app/models/user.rb:147:in `authenticate'
- # ./spec/models/user_spec.rb:27
- 2) Posts creates post
- Failure/Error: login user
- RuntimeError:
- $2a$10$Z56C5vOxA0C00RzGn1La0eMoPvjv019T5wTWVh9zyLjaWwhyQ6WuK
- $2a$10$Z56C5vOxA0C00RzGn1La0eJbmhSOWgR/pCU5PHcYMkdGZLcXBVN1u
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/support/auth_macros.rb:7:in `login'
- # ./spec/requests/posts_spec.rb:6
- 3) Sessions notifies if login info is blank
- Failure/Error: click_button "Login"
- NoMethodError:
- undefined method `password_hash' for nil:NilClass
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:8
- 4) Sessions notifies if password is blank
- Failure/Error: click_button "Login"
- NoMethodError:
- undefined method `password_hash' for nil:NilClass
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:15
- 5) Sessions notifies if email is blank
- Failure/Error: click_button "Login"
- NoMethodError:
- undefined method `password_hash' for nil:NilClass
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:22
- 6) Sessions logs user in if info is correct
- Failure/Error: click_button "Login"
- RuntimeError:
- $2a$10$M.19NL90F3grDjLDVI6zauz5yvrAOjaHMTTC3GYyhCINcNFCMhQeO
- $2a$10$M.19NL90F3grDjLDVI6zau.zMHmswqQbtY295fsy6YmsXZ57kba8C
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:31
- ## raise errors
- 3) Sessions notifies if login info is blank
- Failure/Error: click_button "Login"
- RuntimeError:
- ---
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:8
- 4) Sessions notifies if password is blank
- Failure/Error: click_button "Login"
- RuntimeError:
- ---
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:15
- 5) Sessions notifies if email is blank
- Failure/Error: click_button "Login"
- RuntimeError:
- ---
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:22
- 6) Sessions logs user in if info is correct
- Failure/Error: click_button "Login"
- RuntimeError:
- --- !ruby/object:User
- attributes:
- name: John Doe
- encrypted_password:
- avatar_file_name:
- avatar_file_size:
- created_at: 2011-08-01 06:22:27 Z
- updated_at: 2011-08-01 06:22:27 Z
- dj_name: John Doe
- role: noob
- signature:
- password_reset_requested_at:
- id: 127
- password_reset_token:
- about:
- phone_number:
- avatar_content_type:
- password_salt: $2a$10$gve33jeJSYoL9lmThECnze
- aim_screenname:
- soft_deleted: 0
- login:
- additional_contact_info:
- avatar_updated_at:
- password_hash: $2a$10$gve33jeJSYoL9lmThECnzeVyhPGeB0tOb/bCuvxhHQR.6Z63gCme.
- email: jdoe@example.com
- active: 0
- attributes_cache: {}
- changed_attributes: {}
- destroyed: false
- marked_for_destruction: false
- new_record: false
- previously_changed: {}
- readonly: false
- # ./app/models/user.rb:147:in `authenticate'
- # ./app/controllers/cp/sessions_controller.rb:9:in `create'
- # (eval):2:in `send'
- # (eval):2:in `click_button'
- # ./spec/requests/sessions_spec.rb:31
- ## sessions_controller.rb
- def create
- user = User.authenticate(params[:email], params[:password])
- if user
- session[:user_id] = user.id
- if session[:return_to]
- redirect_to session[:return_to]
- session[:return_to] = nil
- else
- redirect_to cp_root_path
- end
- else
- flash.now.alert = "Wrong Login Information. Try again."
- render 'new'
- end
- end
- ## user.rb
- def self.authenticate(email, password)
- user = find_by_email(email)
- if user && user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
- user
- else
- nil #just incase
- end
- end
- def encrypt_password
- if password.present?
- self.password_salt = BCrypt::Engine.generate_salt
- self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
- end
- end
- ## user_spec.rb
- require 'spec_helper'
- describe "Sessions" do
- let!(:user) { Factory(:user) }
- it "logs user in if info is correct" do
- visit cp_login_path
- fill_in "email", :with => "jdoe@example.com"
- fill_in "password", :with => "secret"
- click_button "Login"
- page.should have_content("Hello, John Doe!")
- end
- end
- ## factories.rb
- Factory.define(:user) do |f|
- f.name "John Doe"
- f.email "jdoe@example.com"
- f.password "secret"
- end
- ## error
- 3) Sessions logs user in if info is correct
- Failure/Error: page.should have_content("Hello, John Doe!")
- expected there to be content "Hello, John Doe!" in "Birn CP\n \n Control Panel\n \t \n\t\n \n Wrong Login Information. Try again.\n\n \n\t\n\t\tPlease Login\n\t\t\t\n\t\t\t\tE-mail\n\t\t\t\t\n\t\n\t\t\t \n\t\t\t\tPassword\n\t\t\t\t\n\t\t\tForgot Password?\n\t\t\n\t\n\t\tHaving trouble logging in?Contact the webteam: webteam [at] thebirn.com\n\t\n\n \n \n \n \n \n Tyro Created by The BIRN © 2011\n \n "
- # ./spec/requests/sessions_spec.rb:31
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement