Sha256: eceb61717f7bfc645e98ba2d4a8df019f0c0961294ca1b3209d678181e9d5cb4
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' describe 'generic_files/stats.html.erb' do describe 'usage statistics' do let(:generic_file) { stub_model(GenericFile, noid: '123', title: ['file1.txt']) } let(:no_stats) { allow_message_expectations_on_nil allow(FileUsage).to receive(:new) stub_model(FileUsage, created: Date.parse('2014-01-01'), total_pageviews: 0, total_downloads: 0, to_flot: [] ) } let(:stats) { allow(FileUsage).to receive(:new) stub_model(FileUsage, created: Date.parse('2014-01-01'), total_pageviews: 9, total_downloads: 4, to_flot: [[1396422000000,2],[1396508400000,3],[1396594800000,4]] ) } before do assign(:generic_file, generic_file) assign(:stats, no_stats) end context 'when no analytics results returned' do before do assign(:pageviews, 0) end it 'shows 0 visits' do render page = Capybara::Node::Simple.new(rendered) expect(page).to have_selector('div.alert-info', text: /0 views and 0 downloads since January 1, 2014/i, count: 1) end end context 'when results are returned' do before do assign(:stats, stats) end it 'shows visits' do render page = Capybara::Node::Simple.new(rendered) expect(page).to have_selector('div.alert-info', text: /9 views and 4 downloads since January 1, 2014/i, count: 1) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sufia-4.0.1 | spec/views/generic_file/stats.html.erb_spec.rb |
sufia-4.0.0 | spec/views/generic_file/stats.html.erb_spec.rb |