public
Fork of vigetlabs/crash_cart
Description: Tools to manage ExpressionEngine ... maybe.
Clone URL: git://github.com/reagent/crash_cart.git
Search Repo:
Don't save template files if no path is set
reagent (author)
Tue May 13 19:16:56 -0700 2008
commit  773be0dea30778578f5df47cd53f0c3a886fb8b9
tree    f828f0d217502ff83db8ae32fed6401fea24bd43
parent  0b531f46d2737cd019584988ae279916f0bd05e0
...
22
23
24
25
 
 
 
26
27
28
...
40
41
42
43
 
44
45
46
...
22
23
24
 
25
26
27
28
29
30
...
42
43
44
 
45
46
47
48
0
@@ -22,7 +22,9 @@
0
       end
0
 
0
       def save_template_file?
0
- read_attribute(:save_template_file) == 'y' ? true : false
0
+ save_file = read_attribute(:save_template_file) == 'y' ? true : false
0
+ save_file = save_file && !self.preferences[:tmpl_file_basepath].blank?
0
+ save_file
0
       end
0
       
0
       def name
0
@@ -40,7 +42,7 @@
0
       private
0
       def retrieve_file
0
         path = self.preferences[:tmpl_file_basepath]
0
- @file = ::ExpressionEngine::Files::Template.new(path, self)
0
+ @file = ::ExpressionEngine::Files::Template.new(path, self) unless path.blank?
0
       end
0
       
0
     end
...
2
3
4
5
 
6
7
8
9
10
11
12
13
14
 
 
15
16
 
17
18
 
 
 
 
 
 
 
 
19
20
21
22
...
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
29
 
 
30
31
32
33
34
35
...
51
52
53
54
 
 
 
 
55
56
57
 
58
59
60
61
62
63
 
 
64
65
66
 
67
68
69
...
2
3
4
 
5
6
 
 
 
 
 
 
 
 
7
8
9
 
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
...
67
68
69
 
70
71
72
73
74
75
 
76
77
78
79
80
 
 
81
82
83
84
85
86
87
88
89
0
@@ -2,20 +2,22 @@
0
 
0
 module ExpressionEngine::Models
0
 
0
- describe Template do
0
+ describe Template, "with no template path" do
0
     
0
- it "should have an associated file" do
0
- path = '/path/to/ee/root/templates'
0
- template_file = mock()
0
-
0
- ExpressionEngine::Files::Template.expects(:new).with(path, kind_of(Template)).returns(template_file)
0
-
0
- Template.any_instance.expects(:preferences).with(nil).returns({:tmpl_file_basepath => path})
0
-
0
+ it "should not have an associated file" do
0
+ Template.any_instance.expects(:preferences).returns({:tmpl_file_basepath => ''})
0
       t = Template.find(1)
0
- t.file.should == template_file
0
+ t.file.should be_nil
0
     end
0
     
0
+ it "should know not to save the associated file" do
0
+ t = Template.find(1)
0
+ t.expects(:read_attribute).with(:save_template_file).returns('y')
0
+ t.expects(:preferences).returns({:tmpl_file_basepath => ''})
0
+
0
+ t.save_template_file?.should == false
0
+ end
0
+
0
   end
0
 
0
   describe Template, "with an existing record" do
0
0
@@ -26,7 +28,21 @@
0
       @template.should be_an_instance_of(Template)
0
     end
0
     
0
+ it "should have an associated file" do
0
+ path = '/path/to/ee/root/templates'
0
+ template_file = mock()
0
+
0
+ ExpressionEngine::Files::Template.expects(:new).with(path, kind_of(Template)).returns(template_file)
0
+
0
+ Template.any_instance.expects(:preferences).with(nil).returns({:tmpl_file_basepath => path})
0
+
0
+ t = Template.find(1)
0
+ t.file.should == template_file
0
+ end
0
+
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
+
0
       @template.save_template_file = true
0
       @template.file.expects(:save).once
0
       @template.save_file
0
0
0
0
@@ -51,19 +67,23 @@
0
 
0
   describe Template, "with a new record" do
0
     
0
- before { @template = Template.new(:template_name => 'index')}
0
+ before do
0
+ @template = Template.new
0
+ @template.expects(:preferences).at_most_once.returns({:tmpl_file_basepath => '/test/path'})
0
+ end
0
     
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 = false
0
       @template.save_template_file?.should be_false
0
     end
0
 
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
     end
0
     
0
     it "should have a name" do
0
+ @template.template_name = 'index'
0
       @template.name.should == 'index'
0
     end
0
     

Comments

    No one has commented yet.