Sha256: 7b7d2ed67542715c8892a68c720751e6416589adacdc1d9053165db5de955012
Contents?: true
Size: 1.41 KB
Versions: 8
Compression:
Stored size: 1.41 KB
Contents
describe Hyrax::UserUsageStats do subject { FactoryGirl.create(:user) } describe 'with cached stats' do let!(:stat_1_day_ago) { UserStat.create!(user_id: subject.id, date: 1.day.ago, file_views: 3, file_downloads: 2, work_views: 5) } let!(:stat_2_days_ago) { UserStat.create!(user_id: subject.id, date: 2.days.ago, file_views: 2, file_downloads: 1, work_views: 7) } let!(:someone_elses_user_id) { subject.id + 1 } let!(:not_my_stat) { UserStat.create!(user_id: someone_elses_user_id, date: 2.days.ago, file_views: 10, file_downloads: 11) } describe '#total_file_views' do it 'returns the total file views for that user' do expect(subject.total_file_views).to eq 5 end end describe '#total_file_downloads' do it 'returns the total file downloads for that user' do expect(subject.total_file_downloads).to eq 3 end end describe '#total_work_views' do it 'returns the total work views for that user' do expect(subject.total_work_views).to eq 12 end end end describe 'with empty cache' do describe '#total_file_views' do it 'returns the total file views for that user' do expect(subject.total_file_views).to eq 0 end end describe '#total_file_downloads' do it 'returns the total file downloads for that user' do expect(subject.total_file_downloads).to eq 0 end end end end
Version data entries
8 entries across 8 versions & 2 rubygems