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