Sha256: f55e79700d8dc1987f5e9f1445d3c8567d569ef6e965f39d8a4b63cf8ef3effb
Contents?: true
Size: 1.39 KB
Versions: 10
Compression:
Stored size: 1.39 KB
Contents
describe Hyrax::Statistics::SystemStats do let(:user1) { create(:user) } let(:start_date) { nil } let(:end_date) { nil } let(:stats) { described_class.new(depositor_count, start_date, end_date) } describe "#recent_users" do let!(:user2) { create(:user) } let(:two_days_ago_date) { 2.days.ago.beginning_of_day } let(:one_day_ago_date) { 1.day.ago.end_of_day } let(:depositor_count) { nil } subject { stats.recent_users } context "without dates" do let(:mock_order) { double } let(:mock_limit) { double } it "defaults to latest 5 users" do expect(mock_order).to receive(:limit).with(5).and_return(mock_limit) expect(User).to receive(:order).with('created_at DESC').and_return(mock_order) is_expected.to eq mock_limit end end context "with start date" do let(:start_date) { two_days_ago_date } it "allows queries without an end date " do expect(User).to receive(:recent_users).with(two_days_ago_date, nil).and_return([user2]) is_expected.to eq([user2]) end end context "with start date and end date" do let(:start_date) { two_days_ago_date } let(:end_date) { one_day_ago_date } it "queries" do expect(User).to receive(:recent_users).with(two_days_ago_date, one_day_ago_date).and_return([user2]) is_expected.to eq([user2]) end end end end
Version data entries
10 entries across 10 versions & 2 rubygems