From 437a8db85b3ea18b825991dabbc7e75b202c0a7c Mon Sep 17 00:00:00 2001 From: Dan Mayer Date: Sun, 2 Jun 2024 17:44:48 -0600 Subject: [PATCH] fix for #539 ensure we use namespace when available for abstract tracker --- lib/coverband/collectors/abstract_tracker.rb | 6 +++++- test/coverband/collectors/route_tracker_test.rb | 2 +- test/coverband/collectors/view_tracker_test.rb | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/coverband/collectors/abstract_tracker.rb b/lib/coverband/collectors/abstract_tracker.rb index 1dcd562a..8a52421e 100644 --- a/lib/coverband/collectors/abstract_tracker.rb +++ b/lib/coverband/collectors/abstract_tracker.rb @@ -157,7 +157,11 @@ def tracker_time_key end def class_key - @class_key ||= self.class.name.split("::").last + @class_key ||= if Coverband.configuration.redis_namespace + "#{Coverband.configuration.redis_namespace}_#{self.class.name.split("::").last}" + else + self.class.name.split("::").last + end end end end diff --git a/test/coverband/collectors/route_tracker_test.rb b/test/coverband/collectors/route_tracker_test.rb index 02ccc96f..a3b373a3 100644 --- a/test/coverband/collectors/route_tracker_test.rb +++ b/test/coverband/collectors/route_tracker_test.rb @@ -174,7 +174,7 @@ def setup method: "GET" } store.raw_store.expects(:del).with(tracker_key) - store.raw_store.expects(:del).with("RouteTracker_tracker_time") + store.raw_store.expects(:del).with("#{tracker_key}_time") tracker = Coverband::Collectors::RouteTracker.new(store: store, roots: "dir") tracker.track_key(payload) tracker.reset_recordings diff --git a/test/coverband/collectors/view_tracker_test.rb b/test/coverband/collectors/view_tracker_test.rb index 960156fb..df3eceb5 100644 --- a/test/coverband/collectors/view_tracker_test.rb +++ b/test/coverband/collectors/view_tracker_test.rb @@ -4,7 +4,7 @@ class ViewTrackerTest < Minitest::Test def tracker_key - "ViewTracker_tracker" + "coverband_test_ViewTracker_tracker" end def setup @@ -98,7 +98,7 @@ def setup Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true) store = fake_store store.raw_store.expects(:del).with(tracker_key) - store.raw_store.expects(:del).with("ViewTracker_tracker_time") + store.raw_store.expects(:del).with("#{tracker_key}_time") tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir") tracker.track_key(identifier: "file") tracker.reset_recordings