Sha256: a5e514c1d867680706d2bd6e30a2c91c2bd399dfd543a1e9d72b9387fd6b8c82

Contents?: true

Size: 1.89 KB

Versions: 7

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe "Consolidated iCal feed", :feature do
  let(:now) { Time.now }
  let(:parsed_feed) { RiCal.parse_string(Almanack.calendar.ical_feed) }
  let(:parsed_cal) { parsed_feed.first }
  let(:parsed_events) { parsed_cal.events }

  before do
    Timecop.freeze(now)

    Almanack.reset!

    Almanack.config.add_events [
      { title: "Basic", start_time: now },
      { title: "Almost a year away", start_time: now + 364 * 24 * 60 * 60 },
      { title: "Over a year away", start_time: now + 366 * 24 * 60 * 60 },
      {
        title: "Complex",
        start_time: now,
        end_time: now + 30 * 24 * 60 * 60,
        description: "Body",
        location: "CA"
      }
    ]
  end

  after { Timecop.return }

  it "should contain one calendar entity" do
    expect(parsed_feed.length).to eq(1)
    expect(parsed_feed.first).to be_an_instance_of(RiCal::Component::Calendar)
  end

  it "contains a year's worth of events" do
    expect(parsed_events.length).to eq(3)
    expect(parsed_events.map(&:summary)).to_not include("Over a year away")
  end

  it "contains all available event information" do
    complex_event = parsed_events.find { |e| e.summary == 'Complex' }
    expect(complex_event.dtstart).to eq_time(now)
    expect(complex_event.dtend).to eq_time(now + 30 * 24 * 60 * 60)
    expect(complex_event.description).to eq('Body')
    expect(complex_event.location).to eq('CA')
  end

  it "treats missing end dates as three hours from the start date" do
    three_hours_from_now = now + 3 * 60 * 60
    basic_event = parsed_events.find { |e| e.summary == 'Basic' }
    expect(basic_event.dtend).to eq_time(three_hours_from_now)
  end

  it "can be accessed from the server" do
    allow(Almanack.calendar).to receive(:ical_feed) { "feed" }
    get "/feed.ics"
    expect(last_response.body).to eq("feed")
    expect(last_response.headers["Content-Type"]).to include("text/calendar")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
almanack-1.1.0 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta6 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta5 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta4 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta3 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta2 spec/features/subscription_feature_spec.rb
almanack-1.1.0.beta1 spec/features/subscription_feature_spec.rb