2023-06-05 16:52:33 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Admin::Metrics::Dimension::SourcesDimension do
|
2024-04-12 11:18:35 +02:00
|
|
|
subject { described_class.new(start_at, end_at, limit, params) }
|
2023-06-05 16:52:33 +02:00
|
|
|
|
|
|
|
let(:start_at) { 2.days.ago }
|
|
|
|
let(:end_at) { Time.now.utc }
|
|
|
|
let(:limit) { 10 }
|
|
|
|
let(:params) { ActionController::Parameters.new }
|
|
|
|
|
|
|
|
describe '#data' do
|
2024-04-12 11:18:35 +02:00
|
|
|
let(:app) { Fabricate(:application) }
|
|
|
|
let(:alice) { Fabricate(:user) }
|
|
|
|
let(:bob) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
alice.update(created_by_application: app)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns OAuth applications with user counts' do
|
|
|
|
expect(subject.data.size)
|
|
|
|
.to eq(1)
|
|
|
|
expect(subject.data.map(&:symbolize_keys))
|
|
|
|
.to contain_exactly(
|
|
|
|
include(key: app.name, value: '1')
|
|
|
|
)
|
2023-06-05 16:52:33 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|