2023-06-06 00:52:33 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe Admin::Metrics::Dimension::LanguagesDimension do
|
2024-04-05 19:54:11 +11:00
|
|
|
subject { described_class.new(start_at, end_at, limit, params) }
|
2023-06-06 00:52:33 +10: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-05 19:54:11 +11:00
|
|
|
let(:alice) { Fabricate(:user, locale: 'en', current_sign_in_at: 1.day.ago) }
|
|
|
|
let(:bob) { Fabricate(:user, locale: 'en', current_sign_in_at: 30.days.ago) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
alice.update(current_sign_in_at: 1.day.ago)
|
|
|
|
bob.update(current_sign_in_at: 30.days.ago)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns locales with sign in counts' do
|
|
|
|
expect(subject.data.size)
|
|
|
|
.to eq(1)
|
|
|
|
expect(subject.data.map(&:symbolize_keys))
|
|
|
|
.to contain_exactly(
|
|
|
|
include(key: 'en', value: '1')
|
|
|
|
)
|
2023-06-06 00:52:33 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|