route helpers sometimes return route with extension, and sometimes do not
tmertens opened this issue · 3 comments
When running tests for an app, sometimes the grape route helpers return a string with the extension for the route appended (expected behavior), and sometimes they do not (not expected). This causes tests to fail for code that generates a payload with callback URLs using grape route helpers, because the return value is not consistent.
Any ideas why this would be happening? I suspect it is a load order issue but I have not been able to identify the specific culprit yet as it only happens 1:20 builds; however, when it does occur we see all tests that rely on grape route helpers fail, not just one or two intermittent failures within the specs.
Thanks for reporting this. I'm not sure why there's an intermittent failure off the top of my head. Are you able to write a generic test that helps me reproduce this?
Can you describe how you're using the helpers more? That might help me figure out what's going on. How are you using the helpers to generate a payload that has callback URLs in them? Can you paste an example, and example return value?
Did you only see test failures when you're using the helpers in that specific way?
@reprah Yes, we are using the helpers to generate callback URLs. Here is an example:
class Capabilities
include GrapeRouteHelpers::NamedRouteMatcher
def my_callback_hash_generator
# Where `api_install_complete_path` is the grape route helper
{ callbackUrl: URI.join(root_url, api_install_complete_path).to_s }
end
def root_url
Rails.application.routes.url_helpers.root_url
end
end
The return value is always the same path, with the exception that sometimes it is missing the .json
extension.
I only use the helpers in a couple of places, so unfortunately I don't have a lot of other use cases to draw from.