Sha256: ddfd3114c46e35b9687c5df63e8fea17f1fbb018b687cbd206bc5065dc0aa8db
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# == Schema Information # # Table name: pages # # id :integer not null, primary key # name :string(255) # permalink :string(255) # site_id :integer # created_at :datetime # updated_at :datetime # require 'rails_helper' # =============================== # Note: The Site model is used to test the base functionality of Superslug. This # model is used to test how a model acts within the context of an object of # another model. We also use this model to test some options. # =============================== RSpec.describe Page, :type => :model do before :all do @site_1 = create(:site, :title => 'Hello World') @site_2 = create(:site, :title => 'Goodbye World') end it 'will use underscores if the option is specified' do page = create(:page, :name => 'Hello World 01') expect(page.permalink).to eq('hello_world_01') end it 'will not append the id if an identical slug exists but belongs to a different site' do create(:page, :name => 'Hello World 02', :site => @site_1) page = create(:page, :name => 'Hello World 02', :site => @site_2) expect(page.permalink).to eq('hello_world_02') end it 'will append the id if the slug is duplicated for records belonging to the same site' do create(:page, :name => 'Hello World 03', :site => @site_1) page = create(:page, :name => 'Hello World 03', :site => @site_1) expect(page.permalink).to eq("hello_world_03_#{page.id}") end it 'will change the slug if forced' do page = create(:page, :name => 'Hello World 04') page.update(:name => 'Hello World 05') expect(page.permalink).to eq('hello_world_05') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
superslug-1.3.1 | test/spec/models/page_spec.rb |
superslug-1.3.0 | test/spec/models/page_spec.rb |