Sha256: e64db8ec021b0a2278576e134482c52136beeb98592c34c49e1d3c95011ca3f8

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe "admin/stats/index.html.erb" do
  let(:presenter) do
    Sufia::AdminStatsPresenter.new({}, 5).tap do |p|
      p.deposit_stats = {}
      p.depositors = []
    end
  end
  before do
    assign(:presenter, presenter)
  end

  context "default depositors" do
    let(:top_5_active_users) do
      users = {}
      5.times { |i| users[i.to_s] = i }
      users
    end
    before do
      allow(presenter).to receive(:active_users).and_return(top_5_active_users)
      render
    end
    it "shows top 5 depositors and option to view more" do
      expect(rendered).to have_content("(top 5)")
      expect(rendered).to have_link("View top 20", href: "/admin/stats?limit=20")
    end
  end

  context "top 20 depositors" do
    let(:top_20_active_users) do
      users = {}
      20.times { |i| users[i.to_s] = i }
      users
    end
    before do
      allow(presenter).to receive(:active_users).and_return(top_20_active_users)
      allow(presenter).to receive(:limit).and_return(20)
      render
    end
    it "shows top 20 depositors, without an option to view more" do
      expect(rendered).to have_content("(top 20)")
      expect(rendered).to_not have_content("View top 20")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sufia-6.7.0 spec/views/admin/stats/index.html.erb_spec.rb
sufia-6.6.1 spec/views/admin/stats/index.html.erb_spec.rb
sufia-6.6.0 spec/views/admin/stats/index.html.erb_spec.rb
sufia-6.5.0 spec/views/admin/stats/index.html.erb_spec.rb
sufia-6.4.0 spec/views/admin/stats/index.html.erb_spec.rb