0
module ExpressionEngine::Models
0
+ describe Template
, "with no template path" do
0
- it "should have an associated file" do
0
- path = '/path/to/ee/root/templates'
0
- template_file = mock()
0
- ExpressionEngine::Files::Template.expects(:new).with(path, kind_of(Template)).returns(template_file)
0
- Template.any_instance.expects(:preferences).with(nil).returns({:tmpl_file_basepath => path})
0
+ it "should not have an associated file" do
0
+ Template.any_instance.expects(:preferences).returns({:tmpl_file_basepath => ''})
0
- t.file.should
== template_file0
+ it "should know not to save the associated file" do
0
+ t.expects(:read_attribute).with(:save_template_file).returns('y')
0
+ t.expects(:preferences).returns({:tmpl_file_basepath => ''})
0
+ t.save_template_file?.should == false
0
describe Template, "with an existing record" do
0
@template.should be_an_instance_of(Template)
0
+ it "should have an associated file" do
0
+ path = '/path/to/ee/root/templates'
0
+ template_file = mock()
0
+ ExpressionEngine::Files::Template.expects(:new).with(path, kind_of(Template)).returns(template_file)
0
+ Template.any_instance.expects(:preferences).with(nil).returns({:tmpl_file_basepath => path})
0
+ t.file.should == template_file
0
it "should save the associated file if it is configured to do so" do
0
+ @template.expects(:preferences).returns({:tmpl_file_basepath => '/test/path'})
0
@template.save_template_file = true
0
@template.file.expects(:save).once
0
describe Template, "with a new record" do
0
- before { @template = Template.new(:template_name => 'index')}
0
+ @template = Template.new
0
+ @template.expects(:preferences).at_most_once.returns({:tmpl_file_basepath => '/test/path'})
0
it "should know if it is saving a file to disk" do
0
-
t = Template.new(:save_template_file => false)0
+
@template.save_template_file = false0
@template.save_template_file?.should be_false
0
it "should be able to specify that it's saving a file to disk" do
0
- t = Template.new(:save_template_file => true)
0
- t.save_template_file?.should be_true
0
+ @template.save_template_file = true
0
+ @template.save_template_file?.should be_true
0
it "should have a name" do
0
+ @template.template_name = 'index'
0
@template.name.should == 'index'
Comments
No one has commented yet.