Sha256: 2d872c871b2267295e770a08b707081d3e0c9a7a1147ed66051b7a08754647a5

Contents?: true

Size: 1.66 KB

Versions: 16

Compression:

Stored size: 1.66 KB

Contents

require 'rails_helper'

describe CmsPost do
  setup_account

  it 'write more tests'
  
  describe 'slug handling' do

    let(:blog1) { create(:blog) }
    let(:blog2) { create(:news_blog)}
    
    #------------------------------------------------------------------------------
    it 'allows the same specified slug between two blogs (scoped to blog)' do
      post1 = blog1.posts.create(attributes_for(:post, slug: 'test-slug'))
      post2 = blog2.posts.create(attributes_for(:post, slug: 'test-slug'))
      expect(post1.slug).to eq post2.slug
    end

    #------------------------------------------------------------------------------
    it 'allows the same auto-generated slug between two blogs (scoped to blog)' do
      post1 = blog1.posts.create(attributes_for(:post, slug: nil))
      post2 = blog2.posts.create(attributes_for(:post, slug: nil))
      expect(post1.slug).to eq post2.slug
    end

    #------------------------------------------------------------------------------
    it 'raises an error when same slug is specified for posts in the same blog' do
      post1 = blog1.posts.create(attributes_for(:post, slug: 'test-slug'))
      post2 = blog1.posts.create(attributes_for(:post, slug: 'test-slug'))
      expect(post2).not_to be_valid
      expect(post2.errors[:slug]).to include("has already been taken")
    end

    #------------------------------------------------------------------------------
    it 'creates a unique auto-generated slug for posts in the same blog' do
      post1 = blog1.posts.create(attributes_for(:post, slug: nil))
      post2 = blog1.posts.create(attributes_for(:post, slug: nil))
      expect(post1.slug).not_to eq post2.slug
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_cms-4.2.3.10 spec/models/cms_post_spec.rb
dm_cms-4.2.3.9 spec/models/cms_post_spec.rb
dm_cms-4.2.3.8 spec/models/cms_post_spec.rb
dm_cms-4.2.3.7 spec/models/cms_post_spec.rb
dm_cms-4.2.3.6 spec/models/cms_post_spec.rb
dm_cms-4.2.3.5 spec/models/cms_post_spec.rb
dm_cms-4.2.3.4 spec/models/cms_post_spec.rb
dm_cms-4.2.3.3 spec/models/cms_post_spec.rb
dm_cms-4.2.3.2 spec/models/cms_post_spec.rb
dm_cms-4.2.3.1 spec/models/cms_post_spec.rb
dm_cms-4.2.3 spec/models/cms_post_spec.rb
dm_cms-4.2.2.3 spec/models/cms_post_spec.rb
dm_cms-4.2.2.2 spec/models/cms_post_spec.rb
dm_cms-4.2.2.1 spec/models/cms_post_spec.rb
dm_cms-4.2.2 spec/models/cms_post_spec.rb
dm_cms-4.2.1.5 spec/models/cms_post_spec.rb