Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. FFFFFFFFFFFFF
  2. Failures:
  3. 1) Api::V1::UsersController GET #show returns the information about a reporter on a hash
  4. Failure/Error: get :show, params: { id: @user.id }
  5.  
  6. NoMethodError:
  7. undefined method `prepare!' for nil:NilClass
  8. # ./spec/controllers/api/v1/users_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
  9. # ------------------
  10. # --- Caused by: ---
  11. # ActionController::MissingRenderer:
  12. # No renderer defined for format: application/vnd.souq.v1
  13. # ./app/controllers/api/v1/users_controller.rb:20:in `show'
  14. # ./app/controllers/api/v1/products_controller.rb:10:in `show'
  15. 2) Api::V1::UsersController GET #show
  16. Failure/Error: get :show, params: { id: @user.id }ecords from the database
  17. Failure/Error: get :index
  18. NoMethodError:
  19. undefined method `prepare!' for nil:NilClass
  20. # ./spec/controllers/api/v1/users_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
  21. # ------------------
  22. # --- Caused by: ---
  23. # ActionController::MissingRenderer:
  24. # No renderer defined for format: application/vnd.souq.v1
  25. # ./app/controllers/api/v1/users_controller.rb:20:in `show'
  26.  
  27. 3) Api::V1::UsersController POST #create when is successfully created renders the json representation for the user record just created
  28. Failure/Error: post :create, params: { user: @user_attributes }
  29.  
  30. NoMethodError:
  31. undefined method `prepare!' for nil:NilClass
  32. # ./spec/controllers/api/v1/users_controller_spec.rb:24:in `block (4 levels) in <top (required)>'
  33. # ------------------
  34. # --- Caused by: ---
  35. # NoMethodError:
  36. # undefined method `content_type' for nil:NilClass
  37. # ./app/controllers/api/v1/users_controller.rb:9:in `create'
  38.  
  39. 4) Api::V1::UsersController POST #create when is successfully created
  40. Failure/Error: post :create, params: { user: @user_attributes }
  41.  
  42. NoMethodError:
  43. undefined method `prepare!' for nil:NilClass
  44. # ./spec/controllers/api/v1/users_controller_spec.rb:24:in `block (4 levels) in <top (required)>'
  45. # ------------------
  46. # --- Caused by: ---
  47. # NoMethodError:
  48. # undefined method `content_type' for nil:NilClass
  49. # ./app/controllers/api/v1/users_controller.rb:9:in `create'
  50.  
  51. 5) Api::V1::UsersController POST #create when is not created renders an errors json
  52. Failure/Error: post :create, params: { user: @invalid_user_attributes }
  53.  
  54. NoMethodError:
  55. undefined method `prepare!' for nil:NilClass
  56. # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
  57. # ------------------
  58. # --- Caused by: ---
  59. # NoMethodError:
  60. # undefined method `content_type' for nil:NilClass
  61. # ./app/controllers/api/v1/users_controller.rb:11:in `create'
  62.  
  63. 6) Api::V1::UsersController POST #create when is not created renders the json errors on whye the user could not be created
  64. Failure/Error: post :create, params: { user: @invalid_user_attributes }
  65.  
  66. NoMethodError:
  67. undefined method `prepare!' for nil:NilClass
  68. # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
  69. # ------------------
  70. # --- Caused by: ---
  71. # NoMethodError:
  72. # undefined method `content_type' for nil:NilClass
  73. # ./app/controllers/api/v1/users_controller.rb:11:in `create'
  74.  
  75. 7) Api::V1::UsersController POST #create when is not created
  76. Failure/Error: post :create, params: { user: @invalid_user_attributes }
  77.  
  78. NoMethodError:
  79. undefined method `prepare!' for nil:NilClass
  80. # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
  81. # ------------------
  82. # --- Caused by: ---
  83. # NoMethodError:
  84. # undefined method `content_type' for nil:NilClass
  85. # ./app/controllers/api/v1/users_controller.rb:11:in `create'
  86.  
  87. 8) Api::V1::UsersController PUT/PATCH #update when is successfully updated renders the json representation for the updated user
  88. Failure/Error: patch :update, params: { id: @user.id, user: { email: "newmail@example.com" } }
  89.  
  90. NoMethodError:
  91. undefined method `prepare!' for nil:NilClass
  92. # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
  93. # ------------------
  94. # --- Caused by: ---
  95. # NoMethodError:
  96. # undefined method `committed?' for nil:NilClass
  97. # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
  98.  
  99. 9) Api::V1::UsersController PUT/PATCH #update when is successfully updated
  100. Failure/Error: patch :update, params: { id: @user.id, user: { email: "newmail@example.com" } }
  101.  
  102. NoMethodError:
  103. undefined method `prepare!' for nil:NilClass
  104. # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
  105. # ------------------
  106. # --- Caused by: ---
  107. # NoMethodError:
  108. # undefined method `committed?' for nil:NilClass
  109. # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
  110.  
  111. 10) Api::V1::UsersController PUT/PATCH #update when is not updated renders an errors json
  112. Failure/Error: patch :update, params: { id: @user.id, user: { email: "bademail.com" } }
  113.  
  114. NoMethodError:
  115. undefined method `prepare!' for nil:NilClass
  116. # ./spec/controllers/api/v1/users_controller_spec.rb:79:in `block (4 levels) in <top (required)>'
  117. # ------------------
  118. # --- Caused by: ---
  119. # NoMethodError:
  120. # undefined method `committed?' for nil:NilClass
  121. # ./spec/controllers/api/v1/users_controller_spec.rb:79:in `block (4 levels) in <top (required)>'
  122.  
  123. 11) Api::V1::UsersController PUT/PATCH #update when is not updated renders the json errors on whye the user could not be created
  124. Failure/Error: patch :update, params: { id: @user.id, user: { email: "bademail.com" } }
  125.  
  126. # controls the user actions and authentication
  127. class Api::V1::UsersController < ApplicationController
  128. before_action :authenticate_with_token!, only: [:update, :destroy]
  129. respond_to :json
  130.  
  131. def create
  132. user = User.new(user_params)
  133. if user.save
  134. render json: user, status: 201, location: [:api, user]
  135. else
  136. render json: { errors: user.errors }, status: 422
  137. end
  138. end
  139.  
  140. def index
  141. respond_with User.all
  142. end
  143.  
  144. def show
  145. respond_with User.find(params[:id])
  146. # @user = User.find(params[:id])
  147. # render json: @user, status: :ok
  148. end
  149.  
  150.  
  151. def update
  152. user = User.find(params[:id])
  153.  
  154. if user.update(user_params)
  155. render json: user, status: 200, location: [:api, user]
  156. else
  157. render json: { errors: user.errors }, status: 422
  158. end
  159. end
  160.  
  161. def destroy
  162. current_user.destroy
  163. head 204
  164. end
  165.  
  166. private
  167.  
  168. def user_params
  169. params.require(:user).permit(:email, :password, :password_confirmation)
  170. end
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement