require 'spec_helper'

describe "repositories/overview.html.erb" do
  it "should display all the repositories" do

    assign(:repositories, [
      stub_model(Repository, :name => 'Open Data Portal', :type => 'Database',
                 :url => 'http://example.com/portal'),
      stub_model(Repository, :name => 'Open Government', :type => 'Platform',
                 :url => 'http://example.com/platform')
    ])

    render

    expect(rendered).to include 'Open Data Portal'
    expect(rendered).to include 'Database'
    expect(rendered).to include 'example.com/portal'

    expect(rendered).to include 'Open Government'
    expect(rendered).to include 'Platform'
    expect(rendered).to include 'example.com/platform'
  end
end

require 'spec_helper'

describe "repositories/overview.html.erb" do
  
  it "should display all the repositories" do
    assign(:repositories, [
      stub_model(Repository, :name => 'Open Data Portal', :type => 'Database',
                 :url => 'http://example.com/portal', :total => 3000),
      stub_model(Repository, :name => 'Open Government', :type => 'Platform',
                 :url => 'http://example.com/platform', :total => 7000)
    ])

    render

    expect(rendered).to include 'Open Data Portal'
    expect(rendered).to include 'Database'
    expect(rendered).to include 'example.com/portal'

    expect(rendered).to include 'Open Government'
    expect(rendered).to include 'Platform'
    expect(rendered).to include 'example.com/platform'

    expect(rendered).to include '3,000'
    expect(rendered).to include '7,000'
  end

end

Fix test by assigning total datasets value to stub
Fix test by assigning total datasets value to stub

Since I had not defined a total datasets value for the model stub in the
test, the query of the total method was executed. Without indexes on the
ElasticSearch instance this fails. Hence, I just added this value.

With this change I also added assertions to check the formatting of the
rendered value.

Signed-off-by: Konrad Reiche <4ff0213f56e2082fcd8c882d04c546881c579ce4@gmail.com>
