Comments (5)
Do you have everything setup on the spec_helper.rb
file?:
config.include Request::JsonHelpers, :type => :controller
config.include Request::HeadersHelpers, :type => :controller
config.include Devise::TestHelpers, :type => :controller
from market_place_api.
Yes I included all of them. Can you take a look at my repository and tell what i'm doing wrong? Here's the link- https://github.com/Mohakjuneja/FatBoy
I'd be really grateful. Thanks!
from market_place_api.
Check out the pull request I made Mohakjuneja/FatBoy#1
from market_place_api.
Hey! Thank you for your support. All the test cases are passing except two.
I have pushed your recommended changes to my repository (link up there) except the change in user.rb because I end up failing more test cases.
I also moved the authenticate_with_token! method back to users controller
Can you take a look at these?
in sessions_controller_specs, on line47, @user = FactoryGirl.create :user has attribute auth_token = nil. How will find the user with a nil auth_token?
- Api::V1::SessionsController DELETE #destroy
Failure/Error: delete :destroy, id: @user.auth_token
ActionController::UrlGenerationError:
No route matches {:action=>"destroy", :controller=>"api/v1/sessions", :id=>nil}./spec/controllers/api/v1/sessions_controller_spec.rb:50:in `block (3 levels) in <top (required)>'
Devise.stub(:friendly_tokenn)and_return("auniquetoken123") returns nil
@user.generate_authentication_token! equals nil
- User#generate_authentication_token! generates a unique token
Failure/Error: expect { @user.generate_authentication_token! }.to change{@user.auth_token}.from(nil).to("auniquetoken123")
result should have been changed to "auniquetoken123", but is now nil./spec/models/user_spec.rb:21:in `block (3 levels) in <top (required)>'
Thank you again!
from market_place_api.
The thing in here is that you need to have a auth_token for each user and in the first case, it seems that it does not have one. A good idea would be to put it on the users.rb
factory file:
FactoryGirl.define do
factory :user do
email { FFaker::Internet.email}
password "12345678"
password_confirmation "12345678"
auth_token { Devise.friendly_token }
end
end
On the second one I think you have to specify the self
to refer to the instance when trying to assign the auth_token, something like:
def generate_authentication_token!
loop do
self.auth_token = Devise.friendly_token
break auth_token unless User.where(auth_token: auth_token).first
end
end
Ruby may not know wheter you are refering to a variable or the attribute, and in this case is to a variable I think.
from market_place_api.
Related Issues (20)
- Body is blank.? --I can not do DELETE/ POST / PUT / interface Sabisu_Rails HOT 3
- Listing: 6.5: Failure/Error: @user.destroy HOT 1
- Chapter 6 should_not be_published HOT 1
- Unable to access api endpoint (via cURL and in browser) HOT 1
- Found an error in the beginning of Chapter 8.1
- Latest updates of this project HOT 4
- Chapter 10 Pagination issue: Meta object in render json: products, meta: is not rendered in ActiveModelSerializer 0.10.2 HOT 1
- json render format; chapter 7 HOT 1
- Filter chain halted as :authenticate_with_token! rendered or redirected Completed 401 Unauthorized HOT 3
- Rspec test failing in Rails 5 HOT 6
- Rails 5.0.1: Sass::SyntaxError in SabisuRails::Explorer#index HOT 5
- Listing 5.12 HOT 3
- How do I do a log out(destroy the session) using cUrl? HOT 5
- 500 error when user not exist HOT 5
- sign_in in sessions controller does not affect tests HOT 4
- Chapter 6.1.3 Dependency Destroy Factory HOT 3
- I have been getting a 404 for the same request which is successful on another POSTMAN. HOT 1
- Chapter 6.2.6: ActionController::UrlGenerationError: No route matches {:action=>"destroy", :controller=>"api/v1/products" ... HOT 1
- Chapter 6 ActionController::UrlGenerationError:
- Chapter 5 Authentication Rails 5.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from market_place_api.