Sha256: f506a16ba8b94cadab666892a13715ed989aa2c9fc23d97f23fcbe1e87c54374
Contents?: true
Size: 1.41 KB
Versions: 7
Compression:
Stored size: 1.41 KB
Contents
describe Sufia::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
7 entries across 7 versions & 1 rubygems