Sha256: 0bbf6bcfe32e26943ba42ced8118a1d5180ea58412fdd25d279cd4d52ce087b4
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
require File.join(File.dirname(__FILE__), '/../../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 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, PageTemplate.find_by_file_name("test.html.erb") assert_nil PageTemplate.find_by_file_name("fail.html.erb") assert_nil PageTemplate.find_by_file_name("fail.erb") assert_nil PageTemplate.find_by_file_name("fail") assert_nil PageTemplate.find_by_file_name(nil) end context "A Page Template instance" do setup do @page_template = Factory(:page_template) end should "be valid when required attributes are set" do assert_valid @page_template end end end
Version data entries
4 entries across 4 versions & 1 rubygems