Search code examples
ruby-on-railsrubyrspecactivemodelactive-model-serializers

Unrelated rspec tests fail after adding active_model_serializers


I'm super confused. I think I'm encountering some kind of bug. Could use some help. I had passing specs (passed dozens of times on local and CI server), and these were completely unrelated to serializers. Like they _just check the status of certain controller methods. But then I literally ONLY added the active_model_serializers, a UserSerializer class, and now my specs are failing. It's saying the response from my controllers is :unauthorized which isn't even possible, b/c I'm calling render status: :created.

The entire app is OSS. This is literally all that has changed: https://github.com/codeblooded/atc-api/commit/a75978a9d9a65a5e8b592685a53045e9fe6d1d91 and it's claiming that this line https://github.com/codeblooded/atc-api/blob/master/app/controllers/colors_controller.rb#L12 is a 401. Any ideas? I'm about to remove active_model_serializers and see if my tests pass again.

See my answer below. I did remove the gem, and all the unrelated tests started passing again. So, I opened a bug with the project. I think active_model_serializers must be touching some object in some unexpected way.


Solution

  • Ok, so I'm pretty sure this is one of those weird bugs. I removed active_model_serializers gem and deleted my UserSerializer class. All tests pass again. I filed an issue with the project: active_model_serializers#2168.