public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
fix site template tests

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2214 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Sep 18 18:28:46 -0700 2006
commit  d9e22bd9d789e78151292649fbf93399fc7271ff
tree    b06a11a9563dc600eb5048e50f55574656348c2d
parent  dc4e8f4e6aa541cb24daeb3084e08ce15e8ae6b0
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
33
0
@@ -21,13 +21,13 @@ class AssetsControllerTest < Test::Unit::TestCase
0
 
0
   def test_should_find_css_by_full_path
0
     get :show, :path => 'style', :ext => 'css', :dir => 'stylesheets'
0
- assert_equal 'text/css', @response.headers['Content-Type']
0
+ assert_equal 'text/css', @response.content_type
0
     assert_equal sites(:first).resources['style.css'].read, @response.body
0
   end
0
 
0
   def test_should_find_js_by_full_path
0
     get :show, :path => 'behavior', :ext => 'js', :dir => 'javascripts'
0
- assert_equal 'text/javascript', @response.headers['Content-Type']
0
+ assert_equal Mime::JS, @response.content_type
0
     assert_equal sites(:first).resources['behavior.js'].read, @response.body
0
   end
0
 end
...
1
 
2
3
4
...
21
22
23
24
25
 
26
...
1
2
3
4
5
...
22
23
24
 
25
26
27
0
@@ -1,4 +1,5 @@
0
 require File.join(RAILS_ROOT, 'app/models/site')
0
+
0
 class Site
0
   attr_reader :recent_template_type, :recent_preferred_template, :recent_layout_template
0
 
0
@@ -21,4 +22,4 @@ class Site
0
   [:set_template_type_for, :set_preferred_template, :set_layout_template].each do |m|
0
     alias_method_chain m, :testing
0
   end
0
-end
0
\ No newline at end of file
0
+end unless Site.instance_methods.include?('set_template_type_for_with_testing')
0
\ No newline at end of file
...
166
167
168
169
 
170
171
172
...
178
179
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
182
...
166
167
168
 
169
170
171
172
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
0
@@ -166,7 +166,7 @@ context "Site Validations" do
0
 end
0
 
0
 context "Site Template" do
0
- fixtures :sites
0
+ fixtures :sites, :sections
0
 
0
   def setup
0
     prepare_theme_fixtures
0
@@ -178,4 +178,38 @@ context "Site Template" do
0
       sites(:first).send(:parse_template, sites(:first).templates[:archive], {}, {})
0
     end
0
   end
0
+
0
+ specify "should find preferred for site" do
0
+ assert_site_template_name :home, :section
0
+ end
0
+
0
+ specify "should find fallback for site with preferred template" do
0
+ FileUtils.rm File.join(THEME_ROOT, 'site-1', 'templates', 'home.liquid')
0
+ assert_site_template_name :section, :section
0
+ end
0
+
0
+ specify "should find preferred for site layout" do
0
+ FileUtils.cp File.join(THEME_ROOT, 'site-1', 'layouts', 'layout.liquid'), File.join(THEME_ROOT, 'site-1', 'layouts', 'custom_layout.liquid')
0
+ sites(:first).sections.home.update_attribute :layout, 'custom_layout'
0
+ assert_site_layout_name :custom_layout, :layout
0
+ end
0
+
0
+ specify "should find fallback for site with preferred layout" do
0
+ sites(:first).sections.home.update_attribute :layout, 'custom_layout'
0
+ assert_site_layout_name :layout
0
+ end
0
+
0
+ protected
0
+ def assert_site_template_name(expected_template_name, template_type = nil, options = {})
0
+ template_type ||= expected_template_name
0
+ site = options[:site] || sites(:first)
0
+ section = options[:section] || site.sections.home
0
+ assert_equal(expected_template_name.nil? ? nil : site.templates[expected_template_name], site.send(:set_preferred_template, section, template_type))
0
+ end
0
+ def assert_site_layout_name(expected_template_name, template_type = nil, options = {})
0
+ template_type ||= expected_template_name
0
+ site = options[:site] || sites(:first)
0
+ section = options[:section] || site.sections.home
0
+ assert_equal(expected_template_name.nil? ? nil : site.templates[expected_template_name], site.send(:set_layout_template, section, template_type))
0
+ end
0
 end
0
\ No newline at end of file
...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
73
74
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -73,45 +73,3 @@ context "Template" do
0
       assert_equal(expected_template_name.nil? ? nil : site.templates[expected_template_name], site.templates.find_preferred(template_type, options[:custom]))
0
     end
0
 end
0
-
0
-context "Site Template" do
0
- fixtures :sites, :sections
0
-
0
- def setup
0
- prepare_theme_fixtures
0
- end
0
-
0
- specify "should find preferred for site" do
0
- assert_site_template_name :home, :section
0
- end
0
-
0
- specify "should find fallback for site with preferred template" do
0
- FileUtils.rm File.join(THEME_ROOT, 'site-1', 'templates', 'home.liquid')
0
- assert_site_template_name :section, :section
0
- end
0
-
0
- specify "should find preferred for site layout" do
0
- FileUtils.cp File.join(THEME_ROOT, 'site-1', 'layouts', 'layout.liquid'), File.join(THEME_ROOT, 'site-1', 'layouts', 'custom_layout.liquid')
0
- sites(:first).sections.home.update_attribute :layout, 'custom_layout'
0
- assert_site_layout_name :custom_layout, :layout
0
- end
0
-
0
- specify "should find fallback for site with preferred layout" do
0
- sites(:first).sections.home.update_attribute :layout, 'custom_layout'
0
- assert_site_layout_name :layout
0
- end
0
-
0
- protected
0
- def assert_site_template_name(expected_template_name, template_type = nil, options = {})
0
- template_type ||= expected_template_name
0
- site = options[:site] || sites(:first)
0
- section = options[:section] || site.sections.home
0
- assert_equal(expected_template_name.nil? ? nil : site.templates[expected_template_name], site.send(:set_preferred_template, section, template_type))
0
- end
0
- def assert_site_layout_name(expected_template_name, template_type = nil, options = {})
0
- template_type ||= expected_template_name
0
- site = options[:site] || sites(:first)
0
- section = options[:section] || site.sections.home
0
- assert_equal(expected_template_name.nil? ? nil : site.templates[expected_template_name], site.send(:set_layout_template, section, template_type))
0
- end
0
-end

Comments

    No one has commented yet.