Sha256: 449c33c2fb9c101b259555805c6bcf18456c87d5c0fa3b7aa1e4999aa6c77b21

Contents?: true

Size: 961 Bytes

Versions: 7

Compression:

Stored size: 961 Bytes

Contents

require "rails_helper"

describe Announcement, "#current" do
  it "should return the latest announcement when there are several" do
    old = create :announcement, body: "no fun", created_at: 2.days.ago
    latest = create :announcement, body: "fun", created_at: 1.day.ago
    older = create :announcement, body: "less fun", created_at: 3.days.ago

    expect(Announcement.current).to eq latest
  end

  it "should return an existent announcement where there is no announcement" do
    create :announcement, body: "body"
    expect(Announcement.current.exists?).to be true
  end

  it "should return a non-existent announcement where there is no announcement" do
    expect(Announcement.current.exists?).to be false
  end
end

describe Announcement, "#to_cookie_key" do
  it "returns a value usable as a cookie key" do
    record = create :announcement, body: "Text"

    expect(record.to_cookie_key).to eq "announcement_#{record.created_at.iso8601}"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
paul_revere-3.3.0 spec/models/announcement_spec.rb
paul_revere-3.2.0 spec/models/announcement_spec.rb
paul_revere-3.1.0 spec/models/announcement_spec.rb
paul_revere-3.0.0 spec/models/announcement_spec.rb
paul_revere-2.1.0 spec/models/announcement_spec.rb
paul_revere-2.1.0.rc1 spec/models/announcement_spec.rb
paul_revere-2.0.0 spec/models/announcement_spec.rb