summaryrefslogtreecommitdiff
path: root/spec/models/clusters/agent_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/clusters/agent_spec.rb')
-rw-r--r--spec/models/clusters/agent_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/clusters/agent_spec.rb b/spec/models/clusters/agent_spec.rb
index f279e779de5..f10e0cc8fa7 100644
--- a/spec/models/clusters/agent_spec.rb
+++ b/spec/models/clusters/agent_spec.rb
@@ -117,6 +117,23 @@ RSpec.describe Clusters::Agent do
end
end
+ describe '#last_used_agent_tokens' do
+ let_it_be(:agent) { create(:cluster_agent) }
+
+ subject { agent.last_used_agent_tokens }
+
+ context 'agent has no tokens' do
+ it { is_expected.to be_empty }
+ end
+
+ context 'agent has active and inactive tokens' do
+ let!(:active_token) { create(:cluster_agent_token, agent: agent, last_used_at: 1.minute.ago) }
+ let!(:inactive_token) { create(:cluster_agent_token, agent: agent, last_used_at: 2.hours.ago) }
+
+ it { is_expected.to contain_exactly(active_token, inactive_token) }
+ end
+ end
+
describe '#activity_event_deletion_cutoff' do
let_it_be(:agent) { create(:cluster_agent) }
let_it_be(:event1) { create(:agent_activity_event, agent: agent, recorded_at: 1.hour.ago) }