Skip to content

Commit

Permalink
Merge pull request #36 from basecamp/fix-update-and-pattern-change
Browse files Browse the repository at this point in the history
Fix update and pattern change
  • Loading branch information
lewispb authored Apr 30, 2024
2 parents 5a54fdf + 34e813e commit 18ba6b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/mission_control/web/routes_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ def initialize(application)
end

def put(route)
remove(route)

if route.disabled?
add(route)
else
remove(route)
end
end

def remove(route)
redis.srem redis_key, route.pattern.to_s
redis.srem redis_key, [ route.pattern_previously_was.to_s, route.pattern.to_s ]
end

def disabled?(path)
Expand Down
7 changes: 7 additions & 0 deletions test/models/mission_control/web/route_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class MissionControl::Web::RouteTest < ActiveSupport::TestCase
assert_not MissionControl::Web.host_application.route_disabled? "/campfire"
end

test "updating a Route with a new pattern deletes the old pattern" do
@route.update!(pattern: "/chat")

assert_not MissionControl::Web.host_application.route_disabled? "/campfire"
assert MissionControl::Web.host_application.route_disabled? "/chat"
end

test "destroying a Route removes the routes configuration" do
@route.destroy!

Expand Down

0 comments on commit 18ba6b7

Please sign in to comment.