Sha256: cf67ab38307c21df4fe39228a2611f2a45b04bbe02c83f5adb6e45fa91b84518

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
# require 'model_shared'
RSpec.describe 'hyrax/newspaper_titles/_issue_calendar.html.erb', type: :view do
  let!(:issues) do
    [
      SolrDocument.new(id: '123',
                       publication_date_dtsi: '2019-02-13T:00:00:00Z'),
      SolrDocument.new(id: '456',
                       publication_date_dtsi: '2019-03-05T:00:00:00Z')
    ]
  end

  let(:years) do
    { current: 2019, previous: nil, next: nil }
  end

  it 'shows calendar' do
    render partial: "issues_calendar.html.erb", locals: { issues: issues, years: years }
    expect(rendered).to have_content 'January'
  end

  it 'has link on dates with issues' do
    render partial: "issues_calendar.html.erb", locals: { issues: issues, years: years }
    links = {}
    issues.each do |issue|
      links[Date.parse(issue["publication_date_dtsi"]).strftime("%-d")] = hyrax_newspaper_issue_path(issue)
    end
    links.each do |day, path|
      expect(rendered).to have_link(day, href: path)
    end
  end

  it 'displays the year' do
    render partial: "issues_calendar.html.erb", locals: { issues: issues, years: years }
    expect(rendered).to have_content "Issues: 2019"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 spec/views/hyrax/newspaper_titles/_issues_calendar.html.erb_spec.rb
newspaper_works-1.0.0 spec/views/hyrax/newspaper_titles/_issues_calendar.html.erb_spec.rb
newspaper_works-0.1.0 spec/views/hyrax/newspaper_titles/_issues_calendar.html.erb_spec.rb