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

Determining which adapter is being used no workie #127

Closed
FilmKnurd opened this issue Sep 1, 2015 · 4 comments
Closed

Determining which adapter is being used no workie #127

FilmKnurd opened this issue Sep 1, 2015 · 4 comments

Comments

@FilmKnurd
Copy link

I just upgraded to the latest (2.0.0 from 1.13.2 ) and suddenly tests started failing. The test helper handleUpdate() no longer mocked the API requests made by the adapter. It was mocking PATCH for a JSONAPIAdpater, but I'm using the RESTAdapter which uses PUT.

I did a little digging, and I think maybe usingAdapterType() in fixture-builder-factory is not working. I put a breakpoint on line 18 adapter.toString() does not contain the type, so this function returns null and things just get weird from there. Consequently, all calls to useJSONAPI() were true, even though in my case it should have been false.

I don't know if this is the best way, but one possible solution is to detect the instance.

var usingJSONAPIAdapter = function () {
    return adapter instanceof DS.JSONAPIAdapter; //usingAdapterType('json-api');
 };

 var usingRESTAdapter = function () {
    return adapter instanceof DS.RESTAdapter; //usingAdapterType('rest');
 };
@danielspaniel
Copy link
Collaborator

yes .. that figures I blew that one @FilmKnurd .. I was trying like crazy to avoid having to do

return adapter instanceof ActiveModelAdapter

for the using ActiveModelAdapter function

, and in the meantime did not realize your idea is really great for the other two. For ActiveModelAdapter .. that one I am going to have trouble with because people don't all have that package included .. so I can't import it and assume they will have it
which is why I tried to the .toString whoo haaa .. but I will revert to your idea tomorrow and put out new version .. with a bunch of other internal changes that are now underway ...

@danielspaniel
Copy link
Collaborator

actually @FilmKnurd , that plan is not going to work .. since

adapter instanceof DS.RESTAdapter is true for ActiveModelAdapter since its a subclass of DS.RESTAdapter

got any other ideas? this has been a thorn in my side for a long time .. could use a good idea.

@danielspaniel
Copy link
Collaborator

ok @FilmKnurd .. try v2.0.1 .. I think I found a solution that works.

@FilmKnurd
Copy link
Author

2.0.1 works great. Thanks! That sure is a pain having to detect the ActiveModelAdapter.

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