radiant 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

Files changed (205) hide show
  1. data/CHANGELOG +1 -0
  2. data/CONTRIBUTORS +12 -0
  3. data/LICENSE +9 -0
  4. data/README +91 -0
  5. data/Rakefile +10 -0
  6. data/app/behaviors/archive_behavior.rb +42 -0
  7. data/app/behaviors/archive_day_index_behavior.rb +30 -0
  8. data/app/behaviors/archive_month_index_behavior.rb +30 -0
  9. data/app/behaviors/archive_year_index_behavior.rb +30 -0
  10. data/app/behaviors/env_behavior.rb +18 -0
  11. data/app/behaviors/page_missing_behavior.rb +31 -0
  12. data/app/controllers/admin/export_controller.rb +8 -0
  13. data/app/controllers/admin/layout_controller.rb +23 -0
  14. data/app/controllers/admin/model_controller.rb +119 -0
  15. data/app/controllers/admin/page_controller.rb +119 -0
  16. data/app/controllers/admin/snippet_controller.rb +6 -0
  17. data/app/controllers/admin/user_controller.rb +45 -0
  18. data/app/controllers/admin/welcome_controller.rb +39 -0
  19. data/app/controllers/application.rb +32 -0
  20. data/app/controllers/site_controller.rb +54 -0
  21. data/app/filters/markdown_filter.rb +9 -0
  22. data/app/filters/textile_filter.rb +9 -0
  23. data/app/helpers/admin/export_helper.rb +2 -0
  24. data/app/helpers/admin/layout_helper.rb +2 -0
  25. data/app/helpers/admin/page_helper.rb +10 -0
  26. data/app/helpers/admin/snippet_helper.rb +2 -0
  27. data/app/helpers/admin/user_helper.rb +2 -0
  28. data/app/helpers/admin/welcome_helper.rb +2 -0
  29. data/app/helpers/application_helper.rb +141 -0
  30. data/app/helpers/site_helper.rb +2 -0
  31. data/app/models/archive_finder.rb +66 -0
  32. data/app/models/behavior.rb +194 -0
  33. data/app/models/layout.rb +13 -0
  34. data/app/models/page.rb +91 -0
  35. data/app/models/page_context.rb +526 -0
  36. data/app/models/page_part.rb +13 -0
  37. data/app/models/radiant/config.rb +53 -0
  38. data/app/models/radiant/exporter.rb +11 -0
  39. data/app/models/response_cache.rb +112 -0
  40. data/app/models/snippet.rb +16 -0
  41. data/app/models/status.rb +31 -0
  42. data/app/models/text_filter.rb +11 -0
  43. data/app/models/user.rb +70 -0
  44. data/app/models/user_action_observer.rb +13 -0
  45. data/app/views/admin/layout/index.rhtml +38 -0
  46. data/app/views/admin/layout/new.rhtml +37 -0
  47. data/app/views/admin/layout/remove.rhtml +17 -0
  48. data/app/views/admin/page/_node.rhtml +51 -0
  49. data/app/views/admin/page/_part.rhtml +17 -0
  50. data/app/views/admin/page/children.rhtml +4 -0
  51. data/app/views/admin/page/index.rhtml +172 -0
  52. data/app/views/admin/page/new.rhtml +164 -0
  53. data/app/views/admin/page/remove.rhtml +14 -0
  54. data/app/views/admin/snippet/index.rhtml +36 -0
  55. data/app/views/admin/snippet/new.rhtml +28 -0
  56. data/app/views/admin/snippet/remove.rhtml +16 -0
  57. data/app/views/admin/user/index.rhtml +43 -0
  58. data/app/views/admin/user/new.rhtml +48 -0
  59. data/app/views/admin/user/preferences.rhtml +29 -0
  60. data/app/views/admin/user/remove.rhtml +16 -0
  61. data/app/views/admin/welcome/login.rhtml +51 -0
  62. data/app/views/layouts/application.rhtml +75 -0
  63. data/app/views/site/not_found.rhtml +3 -0
  64. data/bin/radiant +305 -0
  65. data/config/boot.rb +80 -0
  66. data/config/database.mysql.yml +20 -0
  67. data/config/database.postgresql.yml +20 -0
  68. data/config/database.sqlite.yml +20 -0
  69. data/config/environment.rb +76 -0
  70. data/config/environments/development.rb +20 -0
  71. data/config/environments/production.rb +22 -0
  72. data/config/environments/test.rb +20 -0
  73. data/config/locomotive.yml +6 -0
  74. data/config/routes.rb +64 -0
  75. data/db/development_structure.sql +80 -0
  76. data/db/migrate/001_create_radiant_tables.rb +73 -0
  77. data/db/migrate/002_insert_initial_data.rb +45 -0
  78. data/db/migrate/003_rename_behavior_column.rb +9 -0
  79. data/db/migrate/004_rename_filter_column.rb +11 -0
  80. data/db/migrate/005_add_virtual_column_to_page.rb +9 -0
  81. data/db/migrate/006_integer_columns_to_boolean.rb +11 -0
  82. data/db/migrate/007_remove_virtual_column_from_page.rb +9 -0
  83. data/db/migrate/008_add_virtual_column_to_page_again.rb +9 -0
  84. data/db/migrate/009_add_content_type_field_to_layout.rb +9 -0
  85. data/db/schema.rb +74 -0
  86. data/db/templates/empty.yml +2 -0
  87. data/db/templates/simple-blog.yml +197 -0
  88. data/db/templates/styled-blog.yml +472 -0
  89. data/lib/advanced_delegation.rb +21 -0
  90. data/lib/archive_index_behavior_tags_and_methods.rb +48 -0
  91. data/lib/generators/behavior/USAGE +16 -0
  92. data/lib/generators/behavior/behavior_generator.rb +22 -0
  93. data/lib/generators/behavior/templates/model.rb.template +9 -0
  94. data/lib/generators/behavior/templates/unit_test.rb.template +16 -0
  95. data/lib/generators/filter/USAGE +16 -0
  96. data/lib/generators/filter/filter_generator.rb +22 -0
  97. data/lib/generators/filter/templates/model.rb.template +8 -0
  98. data/lib/generators/filter/templates/unit_test.rb.template +7 -0
  99. data/lib/inheritable_class_attributes.rb +65 -0
  100. data/lib/login_system.rb +80 -0
  101. data/lib/plugins/index_quoting_fix/init.rb +32 -0
  102. data/lib/plugins/string_io/init.rb +2 -0
  103. data/lib/radiant.rb +5 -0
  104. data/lib/registerable.rb +70 -0
  105. data/lib/tasks/release.rake +84 -0
  106. data/public/404.html +8 -0
  107. data/public/500.html +8 -0
  108. data/public/dispatch.cgi +10 -0
  109. data/public/dispatch.fcgi +24 -0
  110. data/public/dispatch.rb +10 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/images/add-child.png +0 -0
  113. data/public/images/brown-bottom-line.gif +0 -0
  114. data/public/images/clear-page-cache.png +0 -0
  115. data/public/images/collapse.png +0 -0
  116. data/public/images/expand.png +0 -0
  117. data/public/images/minus.png +0 -0
  118. data/public/images/new-homepage.png +0 -0
  119. data/public/images/new-layout.png +0 -0
  120. data/public/images/new-snippet.png +0 -0
  121. data/public/images/new-user.png +0 -0
  122. data/public/images/page.png +0 -0
  123. data/public/images/plus.png +0 -0
  124. data/public/images/remove-disabled.png +0 -0
  125. data/public/images/remove.png +0 -0
  126. data/public/images/snippet.png +0 -0
  127. data/public/images/spinner.gif +0 -0
  128. data/public/images/view-site.gif +0 -0
  129. data/public/images/virtual-page.png +0 -0
  130. data/public/javascripts/application.js +2 -0
  131. data/public/javascripts/controls.js +815 -0
  132. data/public/javascripts/dragdrop.js +913 -0
  133. data/public/javascripts/effects.js +958 -0
  134. data/public/javascripts/pngfix.js +78 -0
  135. data/public/javascripts/prototype.js +2006 -0
  136. data/public/javascripts/ruledtable.js +28 -0
  137. data/public/javascripts/string.js +23 -0
  138. data/public/javascripts/tabcontrol.js +140 -0
  139. data/public/robots.txt +1 -0
  140. data/public/stylesheets/admin.css +464 -0
  141. data/script/about +3 -0
  142. data/script/breakpointer +3 -0
  143. data/script/console +3 -0
  144. data/script/destroy +3 -0
  145. data/script/generate +3 -0
  146. data/script/performance/benchmarker +3 -0
  147. data/script/performance/profiler +3 -0
  148. data/script/plugin +3 -0
  149. data/script/process/reaper +3 -0
  150. data/script/process/spawner +3 -0
  151. data/script/process/spinner +3 -0
  152. data/script/runner +3 -0
  153. data/script/server +3 -0
  154. data/script/setup_database +297 -0
  155. data/test/fixtures/layouts.yml +26 -0
  156. data/test/fixtures/page_parts.yml +99 -0
  157. data/test/fixtures/pages.yml +359 -0
  158. data/test/fixtures/pages.yml.rej +28 -0
  159. data/test/fixtures/snippets.yml +18 -0
  160. data/test/fixtures/users.yml +30 -0
  161. data/test/functional/admin/export_controller_test.rb +22 -0
  162. data/test/functional/admin/layout_controller_test.rb +40 -0
  163. data/test/functional/admin/model_controller_test.rb +152 -0
  164. data/test/functional/admin/page_controller_test.rb +179 -0
  165. data/test/functional/admin/snippet_controller_test.rb +11 -0
  166. data/test/functional/admin/user_controller_test.rb +71 -0
  167. data/test/functional/admin/welcome_controller_test.rb +48 -0
  168. data/test/functional/application_controller_test.rb +44 -0
  169. data/test/functional/login_system_test.rb +155 -0
  170. data/test/functional/site_controller_test.rb +172 -0
  171. data/test/helpers/archive_index_test_helper.rb +35 -0
  172. data/test/helpers/behavior_render_test_helper.rb +34 -0
  173. data/test/helpers/behavior_test_helper.rb +47 -0
  174. data/test/helpers/caching_test_helper.rb +41 -0
  175. data/test/helpers/layout_test_helper.rb +35 -0
  176. data/test/helpers/page_part_test_helper.rb +49 -0
  177. data/test/helpers/page_test_helper.rb +36 -0
  178. data/test/helpers/snippet_test_helper.rb +32 -0
  179. data/test/helpers/user_test_helper.rb +34 -0
  180. data/test/helpers/validation_test_helper.rb +42 -0
  181. data/test/test_helper.rb +54 -0
  182. data/test/unit/behavior_test.rb +196 -0
  183. data/test/unit/behaviors/archive_behavior_test.rb +33 -0
  184. data/test/unit/behaviors/archive_day_index_behavior_test.rb +21 -0
  185. data/test/unit/behaviors/archive_month_index_behavior_test.rb +21 -0
  186. data/test/unit/behaviors/archive_year_index_behavior_test.rb +21 -0
  187. data/test/unit/behaviors/page_missing_behavior_test.rb +27 -0
  188. data/test/unit/filters/markdown_filter_test.rb +14 -0
  189. data/test/unit/filters/textile_filter_test.rb +14 -0
  190. data/test/unit/inheritable_class_attributes_test.rb +47 -0
  191. data/test/unit/layout_test.rb +29 -0
  192. data/test/unit/page_context_test.rb +375 -0
  193. data/test/unit/page_context_test.rb.rej +26 -0
  194. data/test/unit/page_part_test.rb +44 -0
  195. data/test/unit/page_test.rb +224 -0
  196. data/test/unit/radiant/config_test.rb +46 -0
  197. data/test/unit/radiant/exporter_test.rb +26 -0
  198. data/test/unit/registerable_test.rb +68 -0
  199. data/test/unit/response_cache_test.rb +133 -0
  200. data/test/unit/snippet_test.rb +47 -0
  201. data/test/unit/status_test.rb +43 -0
  202. data/test/unit/text_filter_test.rb +14 -0
  203. data/test/unit/user_action_observer_test.rb +40 -0
  204. data/test/unit/user_test.rb +138 -0
  205. metadata +355 -0
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+ require 'admin/welcome_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class Admin::WelcomeController; def rescue_action(e) raise e end; end
6
+
7
+ class Admin::WelcomeControllerTest < Test::Unit::TestCase
8
+
9
+ fixtures :users
10
+
11
+ def setup
12
+ @controller = Admin::WelcomeController.new
13
+ @request = ActionController::TestRequest.new
14
+ @response = ActionController::TestResponse.new
15
+ end
16
+
17
+ def test_index
18
+ get :index
19
+ assert_redirected_to page_index_url
20
+ end
21
+
22
+ def test_login
23
+ get :login
24
+ assert_response :success
25
+ end
26
+ def test_login__post
27
+ post :login, :user => { :login => 'existing', :password => 'password' }
28
+ assert_redirected_to welcome_url
29
+
30
+ user = session[:user]
31
+ assert_kind_of User, user
32
+ assert_equal 'existing', user.login
33
+ end
34
+ def test_login__post_invalid_user
35
+ post :login, :user => { :login => 'invalid', :password => 'password' }
36
+ assert_response :success
37
+ assert_match /invalid/i, flash[:error]
38
+ assert_nil session[:user]
39
+ end
40
+
41
+ def test_logout
42
+ get :logout, nil, { :user => users(:existing) }
43
+ assert_redirected_to login_url
44
+ assert_nil session[:user]
45
+ assert_match /logged out/i, flash[:notice]
46
+ end
47
+
48
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'site_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class ApplicationController; def rescue_action(e) raise e end; end
6
+
7
+ class ApplicationControllerTest < Test::Unit::TestCase
8
+ fixtures :users
9
+
10
+ class TestController < ApplicationController
11
+ def test
12
+ render :text => 'test'
13
+ end
14
+ end
15
+
16
+ def setup
17
+ @controller = TestController.new
18
+ @request = ActionController::TestRequest.new
19
+ @response = ActionController::TestResponse.new
20
+ @user = users(:existing)
21
+ end
22
+
23
+ def test_ancestors
24
+ assert ApplicationController.include?(LoginSystem)
25
+ end
26
+
27
+ def test_initialize
28
+ assert_equal Radiant::Config, @controller.config
29
+ end
30
+
31
+ def test_default_parts
32
+ assert_equal ['body', 'extended'], @controller.default_parts
33
+ end
34
+
35
+ def test_before_filter
36
+ with_routing do |routes|
37
+ routes.map ':controller/:action'
38
+ UserActionObserver.current_user = nil
39
+ get :test, {}, { :user => @user }
40
+ assert_response :success
41
+ assert_equal @user, UserActionObserver.current_user
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,155 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class LoginSystemTest < Test::Unit::TestCase
4
+
5
+ fixtures :users
6
+
7
+ class StubController < ActionController::Base
8
+ def rescue_action(e)
9
+ raise e
10
+ end
11
+
12
+ def method_missing(method, *args, &block)
13
+ if (args.size == 0) and not block_given?
14
+ render :text => 'just a test'
15
+ else
16
+ super
17
+ end
18
+ end
19
+ end
20
+
21
+ class LoginRequiredController < StubController
22
+ include LoginSystem
23
+
24
+ attr_writer :condition
25
+
26
+ def condition?
27
+ @condition ||= false
28
+ end
29
+ end
30
+
31
+ class NoLoginRequiredController < LoginRequiredController
32
+ no_login_required
33
+ end
34
+
35
+ class OnlyAllowAccessToWhenController < LoginRequiredController
36
+ only_allow_access_to :edit, :new, :when => [:admin, :developer], :denied_url => { :action => :test }, :denied_message => 'Fun.'
37
+ end
38
+
39
+ class OnlyAllowAccessToWhenDefaultsController < LoginRequiredController
40
+ only_allow_access_to :edit, :when => :admin
41
+ end
42
+
43
+ class OnlyAllowAccessToIfController < LoginRequiredController
44
+ only_allow_access_to :edit, :if => :condition?
45
+ end
46
+
47
+ def setup
48
+ @controller = LoginRequiredController.new
49
+ @request = ActionController::TestRequest.new
50
+ @response = ActionController::TestResponse.new
51
+ end
52
+
53
+ def test_authenticate__with_user_in_session
54
+ custom_routes do
55
+ get :index, {}, { :user => users(:existing) }
56
+ assert_response :success
57
+ end
58
+ end
59
+ def test_authenticate__without_user_in_session
60
+ custom_routes do
61
+ get :index
62
+ assert_redirected_to login_url
63
+ end
64
+ end
65
+
66
+ # Class Methods
67
+
68
+ def test_no_login_required
69
+ custom_routes do
70
+ @controller = NoLoginRequiredController.new
71
+ get :index
72
+ assert_response :success
73
+ end
74
+ end
75
+
76
+ def test_only_allow_access_to__when_user_in_role
77
+ custom_routes do
78
+ @controller = OnlyAllowAccessToWhenController.new
79
+ get :edit, {}, { :user => users(:admin) }
80
+ assert_response :success
81
+ end
82
+ end
83
+ def test_only_allow_access_to__when_user_in_role_2
84
+ custom_routes do
85
+ @controller = OnlyAllowAccessToWhenController.new
86
+ get :new, {}, { :user => users(:developer) }
87
+ assert_response :success
88
+ end
89
+ end
90
+ def test_only_allow_access_to__when_user_in_role_3
91
+ custom_routes do
92
+ @controller = OnlyAllowAccessToWhenController.new
93
+ get :another, {}, { :user => users(:admin) }
94
+ assert_response :success
95
+ end
96
+ end
97
+ def test_only_allow_access_to__when_user_not_in_role
98
+ custom_routes do
99
+ @controller = OnlyAllowAccessToWhenController.new
100
+ get :edit, {}, { :user => users(:non_admin) }
101
+ assert_redirected_to :action => :test
102
+ assert_equal 'Fun.', flash[:error]
103
+ end
104
+ end
105
+ def test_only_allow_access_to__when_user_not_in_role_2
106
+ custom_routes do
107
+ @controller = OnlyAllowAccessToWhenController.new
108
+ get :new, {}, { :user => users(:non_admin) }
109
+ assert_redirected_to :action => :test
110
+ assert_equal 'Fun.', flash[:error]
111
+ end
112
+ end
113
+ def test_only_allow_access_to__when__user_not_in_role_3
114
+ custom_routes do
115
+ @controller = OnlyAllowAccessToWhenController.new
116
+ get :another, {}, { :user => users(:non_admin) }
117
+ assert_response :success
118
+ end
119
+ end
120
+ def test_only_allow_access_to__when__user_not_in_role__defaults
121
+ custom_routes do
122
+ @controller = OnlyAllowAccessToWhenDefaultsController.new
123
+ get :edit, {}, { :user => users(:non_admin) }
124
+ assert_redirected_to :action => :index
125
+ assert_equal 'Access denied.', flash[:error]
126
+ end
127
+ end
128
+
129
+ def test_only_allow_access_to__if__condition_true
130
+ custom_routes do
131
+ @controller = OnlyAllowAccessToIfController.new
132
+ @controller.condition = true
133
+ get :edit, {}, { :user => users(:existing) }
134
+ assert_response :success
135
+ end
136
+ end
137
+ def test_only_allow_access_to__if__condition_false
138
+ custom_routes do
139
+ @controller = OnlyAllowAccessToIfController.new
140
+ @controller.condition = false
141
+ get :edit, {}, { :user => users(:existing) }
142
+ assert_response :redirect
143
+ end
144
+ end
145
+
146
+ private
147
+
148
+ def custom_routes
149
+ with_routing do |set|
150
+ set.draw { set.connect ':controller/:action' }
151
+ yield
152
+ end
153
+ end
154
+
155
+ end
@@ -0,0 +1,172 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'site_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class SiteController; def rescue_action(e) raise e end; end
6
+
7
+ class SiteControllerTest < Test::Unit::TestCase
8
+ fixtures :pages, :page_parts
9
+ test_helper :behavior
10
+
11
+ def setup
12
+ @controller = SiteController.new
13
+ @request = ActionController::TestRequest.new
14
+ @response = ActionController::TestResponse.new
15
+ @cache = @controller.cache
16
+ @cache.perform_caching = false
17
+ @cache.clear
18
+ end
19
+
20
+ def test_initialize
21
+ assert_equal Radiant::Config, @controller.config
22
+ assert_kind_of ResponseCache, @cache
23
+ end
24
+
25
+ def test_show_page__home_page
26
+ get :show_page, :url => ''
27
+ assert_response :success
28
+ assert_equal 'This is the body portion of the Ruby home page.', @response.body
29
+ end
30
+
31
+ def test_show_page__one_level_deep
32
+ get :show_page, :url => 'documentation/'
33
+ assert :success
34
+ assert_equal 'This is the documentation section.', @response.body
35
+ end
36
+
37
+ def test_show_page__two_levels_deep
38
+ get :show_page, :url => 'documentation/books/'
39
+ assert_response :success
40
+ assert_equal 'This is the books page.', @response.body
41
+ end
42
+
43
+ def test_show_page__not_found
44
+ get :show_page, :url => 'asdf'
45
+ assert_response :missing
46
+ assert_template 'site/not_found'
47
+ end
48
+
49
+ def test_show_page__missing_root_redirects_to_admin
50
+ pages(:homepage).destroy
51
+ get :show_page, :url => '/'
52
+ assert_redirected_to :controller => 'admin/welcome'
53
+ end
54
+
55
+ def test_show_page__radius_integration
56
+ get :show_page, :url => 'radius'
57
+ assert_response :success
58
+ assert_equal "<h1>Radius Test Page</h1>\n\n\n\t<ul>\n\t<li>Radius Test Child 1</li>\n\t\t<li>Radius Test Child 2</li>\n\t\t<li>Radius Test Child 3</li>\n\t</ul>", @response.body
59
+ end
60
+
61
+ def test_show_page__not_published
62
+ ['draft', 'hidden'].each do |url|
63
+ get :show_page, :url => url
64
+ assert_response :missing, "for URL: #{url}"
65
+ assert_template 'site/not_found', "for URL: #{url}"
66
+ end
67
+
68
+ #validates the custom 404 page is rendered
69
+ get :show_page, :url => "/gallery/gallery_draft/"
70
+ assert_response :missing
71
+ assert_template nil
72
+ end
73
+
74
+ def test_show_page__not_published__on_dev_site
75
+ @request.host = 'devsite.com'
76
+ ['draft', 'hidden'].each do |url|
77
+ get :show_page, :url => url
78
+ assert_response :success, "for URL: #{url}"
79
+ end
80
+ end
81
+
82
+ def test_show_page__not_published__on_dev_site_in_conf
83
+ @controller.config = { 'dev.host' => 'mydevsite.com' }
84
+ @request.host = 'mydevsite.com'
85
+ ['draft', 'hidden'].each do |url|
86
+ get :show_page, :url => url
87
+ assert_response :success, "for URL: #{url}"
88
+ end
89
+ end
90
+
91
+ def test_show_page__does_not_have_no_cache_header
92
+ get :show_page, :url => '/'
93
+ assert_equal false, @response.headers.keys.include?('Cache-Control')
94
+ end
95
+
96
+ class TestPage
97
+ def request
98
+ @request
99
+ end
100
+ def response
101
+ @response
102
+ end
103
+ def process(request, response)
104
+ @request, @response = request, response
105
+ response.headers['Status'] = '200 OK'
106
+ end
107
+ def cache?
108
+ true
109
+ end
110
+ end
111
+
112
+ def test_show_page__page_processed
113
+ class << @controller
114
+ def find_page(url)
115
+ SiteControllerTest::TestPage.new
116
+ end
117
+ end
118
+ get :show_page, :url => 'really/just/a/test'
119
+ assert_response :success
120
+ page = assigns(:page)
121
+ assert_same @request, page.request
122
+ assert_same @response, page.response
123
+ end
124
+
125
+ def test_show_page__cached
126
+ @controller.cache.perform_caching = true
127
+ @cache.clear
128
+ get :show_page, :url => 'documentation'
129
+ assert_response :success
130
+ assert File.exists?(cache_file('documentation'))
131
+ end
132
+
133
+ def test_show_page__no_cache
134
+ @controller.cache.perform_caching = true
135
+ @cache.clear
136
+ get :show_page, :url => 'no-cache'
137
+ assert_response :success
138
+ assert !File.exists?(cache_file('no-cache'))
139
+ end
140
+
141
+ def test_show_page__no_cache_on_dev_site
142
+ @controller.cache.perform_caching = true
143
+ @request.host = 'devsite.com'
144
+ @cache.clear
145
+ get :show_page, :url => 'documentation'
146
+ assert_response :success
147
+ assert !File.exists?(cache_file('documentation'))
148
+ end
149
+
150
+ def test_show_page__no_cache_on_dev_site__cached
151
+ @controller.cache.perform_caching = true
152
+ @request.host = 'devsite.com'
153
+ @cache.cache_response('documentation', response(:body => 'expired body'))
154
+ get :show_page, :url => 'documentation'
155
+ assert_response :success
156
+ assert_equal 'This is the documentation section.', @response.body
157
+ end
158
+
159
+ private
160
+
161
+ def cache_file(path)
162
+ "#{@cache.directory}/#{path}.yml"
163
+ end
164
+
165
+ def response(options = {})
166
+ r = ActionController::TestResponse.new
167
+ options.each do |k, v|
168
+ r.send("#{k}=", v)
169
+ end
170
+ r
171
+ end
172
+ end
@@ -0,0 +1,35 @@
1
+ module ArchiveIndexTestHelper
2
+ module ArchiveIndexTests
3
+ def test_page_virtual?
4
+ assert_equal true, @page.virtual?
5
+ end
6
+
7
+ def test_first_tag__index
8
+ assert_renders 'unimplemented', '<r:archive:children:first><r:slug /></r:archive:children:first>'
9
+ end
10
+
11
+ def test_last_tag__index
12
+ assert_renders 'unimplemented', '<r:archive:children:last><r:slug /></r:archive:children:last>'
13
+ end
14
+
15
+ def test_count_tag__index
16
+ assert_renders 'unimplemented', '<r:archive:children:count />'
17
+ end
18
+
19
+ def test_year_tag
20
+ assert_renders '2000', '<r:archive:year />', '/archive/2000/'
21
+ end
22
+
23
+ def test_month_tag
24
+ assert_renders 'June', '<r:archive:month />', '/archive/2000/06/'
25
+ end
26
+
27
+ def test_day_tag
28
+ assert_renders '9', '<r:archive:day />', '/archive/2000/06/09/'
29
+ end
30
+
31
+ def test_day_of_week_tag
32
+ assert_renders 'Friday', '<r:archive:day_of_week />', '/archive/2000/06/09/'
33
+ end
34
+ end
35
+ end