Sha256: 25e08d1bba2400d96d00c3f211bdbd7710d10a47a7b40ad689a8da9e78e2cad7

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

describe 'hyrax/stats/file.html.erb', type: :view do
  describe 'usage statistics' do
    before do
      allow_message_expectations_on_nil
    end

    let(:no_stats) do
      double('FileUsage',
             created: Date.parse('2014-01-01'),
             total_pageviews: 0,
             total_downloads: 0,
             to_flot: [])
    end

    let(:stats) do
      double('FileUsage',
             created: Date.parse('2014-01-01'),
             total_pageviews: 9,
             total_downloads: 4,
             to_flot: [[1_396_422_000_000, 2], [1_396_508_400_000, 3], [1_396_594_800_000, 4]])
    end

    context 'when no analytics results returned' do
      before do
        assign(:stats, no_stats)
        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

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.1.0 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.5 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.4 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.3 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.2 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.1 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.0.rc2 spec/views/hyrax/stats/file.html.erb_spec.rb
hyrax-1.0.0.rc1 spec/views/hyrax/stats/file.html.erb_spec.rb
test_hyrax-0.0.1.alpha spec/views/hyrax/stats/file.html.erb_spec.rb