Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FFFFFFFFFFFFF
- Failures:
- 1) Api::V1::UsersController GET #show returns the information about a reporter on a hash
- Failure/Error: get :show, params: { id: @user.id }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # ActionController::MissingRenderer:
- # No renderer defined for format: application/vnd.souq.v1
- # ./app/controllers/api/v1/users_controller.rb:20:in `show'
- # ./app/controllers/api/v1/products_controller.rb:10:in `show'
- 2) Api::V1::UsersController GET #show
- Failure/Error: get :show, params: { id: @user.id }ecords from the database
- Failure/Error: get :index
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # ActionController::MissingRenderer:
- # No renderer defined for format: application/vnd.souq.v1
- # ./app/controllers/api/v1/users_controller.rb:20:in `show'
- 3) Api::V1::UsersController POST #create when is successfully created renders the json representation for the user record just created
- Failure/Error: post :create, params: { user: @user_attributes }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:24:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `content_type' for nil:NilClass
- # ./app/controllers/api/v1/users_controller.rb:9:in `create'
- 4) Api::V1::UsersController POST #create when is successfully created
- Failure/Error: post :create, params: { user: @user_attributes }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:24:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `content_type' for nil:NilClass
- # ./app/controllers/api/v1/users_controller.rb:9:in `create'
- 5) Api::V1::UsersController POST #create when is not created renders an errors json
- Failure/Error: post :create, params: { user: @invalid_user_attributes }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `content_type' for nil:NilClass
- # ./app/controllers/api/v1/users_controller.rb:11:in `create'
- 6) Api::V1::UsersController POST #create when is not created renders the json errors on whye the user could not be created
- Failure/Error: post :create, params: { user: @invalid_user_attributes }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `content_type' for nil:NilClass
- # ./app/controllers/api/v1/users_controller.rb:11:in `create'
- 7) Api::V1::UsersController POST #create when is not created
- Failure/Error: post :create, params: { user: @invalid_user_attributes }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:41:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `content_type' for nil:NilClass
- # ./app/controllers/api/v1/users_controller.rb:11:in `create'
- 8) Api::V1::UsersController PUT/PATCH #update when is successfully updated renders the json representation for the updated user
- Failure/Error: patch :update, params: { id: @user.id, user: { email: "newmail@example.com" } }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `committed?' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
- 9) Api::V1::UsersController PUT/PATCH #update when is successfully updated
- Failure/Error: patch :update, params: { id: @user.id, user: { email: "newmail@example.com" } }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `committed?' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:66:in `block (4 levels) in <top (required)>'
- 10) Api::V1::UsersController PUT/PATCH #update when is not updated renders an errors json
- Failure/Error: patch :update, params: { id: @user.id, user: { email: "bademail.com" } }
- NoMethodError:
- undefined method `prepare!' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:79:in `block (4 levels) in <top (required)>'
- # ------------------
- # --- Caused by: ---
- # NoMethodError:
- # undefined method `committed?' for nil:NilClass
- # ./spec/controllers/api/v1/users_controller_spec.rb:79:in `block (4 levels) in <top (required)>'
- 11) Api::V1::UsersController PUT/PATCH #update when is not updated renders the json errors on whye the user could not be created
- Failure/Error: patch :update, params: { id: @user.id, user: { email: "bademail.com" } }
- # controls the user actions and authentication
- class Api::V1::UsersController < ApplicationController
- before_action :authenticate_with_token!, only: [:update, :destroy]
- respond_to :json
- def create
- user = User.new(user_params)
- if user.save
- render json: user, status: 201, location: [:api, user]
- else
- render json: { errors: user.errors }, status: 422
- end
- end
- def index
- respond_with User.all
- end
- def show
- respond_with User.find(params[:id])
- # @user = User.find(params[:id])
- # render json: @user, status: :ok
- end
- def update
- user = User.find(params[:id])
- if user.update(user_params)
- render json: user, status: 200, location: [:api, user]
- else
- render json: { errors: user.errors }, status: 422
- end
- end
- def destroy
- current_user.destroy
- head 204
- end
- private
- def user_params
- params.require(:user).permit(:email, :password, :password_confirmation)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement