Sha256: de506a6568d369cb77c816b121f00a9ad7e4a2145573c7223ee493c4c3508ff3

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe 'spotlight/dashboards/_analytics.html.erb', type: :view do
  let(:current_exhibit) { FactoryGirl.create(:exhibit) }
  let(:ga_data) { OpenStruct.new(pageviews: 1, users: 2, sessions: 3) }
  let(:page_data) { [OpenStruct.new(pageTitle: 'title', pagePath: '/path', pageviews: '123')] }
  before do
    allow(view).to receive_messages(current_exhibit: current_exhibit, exhibit_root_path: '/some/path')
    allow(current_exhibit).to receive(:analytics).and_return(ga_data)
    allow(current_exhibit).to receive(:page_analytics).and_return(page_data)
  end

  it 'uses the exhibit_root_path for analytics' do
    expect(current_exhibit).to receive(:analytics).with(1.month, '/some/path').and_return(ga_data)
    expect(current_exhibit).to receive(:page_analytics).with(1.month, '/some/path').and_return(page_data)
    render
  end

  it 'has header' do
    render
    expect(rendered).to have_content 'User Activity Over the Past Month'
  end

  it 'has metric labels' do
    render
    expect(rendered).to have_content 'visitors'
    expect(rendered).to have_content 'unique visits'
    expect(rendered).to have_content 'page views'
  end

  it 'has metric values' do
    render
    expect(rendered).to have_selector '.value.pageviews', text: 1
    expect(rendered).to have_selector '.value.users', text: 2
    expect(rendered).to have_selector '.value.sessions', text: 3
  end

  it 'has page-level data' do
    render
    expect(rendered).to have_content 'Most popular pages'
    expect(rendered).to have_link 'title', href: '/path'
    expect(rendered).to have_content '123'
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
blacklight-spotlight-0.19.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.18.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.17.1 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.17.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.16.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.15.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.14.2 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.14.1 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.14.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.13.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.12.1 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.12.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.11.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.10.3 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.10.2 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.10.1 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.10.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.9.2 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.9.1 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb
blacklight-spotlight-0.9.0 spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb