Sha256: d911900d52611f6dbb12b99a4d446e4a635de00531dc180be50c3c4b5812026f

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

describe "sufia/admin/stats/show.html.erb", type: :view do
  let(:presenter) do
    Sufia::AdminStatsPresenter.new({}, 5)
  end
  before do
    assign(:presenter, presenter)
    allow(presenter).to receive(:top_formats).and_return([])
  end

  context "default depositors" do
    let(:top_5_active_users) do
      (1..5).map { |i| double(label: i.to_s, value: i) }
    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
      (1..20).map { |i| double(label: i.to_s, value: i) }
    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).not_to have_content("View top 20")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.4.0 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.3.1 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.3.0 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.3.0.rc3 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.3.0.rc2 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.3.0.rc1 spec/views/sufia/admin/stats/show.html.erb_spec.rb
sufia-7.2.0 spec/views/sufia/admin/stats/show.html.erb_spec.rb