43
Root
5y

tl;dr @Root refactors some spaghetti.

I'm refactoring an api that creates a support message. It's a post route.

When seeing a magic hardcoded message string, this route instead updates the user object, and does not create a support message.

It also returns different results if the user is muted (fine) or if saving the message succeeds or fails (fine).

But if the user is creating a duplicate message, it doesn't save the message (fine) and... redirects to listing their messages instead? Wat?

Also, when refactoring this (migrating to a new message backend), I discovered that not all routes return a response. If the message is a non-duplicate, from a non-muted player, from a non-redacted client, the route doesn't respond at all!

So, I'm having fun cleaning this up. I actually am. Except I'll need to support all of the legacy clients for the next lifetime or two. I mean, really. There are still people with Android v2 devices who are using this thing. not even kidding.

Comments
  • 11
    In Rails 4, `render text: "blah"` renders "blah" like you'd expect. In Rails 5, it renders ABSOLUTELY NOTHING BUT AN EMPTY BODY. You must instead use `render plain: "blah"` -- but there are no deprecation warnings or anything.

    I wasted an hour debugging my test case for this, thinking the routing, my test, my factories, or my almost complete refactoring were to blame. AN HOUR OF MY LIFE. ASDFJKLSFASJF.
  • 3
    Getting popcorn now. This should be fun!
    Also - add versions in the request headers to redirect old traffic to old handlers. That return "upgrade damnit!"
  • 2
    @magicMirror I've never done that before, but it would be wonderful. I'll see if it's possible with Rails.
  • 2
    Does the 0.01% of Android <4 users really justify lowering your target Android API level that much though? I'd argue with whoever made that decision that losing those users is probably for the best in every way possible anyway.

    And, I mean, wasn't there also that requirement in Google I/O earlier that now all applications have to target the modern API levels? 26 if memory serves me right.
  • 3
    @Condor Backend, not android development. 😋
  • 4
    Pssst.. these people with Android v2 are secretly employed at your competitor.
  • 1
    I am just commenting to follow the API tales of @Root, this should be fun 😜
  • 2
    @frickerg I've been writing tests. I'm up to 86% coverage! 😄

    The APIs here are decent. Not great, but considering my last foray into API Hell (thanks to API Guy), these are positively wonderful!
  • 1
    @Root hey 86% sounds really good though!
Add Comment