Sha256: 32b142a3baddd86e67479ab17728590e93bab6aca823313111a530b67b501dea

Contents?: true

Size: 965 Bytes

Versions: 24

Compression:

Stored size: 965 Bytes

Contents

require 'rails_helper'

describe Pulitzer::Post do
  let(:post) { build :post }

  it 'has a valid factory' do
    expect(post).to be_valid
  end

  describe "Active Model validations" do
    it { should validate_presence_of(:title) }
  end

  describe "ActiveRecord associations" do
    it { should belong_to(:post_type) }
  end

  describe "#active_version" do
    let(:post) { create :post }
    let!(:preview) { create :version, post: post, status: :preview }
    let!(:active)  { create :version, post: post, status: :active  }

    it "should return the version with status = active" do
      expect(post.active_version).to eq active
    end
  end

  describe "Generate a slug" do
    let(:post) { create :post }

    it 'for a new post' do
      expect(post.slug).to match 'winterfell-news-'
    end

    it 'updating a post' do
      post.update title: 'The new King in the North'
      expect(post.slug).to eq 'the-new-king-in-the-north'
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pulitzer-0.5.14 spec/models/post_spec.rb
pulitzer-0.5.13 spec/models/post_spec.rb
pulitzer-0.5.11 spec/models/post_spec.rb
pulitzer-0.5.10 spec/models/post_spec.rb
pulitzer-0.5.9 spec/models/post_spec.rb
pulitzer-0.5.8 spec/models/post_spec.rb
pulitzer-0.5.7 spec/models/post_spec.rb
pulitzer-0.5.6 spec/models/post_spec.rb
pulitzer-0.5.5 spec/models/post_spec.rb
pulitzer-0.5.4 spec/models/post_spec.rb
pulitzer-0.5.3 spec/models/post_spec.rb
pulitzer-0.5.2 spec/models/post_spec.rb
pulitzer-0.5.1 spec/models/post_spec.rb
pulitzer-0.5.0 spec/models/post_spec.rb
pulitzer-0.4.16 spec/models/post_spec.rb
pulitzer-0.4.15 spec/models/post_spec.rb
pulitzer-0.4.14 spec/models/post_spec.rb
pulitzer-0.4.13 spec/models/post_spec.rb
pulitzer-0.4.12 spec/models/post_spec.rb
pulitzer-0.4.11 spec/models/post_spec.rb