require 'test_helper' module PagesCms class PageTest < ActiveSupport::TestCase def setup @page = pages_cms_pages(:one) end test 'valid page' do assert @page.valid?, "Errors: #{@page.errors.full_messages.to_sentence} Slug:#{@page.slug}" end test 'slug gets parameterized' do page = Page.new(account_id: 1, title: 'really cool') page.save assert_equal page.slug, 'really-cool' end test 'different slug names' do page1 = Page.new(account_id: 1, title: 'Duplicate') page2 = Page.new(account_id: 1, title: 'Duplicate') assert page1.valid? page1.save assert_not page2.valid?, "#{page2.errors.full_messages}" end test 'page with no account' do page = Page.new(title: 'really cool') assert_not page.valid? end test 'update page' do @page.update(draft: true) end end end