Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking a singularized endpoint #241

Closed
edprats opened this issue Sep 6, 2016 · 3 comments
Closed

Mocking a singularized endpoint #241

edprats opened this issue Sep 6, 2016 · 3 comments

Comments

@edprats
Copy link

edprats commented Sep 6, 2016

in my application i have a 'user' model, and sometimes i want to findRecord('user', 'me'), which in my user adapter translates to the endpoint GET /user (singular, for retrieving the authenticated user from my API)

how could i use an http GET mock (mockFind?) to use that in development (hit up singular 'user' as opposed to 'users')?

@danielspaniel
Copy link
Collaborator

danielspaniel commented Sep 6, 2016

To deal with this ( till I change to pull in urlForFindRecord ) and you ( actually use urlForFindRecord ) on the adapter you can:

  1. build a user payload and use mockjax directly
let user = build('user');
$.mockjax({url: `/user/me`, responseText: user); 

or
2. use factory guy cache only mode and make a user

FactoryGuy.cacheOnlyMode();
let user = make('user');

cacheOnlyMode works by saying .. hey .. don't bother to look for a findRecord model or findAll if you have something in the store already.

@edprats
Copy link
Author

edprats commented Sep 6, 2016

thank you, that worked perfectly

@edprats edprats closed this as completed Sep 6, 2016
@danielspaniel
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants