ruby-grape / grape-entity

An API focused facade that sits on top of an object model.
MIT License
721 stars 154 forks source link

Problems after update #131

Open reiz opened 9 years ago

reiz commented 9 years ago

One of my projects is running stable with grape-entity 0.3.0. But as soon I update to 0.4.0 or higher some of my tests fail. The odd thing is that they fail randomly and it seems that the connection to MongoDB randomly fails. I'm getting errors like this:


Problem:
   Document(s) not found for class Project with id(s) 555b4d484fe53d4ad2000310.
 Summary:
   When calling Project.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 555b4d484fe53d4ad2000310 ... (1 total) and the following ids were not found: 555b4d484fe53d4ad2000310.
 Resolution:
   Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.

If I downgrade to 0.3.0 all tests are green again.

Any idea what could be the reason?

dblock commented 9 years ago

That is very strange indeed. If you can put the project up I can help you debug.

One idea, check other dependencies, did you update something else under the hood by bundle update.

idyll commented 9 years ago

I kinda remember having an issue like this...

I think that is do to a change with behaviours around exposing models that may not have the method being exposed.

Previously this would work as long as it wasn't called, now it throws an exception.

reiz commented 9 years ago

Thanks for the input. I will give it a try again on the weekend.

epaulet commented 9 years ago

I'm also having issues updating from 0.4.5 to 0.4.8. Before if a model did not have a method, it would that was exposed in an entity, it wouldn't raise any exceptions. Now there is a NoMethodError.

epaulet commented 9 years ago

Seems to be that passing in safe: true doesn't seem to work in conjunction with format_with

marshall-lee commented 9 years ago

@epaulet please open a PR with a failing test or post an example here at least.

epaulet commented 9 years ago

@marshall-lee I added a PR with a failing spec for this issue I was referring to. Not sure if it's related to the topic of this thread or not.