Sha256: 3a97efc10dcbb5c0cca38194383a58e9dc44db1bed769599257acb88a1168dd3

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

require 'rails_helper'

describe Pulitzer::PostTypeContentElementType do
  let(:post_type) {Pulitzer::PostType.named('Welcome')}
  let(:post_type_content_element_type) { post_type.post_type_content_element_types.first }
  let(:cet) {post_type_content_element_type.content_element_type}

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

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

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

  describe "sort order" do
    it "creates elements with the next sort order" do
      last_element_index = post_type_content_element_type.highest_sibling_sort
      ptcet = post_type.post_type_content_element_types.create(content_element_type: cet, label: 'Test Element')
      expect(ptcet.sort_order).to eq (last_element_index + 1)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pulitzer-0.15.0 spec/models/post_type_content_element_type_spec.rb
pulitzer-0.14.4 spec/models/post_type_content_element_type_spec.rb
pulitzer-0.14.3 spec/models/post_type_content_element_type_spec.rb