Sha256: f297618478ff825249668deac502092b0732e008064cf77b33b770e3cf0a4c36
Contents?: true
Size: 1.72 KB
Versions: 6
Compression:
Stored size: 1.72 KB
Contents
require 'test_helper' class PageTemplateTest < ActiveSupport::TestCase def setup @page_template = Factory.build(:page_template, :name => "test") File.delete(@page_template.file_path) if File.exists?(@page_template.file_path) end def teardown File.delete(@page_template.file_path) if File.exists?(@page_template.file_path) end test "Name used to build the form" do assert_equal "page_template", Cms::PageTemplate.resource_collection_name end test "resource_name works for namespaced templates" do assert_equal "page_templates", Cms::PageTemplate.resource_name end def test_create_and_destroy assert !File.exists?(@page_template.file_path), "template file already exists" assert_valid @page_template assert @page_template.save assert File.exists?(@page_template.file_path), "template file was not written to disk" @page_template.destroy assert !File.exists?(@page_template.file_path), "template file was not removed on destroy" end def test_for_valid_name assert_not_valid Factory.build(:page_template, :name => "Fancy") assert_not_valid Factory.build(:page_template, :name => "foo bar") assert_valid Factory.build(:page_template, :name => "subpage_1_column") end def test_find_by_file_name assert @page_template.save, "Could not save page template" assert_equal @page_template, Cms::PageTemplate.find_by_file_name("test.html.erb") assert_nil Cms::PageTemplate.find_by_file_name("fail.html.erb") assert_nil Cms::PageTemplate.find_by_file_name("fail.erb") assert_nil Cms::PageTemplate.find_by_file_name("fail") assert_nil Cms::PageTemplate.find_by_file_name(nil) end def test_default_body assert_not_nil Cms::PageTemplate.default_body end end
Version data entries
6 entries across 6 versions & 1 rubygems