Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. ## raise errors 2
  2. 1) User authenticates user
  3. Failure/Error: User.authenticate('jdoe@example.com', 'secret').should == user
  4. RuntimeError:
  5. $2a$10$HibLgI46WOViVu1cV2LoFuo.ddUdzuElQ6aS/PwtyiLv1Q7MWUWp.
  6. $2a$10$HibLgI46WOViVu1cV2LoFuuu0xrDbBP3C295p8Qsw6FGkQ.tF1yN.
  7. # ./app/models/user.rb:147:in `authenticate'
  8. # ./spec/models/user_spec.rb:27
  9.  
  10. 2) Posts creates post
  11. Failure/Error: login user
  12. RuntimeError:
  13. $2a$10$Z56C5vOxA0C00RzGn1La0eMoPvjv019T5wTWVh9zyLjaWwhyQ6WuK
  14. $2a$10$Z56C5vOxA0C00RzGn1La0eJbmhSOWgR/pCU5PHcYMkdGZLcXBVN1u
  15. # ./app/models/user.rb:147:in `authenticate'
  16. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  17. # (eval):2:in `send'
  18. # (eval):2:in `click_button'
  19. # ./spec/support/auth_macros.rb:7:in `login'
  20. # ./spec/requests/posts_spec.rb:6
  21.  
  22. 3) Sessions notifies if login info is blank
  23. Failure/Error: click_button "Login"
  24. NoMethodError:
  25. undefined method `password_hash' for nil:NilClass
  26. # ./app/models/user.rb:147:in `authenticate'
  27. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  28. # (eval):2:in `send'
  29. # (eval):2:in `click_button'
  30. # ./spec/requests/sessions_spec.rb:8
  31.  
  32. 4) Sessions notifies if password is blank
  33. Failure/Error: click_button "Login"
  34. NoMethodError:
  35. undefined method `password_hash' for nil:NilClass
  36. # ./app/models/user.rb:147:in `authenticate'
  37. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  38. # (eval):2:in `send'
  39. # (eval):2:in `click_button'
  40. # ./spec/requests/sessions_spec.rb:15
  41.  
  42. 5) Sessions notifies if email is blank
  43. Failure/Error: click_button "Login"
  44. NoMethodError:
  45. undefined method `password_hash' for nil:NilClass
  46. # ./app/models/user.rb:147:in `authenticate'
  47. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  48. # (eval):2:in `send'
  49. # (eval):2:in `click_button'
  50. # ./spec/requests/sessions_spec.rb:22
  51.  
  52. 6) Sessions logs user in if info is correct
  53. Failure/Error: click_button "Login"
  54. RuntimeError:
  55. $2a$10$M.19NL90F3grDjLDVI6zauz5yvrAOjaHMTTC3GYyhCINcNFCMhQeO
  56. $2a$10$M.19NL90F3grDjLDVI6zau.zMHmswqQbtY295fsy6YmsXZ57kba8C
  57. # ./app/models/user.rb:147:in `authenticate'
  58. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  59. # (eval):2:in `send'
  60. # (eval):2:in `click_button'
  61. # ./spec/requests/sessions_spec.rb:31
  62.  
  63.  
  64. ## raise errors
  65. 3) Sessions notifies if login info is blank
  66. Failure/Error: click_button "Login"
  67. RuntimeError:
  68. ---
  69. # ./app/models/user.rb:147:in `authenticate'
  70. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  71. # (eval):2:in `send'
  72. # (eval):2:in `click_button'
  73. # ./spec/requests/sessions_spec.rb:8
  74.  
  75. 4) Sessions notifies if password is blank
  76. Failure/Error: click_button "Login"
  77. RuntimeError:
  78. ---
  79. # ./app/models/user.rb:147:in `authenticate'
  80. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  81. # (eval):2:in `send'
  82. # (eval):2:in `click_button'
  83. # ./spec/requests/sessions_spec.rb:15
  84.  
  85. 5) Sessions notifies if email is blank
  86. Failure/Error: click_button "Login"
  87. RuntimeError:
  88. ---
  89. # ./app/models/user.rb:147:in `authenticate'
  90. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  91. # (eval):2:in `send'
  92. # (eval):2:in `click_button'
  93. # ./spec/requests/sessions_spec.rb:22
  94.  
  95. 6) Sessions logs user in if info is correct
  96. Failure/Error: click_button "Login"
  97. RuntimeError:
  98. --- !ruby/object:User
  99. attributes:
  100. name: John Doe
  101. encrypted_password:
  102. avatar_file_name:
  103. avatar_file_size:
  104. created_at: 2011-08-01 06:22:27 Z
  105. updated_at: 2011-08-01 06:22:27 Z
  106. dj_name: John Doe
  107. role: noob
  108. signature:
  109. password_reset_requested_at:
  110. id: 127
  111. password_reset_token:
  112. about:
  113. phone_number:
  114. avatar_content_type:
  115. password_salt: $2a$10$gve33jeJSYoL9lmThECnze
  116. aim_screenname:
  117. soft_deleted: 0
  118. login:
  119. additional_contact_info:
  120. avatar_updated_at:
  121. password_hash: $2a$10$gve33jeJSYoL9lmThECnzeVyhPGeB0tOb/bCuvxhHQR.6Z63gCme.
  122. email: jdoe@example.com
  123. active: 0
  124. attributes_cache: {}
  125.  
  126. changed_attributes: {}
  127.  
  128. destroyed: false
  129. marked_for_destruction: false
  130. new_record: false
  131. previously_changed: {}
  132.  
  133. readonly: false
  134. # ./app/models/user.rb:147:in `authenticate'
  135. # ./app/controllers/cp/sessions_controller.rb:9:in `create'
  136. # (eval):2:in `send'
  137. # (eval):2:in `click_button'
  138. # ./spec/requests/sessions_spec.rb:31
  139.  
  140.  
  141. ## sessions_controller.rb
  142. def create
  143. user = User.authenticate(params[:email], params[:password])
  144. if user
  145. session[:user_id] = user.id
  146. if session[:return_to]
  147. redirect_to session[:return_to]
  148. session[:return_to] = nil
  149. else
  150. redirect_to cp_root_path
  151. end
  152. else
  153. flash.now.alert = "Wrong Login Information. Try again."
  154. render 'new'
  155. end
  156. end
  157.  
  158. ## user.rb
  159. def self.authenticate(email, password)
  160. user = find_by_email(email)
  161. if user && user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
  162. user
  163. else
  164. nil #just incase
  165. end
  166. end
  167.  
  168. def encrypt_password
  169. if password.present?
  170. self.password_salt = BCrypt::Engine.generate_salt
  171. self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
  172. end
  173. end
  174.  
  175. ## user_spec.rb
  176. require 'spec_helper'
  177.  
  178. describe "Sessions" do
  179. let!(:user) { Factory(:user) }
  180.  
  181. it "logs user in if info is correct" do
  182. visit cp_login_path
  183. fill_in "email", :with => "jdoe@example.com"
  184. fill_in "password", :with => "secret"
  185. click_button "Login"
  186. page.should have_content("Hello, John Doe!")
  187. end
  188. end
  189.  
  190. ## factories.rb
  191. Factory.define(:user) do |f|
  192. f.name "John Doe"
  193. f.email "jdoe@example.com"
  194. f.password "secret"
  195. end
  196.  
  197. ## error
  198.  
  199. 3) Sessions logs user in if info is correct
  200. Failure/Error: page.should have_content("Hello, John Doe!")
  201. 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 "
  202. # ./spec/requests/sessions_spec.rb:31
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement