deluxe_publisher 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +29 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +127 -0
  6. data/Rakefile +61 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/deluxe_publisher/comments_controller.rb +93 -0
  9. data/app/controllers/deluxe_publisher/page_types_controller.rb +115 -0
  10. data/app/controllers/deluxe_publisher/pages_controller.rb +191 -0
  11. data/app/controllers/deluxe_publisher/presenter_controller.rb +185 -0
  12. data/app/controllers/deluxe_publisher/redirects_controller.rb +90 -0
  13. data/app/controllers/deluxe_publisher/sitemap_controller.rb +10 -0
  14. data/app/helpers/application_helper.rb +2 -0
  15. data/app/helpers/deluxe_publisher/comments_helper.rb +2 -0
  16. data/app/helpers/deluxe_publisher/page_types_helper.rb +13 -0
  17. data/app/helpers/deluxe_publisher/pages_helper.rb +41 -0
  18. data/app/helpers/deluxe_publisher/presenter_helper.rb +111 -0
  19. data/app/helpers/deluxe_publisher/redirects_helper.rb +2 -0
  20. data/app/helpers/deluxe_publisher/sitemap_helper.rb +2 -0
  21. data/app/models/ckeditor/asset.rb +88 -0
  22. data/app/models/ckeditor/attachment_file.rb +40 -0
  23. data/app/models/ckeditor/picture.rb +23 -0
  24. data/app/models/deluxe_publisher/comment.rb +6 -0
  25. data/app/models/deluxe_publisher/content.rb +6 -0
  26. data/app/models/deluxe_publisher/content_descriptor.rb +4 -0
  27. data/app/models/deluxe_publisher/page.rb +206 -0
  28. data/app/models/deluxe_publisher/page_type.rb +55 -0
  29. data/app/models/deluxe_publisher/redirect.rb +6 -0
  30. data/app/models/deluxe_publisher.rb +5 -0
  31. data/app/views/deluxe_publisher/comments/_form.html.erb +31 -0
  32. data/app/views/deluxe_publisher/comments/edit.html.erb +6 -0
  33. data/app/views/deluxe_publisher/comments/index.html.erb +31 -0
  34. data/app/views/deluxe_publisher/comments/new.html.erb +6 -0
  35. data/app/views/deluxe_publisher/comments/show.html.erb +30 -0
  36. data/app/views/deluxe_publisher/page_types/_content_descriptors.html.erb +15 -0
  37. data/app/views/deluxe_publisher/page_types/_form.html.erb +59 -0
  38. data/app/views/deluxe_publisher/page_types/content_areas_change.js.erb +3 -0
  39. data/app/views/deluxe_publisher/page_types/edit.html.erb +8 -0
  40. data/app/views/deluxe_publisher/page_types/index.html.erb +29 -0
  41. data/app/views/deluxe_publisher/page_types/new.html.erb +7 -0
  42. data/app/views/deluxe_publisher/page_types/show.html.erb +45 -0
  43. data/app/views/deluxe_publisher/pages/_form.html.erb +39 -0
  44. data/app/views/deluxe_publisher/pages/_general.html.erb +108 -0
  45. data/app/views/deluxe_publisher/pages/_page.html.erb +23 -0
  46. data/app/views/deluxe_publisher/pages/_page_content.html.erb +16 -0
  47. data/app/views/deluxe_publisher/pages/_page_links.html.erb +9 -0
  48. data/app/views/deluxe_publisher/pages/_seo.html.erb +27 -0
  49. data/app/views/deluxe_publisher/pages/edit.html.erb +5 -0
  50. data/app/views/deluxe_publisher/pages/index.html.erb +11 -0
  51. data/app/views/deluxe_publisher/pages/new.html.erb +6 -0
  52. data/app/views/deluxe_publisher/pages/page_type_change.js.erb +3 -0
  53. data/app/views/deluxe_publisher/pages/show.html.erb +115 -0
  54. data/app/views/deluxe_publisher/presenter/create_comment.js.erb +3 -0
  55. data/app/views/deluxe_publisher/presenter/create_comment_failed.js.erb +1 -0
  56. data/app/views/deluxe_publisher/presenter/new_comment.js.erb +7 -0
  57. data/app/views/deluxe_publisher/presenter/preview.html.erb +2 -0
  58. data/app/views/deluxe_publisher/redirects/_form.html.erb +29 -0
  59. data/app/views/deluxe_publisher/redirects/edit.html.erb +6 -0
  60. data/app/views/deluxe_publisher/redirects/index.html.erb +27 -0
  61. data/app/views/deluxe_publisher/redirects/new.html.erb +5 -0
  62. data/app/views/deluxe_publisher/redirects/show.html.erb +20 -0
  63. data/app/views/deluxe_publisher/sitemap/index.xml.builder +12 -0
  64. data/app/views/deluxe_publisher/templates/simple_blog.html.erb +19 -0
  65. data/app/views/deluxe_publisher/templates/simple_blog.rss.builder +23 -0
  66. data/app/views/deluxe_publisher/templates/simple_blog_story.html.erb +9 -0
  67. data/app/views/deluxe_publisher/templates/simple_page.html.erb +4 -0
  68. data/app/views/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
  69. data/app/views/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
  70. data/app/views/layouts/application.html.erb +14 -0
  71. data/app/views/layouts/deluxe_publisher.html.erb +36 -0
  72. data/app/views/layouts/deluxe_publisher_blog.html.erb +63 -0
  73. data/app/views/layouts/deluxe_publisher_simple.html.erb +30 -0
  74. data/config/routes.rb +49 -0
  75. data/deluxe_publisher.gemspec +466 -0
  76. data/lib/deluxe_publisher/deluxe_publisher_authentication.rb +37 -0
  77. data/lib/deluxe_publisher/engine.rb +5 -0
  78. data/lib/deluxe_publisher.rb +40 -0
  79. data/lib/generators/deluxe_publisher/base/USAGE +8 -0
  80. data/lib/generators/deluxe_publisher/base/base_generator.rb +45 -0
  81. data/lib/generators/deluxe_publisher/base/templates/images/add.png +0 -0
  82. data/lib/generators/deluxe_publisher/base/templates/images/btn_addNewPage.gif +0 -0
  83. data/lib/generators/deluxe_publisher/base/templates/images/btn_cancel.gif +0 -0
  84. data/lib/generators/deluxe_publisher/base/templates/images/btn_preview.gif +0 -0
  85. data/lib/generators/deluxe_publisher/base/templates/images/btn_save.gif +0 -0
  86. data/lib/generators/deluxe_publisher/base/templates/images/bullet.gif +0 -0
  87. data/lib/generators/deluxe_publisher/base/templates/images/content_bg.jpg +0 -0
  88. data/lib/generators/deluxe_publisher/base/templates/images/delete.png +0 -0
  89. data/lib/generators/deluxe_publisher/base/templates/images/edit.png +0 -0
  90. data/lib/generators/deluxe_publisher/base/templates/images/header_background.jpg +0 -0
  91. data/lib/generators/deluxe_publisher/base/templates/images/icon_published.gif +0 -0
  92. data/lib/generators/deluxe_publisher/base/templates/images/icon_unpublished.gif +0 -0
  93. data/lib/generators/deluxe_publisher/base/templates/images/logo.gif +0 -0
  94. data/lib/generators/deluxe_publisher/base/templates/images/minus.gif +0 -0
  95. data/lib/generators/deluxe_publisher/base/templates/images/plus.gif +0 -0
  96. data/lib/generators/deluxe_publisher/base/templates/images/show.png +0 -0
  97. data/lib/generators/deluxe_publisher/base/templates/images/tab_bg.gif +0 -0
  98. data/lib/generators/deluxe_publisher/base/templates/images/tabs_bg.jpg +0 -0
  99. data/lib/generators/deluxe_publisher/base/templates/initializer.rb +23 -0
  100. data/lib/generators/deluxe_publisher/base/templates/javascripts/deluxe_presenter.js +25 -0
  101. data/lib/generators/deluxe_publisher/base/templates/javascripts/deluxe_publisher.js +86 -0
  102. data/lib/generators/deluxe_publisher/base/templates/javascripts/jquery-rails.js +158 -0
  103. data/lib/generators/deluxe_publisher/base/templates/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
  104. data/lib/generators/deluxe_publisher/base/templates/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
  105. data/lib/generators/deluxe_publisher/base/templates/layouts/deluxe_publisher_blog.html.erb +74 -0
  106. data/lib/generators/deluxe_publisher/base/templates/layouts/deluxe_publisher_simple.html.erb +47 -0
  107. data/lib/generators/deluxe_publisher/base/templates/stylesheets/deluxe_presenter.css +458 -0
  108. data/lib/generators/deluxe_publisher/base/templates/stylesheets/deluxe_publisher.css +202 -0
  109. data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog.html.erb +19 -0
  110. data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog.rss.builder +23 -0
  111. data/lib/generators/deluxe_publisher/base/templates/templates/simple_blog_story.html.erb +12 -0
  112. data/lib/generators/deluxe_publisher/base/templates/templates/simple_page.html.erb +4 -0
  113. data/lib/generators/deluxe_publisher/migration/USAGE +0 -0
  114. data/lib/generators/deluxe_publisher/migration/migration_generator.rb +18 -0
  115. data/lib/generators/deluxe_publisher/migration/templates/migration.rb +98 -0
  116. data/lib/generators/deluxe_publisher/sample_site/sample_site_generator.rb +316 -0
  117. data/spec/controllers/deluxe_publisher/comments_controller_spec.rb +129 -0
  118. data/spec/controllers/deluxe_publisher/page_types_controller_spec.rb +125 -0
  119. data/spec/controllers/deluxe_publisher/pages_controller_spec.rb +129 -0
  120. data/spec/controllers/deluxe_publisher/presenter_controller_spec.rb +19 -0
  121. data/spec/controllers/deluxe_publisher/redirects_controller_spec.rb +118 -0
  122. data/spec/deluxe_publisher_spec.rb +7 -0
  123. data/spec/dummy/Rakefile +7 -0
  124. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  125. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  126. data/spec/dummy/app/views/deluxe_publisher/comments/_form.html.erb +31 -0
  127. data/spec/dummy/app/views/deluxe_publisher/comments/edit.html.erb +6 -0
  128. data/spec/dummy/app/views/deluxe_publisher/comments/index.html.erb +31 -0
  129. data/spec/dummy/app/views/deluxe_publisher/comments/new.html.erb +6 -0
  130. data/spec/dummy/app/views/deluxe_publisher/comments/show.html.erb +30 -0
  131. data/spec/dummy/app/views/deluxe_publisher/page_types/_content_descriptors.html.erb +15 -0
  132. data/spec/dummy/app/views/deluxe_publisher/page_types/_form.html.erb +59 -0
  133. data/spec/dummy/app/views/deluxe_publisher/page_types/content_areas_change.js.erb +3 -0
  134. data/spec/dummy/app/views/deluxe_publisher/page_types/edit.html.erb +8 -0
  135. data/spec/dummy/app/views/deluxe_publisher/page_types/index.html.erb +29 -0
  136. data/spec/dummy/app/views/deluxe_publisher/page_types/new.html.erb +7 -0
  137. data/spec/dummy/app/views/deluxe_publisher/page_types/show.html.erb +45 -0
  138. data/spec/dummy/app/views/deluxe_publisher/pages/_form.html.erb +36 -0
  139. data/spec/dummy/app/views/deluxe_publisher/pages/_general.html.erb +108 -0
  140. data/spec/dummy/app/views/deluxe_publisher/pages/_page.html.erb +23 -0
  141. data/spec/dummy/app/views/deluxe_publisher/pages/_page_content.html.erb +16 -0
  142. data/spec/dummy/app/views/deluxe_publisher/pages/_page_links.html.erb +9 -0
  143. data/spec/dummy/app/views/deluxe_publisher/pages/_seo.html.erb +27 -0
  144. data/spec/dummy/app/views/deluxe_publisher/pages/edit.html.erb +7 -0
  145. data/spec/dummy/app/views/deluxe_publisher/pages/index.html.erb +10 -0
  146. data/spec/dummy/app/views/deluxe_publisher/pages/new.html.erb +7 -0
  147. data/spec/dummy/app/views/deluxe_publisher/pages/page_type_change.js.erb +3 -0
  148. data/spec/dummy/app/views/deluxe_publisher/pages/show.html.erb +115 -0
  149. data/spec/dummy/app/views/deluxe_publisher/presenter/create_comment.js.erb +3 -0
  150. data/spec/dummy/app/views/deluxe_publisher/presenter/create_comment_failed.js.erb +1 -0
  151. data/spec/dummy/app/views/deluxe_publisher/presenter/new_comment.js.erb +7 -0
  152. data/spec/dummy/app/views/deluxe_publisher/presenter/preview.html.erb +2 -0
  153. data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog.html.erb +19 -0
  154. data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog.rss.builder +23 -0
  155. data/spec/dummy/app/views/deluxe_publisher/templates/simple_blog_story.html.erb +9 -0
  156. data/spec/dummy/app/views/deluxe_publisher/templates/simple_page.html.erb +4 -0
  157. data/spec/dummy/app/views/layouts/_deluxe_publisher_comment_form.html.erb +29 -0
  158. data/spec/dummy/app/views/layouts/_deluxe_publisher_comments_list.html.erb +8 -0
  159. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  160. data/spec/dummy/app/views/layouts/deluxe_publisher.html.erb +31 -0
  161. data/spec/dummy/app/views/layouts/deluxe_publisher_blog.html.erb +63 -0
  162. data/spec/dummy/app/views/layouts/deluxe_publisher_simple.html.erb +30 -0
  163. data/spec/dummy/config/application.rb +45 -0
  164. data/spec/dummy/config/boot.rb +10 -0
  165. data/spec/dummy/config/database.yml +22 -0
  166. data/spec/dummy/config/environment.rb +5 -0
  167. data/spec/dummy/config/environments/development.rb +26 -0
  168. data/spec/dummy/config/environments/production.rb +49 -0
  169. data/spec/dummy/config/environments/test.rb +35 -0
  170. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  171. data/spec/dummy/config/initializers/deluxe_publisher.rb +23 -0
  172. data/spec/dummy/config/initializers/inflections.rb +10 -0
  173. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  174. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  175. data/spec/dummy/config/initializers/session_store.rb +8 -0
  176. data/spec/dummy/config/locales/en.yml +5 -0
  177. data/spec/dummy/config/routes.rb +104 -0
  178. data/spec/dummy/config.ru +4 -0
  179. data/spec/dummy/db/migrate/20110405190943_create_deluxe_publisher.rb +135 -0
  180. data/spec/dummy/db/schema.rb +130 -0
  181. data/spec/dummy/public/404.html +26 -0
  182. data/spec/dummy/public/422.html +26 -0
  183. data/spec/dummy/public/500.html +26 -0
  184. data/spec/dummy/public/favicon.ico +0 -0
  185. data/spec/dummy/public/javascripts/application.js +2 -0
  186. data/spec/dummy/public/javascripts/controls.js +965 -0
  187. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  188. data/spec/dummy/public/javascripts/effects.js +1123 -0
  189. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  190. data/spec/dummy/public/javascripts/rails.js +191 -0
  191. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  192. data/spec/dummy/script/rails +6 -0
  193. data/spec/factories/comment_factory.rb +4 -0
  194. data/spec/factories/content_descriptor_factory.rb +5 -0
  195. data/spec/factories/content_factory.rb +24 -0
  196. data/spec/factories/page_factory.rb +26 -0
  197. data/spec/factories/page_type_factory.rb +10 -0
  198. data/spec/factories/redirect_factory.rb +4 -0
  199. data/spec/helpers/deluxe_publisher/comments_helper_spec.rb +15 -0
  200. data/spec/helpers/deluxe_publisher/page_types_helper_spec.rb +26 -0
  201. data/spec/helpers/deluxe_publisher/pages_helper_spec.rb +65 -0
  202. data/spec/helpers/deluxe_publisher/presenter_helper_spec.rb +19 -0
  203. data/spec/helpers/deluxe_publisher/redirects_helper_spec.rb +15 -0
  204. data/spec/integration/navigation_spec.rb +9 -0
  205. data/spec/models/deluxe_publisher/comment_spec.rb +5 -0
  206. data/spec/models/deluxe_publisher/content_descriptor_spec.rb +5 -0
  207. data/spec/models/deluxe_publisher/content_spec.rb +5 -0
  208. data/spec/models/deluxe_publisher/page_spec.rb +358 -0
  209. data/spec/models/deluxe_publisher/page_type_spec.rb +62 -0
  210. data/spec/models/deluxe_publisher/redirect_spec.rb +17 -0
  211. data/spec/requests/deluxe_publisher/deluxe_publisher_comments_spec.rb +11 -0
  212. data/spec/requests/deluxe_publisher/deluxe_publisher_page_types_spec.rb +11 -0
  213. data/spec/requests/deluxe_publisher/deluxe_publisher_redirects_spec.rb +11 -0
  214. data/spec/requests/deluxe_publisher/pages_spec.rb +11 -0
  215. data/spec/routing/deluxe_publisher/comments_routing_spec.rb +35 -0
  216. data/spec/routing/deluxe_publisher/page_types_routing_spec.rb +47 -0
  217. data/spec/routing/deluxe_publisher/pages_routing_spec.rb +47 -0
  218. data/spec/routing/deluxe_publisher/presenter_routing_spec.rb +66 -0
  219. data/spec/routing/deluxe_publisher/redirects_routing_spec.rb +35 -0
  220. data/spec/spec_helper.rb +234 -0
  221. data/spec/views/deluxe_publisher/comments/edit.html.erb_spec.rb +24 -0
  222. data/spec/views/deluxe_publisher/comments/index.html.erb_spec.rb +32 -0
  223. data/spec/views/deluxe_publisher/comments/new.html.erb_spec.rb +24 -0
  224. data/spec/views/deluxe_publisher/comments/show.html.erb_spec.rb +24 -0
  225. data/spec/views/deluxe_publisher/page_types/edit.html.erb_spec.rb +32 -0
  226. data/spec/views/deluxe_publisher/page_types/index.html.erb_spec.rb +48 -0
  227. data/spec/views/deluxe_publisher/page_types/new.html.erb_spec.rb +32 -0
  228. data/spec/views/deluxe_publisher/page_types/show.html.erb_spec.rb +36 -0
  229. data/spec/views/deluxe_publisher/pages/edit.html.erb_spec.rb +58 -0
  230. data/spec/views/deluxe_publisher/pages/index.html.erb_spec.rb +100 -0
  231. data/spec/views/deluxe_publisher/pages/new.html.erb_spec.rb +81 -0
  232. data/spec/views/deluxe_publisher/pages/show.html.erb_spec.rb +75 -0
  233. data/spec/views/deluxe_publisher/presenter/present.html.erb_spec.rb +5 -0
  234. data/spec/views/deluxe_publisher/presenter/preview.html.erb_spec.rb +5 -0
  235. data/spec/views/deluxe_publisher/redirects/edit.html.erb_spec.rb +22 -0
  236. data/spec/views/deluxe_publisher/redirects/index.html.erb_spec.rb +28 -0
  237. data/spec/views/deluxe_publisher/redirects/new.html.erb_spec.rb +22 -0
  238. data/spec/views/deluxe_publisher/redirects/show.html.erb_spec.rb +21 -0
  239. metadata +1006 -0
@@ -0,0 +1,358 @@
1
+ require 'spec_helper'
2
+
3
+ describe DeluxePublisher::Page do
4
+ include AwesomeCo
5
+
6
+
7
+
8
+
9
+ describe "Facotry" do
10
+ it "should be valid by default" do
11
+ Factory(:page).should be_valid
12
+ end
13
+ end
14
+
15
+ [:site_id, :parent_id, :position, :footer_position, :page_type_id,
16
+ :browser_title, :page_title, :menu_title, :file_name].each do |required_field|
17
+
18
+ it "should not be valid if missing required field #{required_field}" do
19
+ Factory.build(:page, required_field => nil).should_not be_valid
20
+ end
21
+
22
+ it "should be valid with out required field #{required_field} if its a root page" do
23
+ Factory.build(:page, required_field => nil, :parent_id => nil).should_not be_valid
24
+ end
25
+ end
26
+
27
+ describe "is_a_blog?" do
28
+ it "should be true if the page's page type functions as a blog page" do
29
+ page_type = Factory(:page_type, :function_as => "blog_page")
30
+ Factory(:page, :page_type => page_type).is_a_blog?.should be true
31
+ end
32
+ end
33
+
34
+ describe "is_a_blog_story?" do
35
+ it "should be true if the page's page type functions as a blog story" do
36
+ page_type = Factory(:page_type, :function_as => "blog_story")
37
+ Factory(:page, :page_type => page_type).is_a_blog_story?.should be true
38
+ end
39
+ end
40
+
41
+
42
+ describe "child_of_a_blog?" do
43
+ it "should return true if the page's parent functions as a blog" do
44
+
45
+ page_type = Factory(:page_type, :function_as => "blog_page")
46
+ parent = Factory(:page, :page_type => page_type)
47
+ Factory(:page, :parent => parent).should be_a_child_of_a_blog
48
+ end
49
+
50
+ it "should return false if the page's parent is root" do
51
+
52
+
53
+ parent = DeluxePublisher::Page.get_site_root(1)
54
+ Factory(:page, :parent => parent).should_not be_a_child_of_a_blog
55
+ end
56
+ end
57
+
58
+ describe "blog_stories" do
59
+ before(:all) do
60
+ @blog_page_type = Factory(:page_type, :function_as => "blog_page")
61
+ @story_page_type = Factory(:page_type, :function_as => "blog_story")
62
+
63
+ @blog = Factory(:page, :page_type => @blog_page_type, :parent => DeluxePublisher::Page.get_site_root(100))
64
+ @stories = []
65
+
66
+ @stories << Factory(:page,
67
+ :page_type => @story_page_type, :parent => @blog,
68
+ :publish_at => DateTime.new(2001,1,1,8,30),
69
+ :is_published => true)
70
+
71
+ @stories << Factory(:page,
72
+ :page_type => @story_page_type, :parent => @blog,
73
+ :publish_at => DateTime.new(2001,1,4,8,30),
74
+ :is_published => true)
75
+
76
+ @stories << Factory(:page,
77
+ :page_type => @story_page_type, :parent => @blog,
78
+ :publish_at => DateTime.new(2001,1,6,8,30),
79
+ :is_published => true)
80
+
81
+ @stories << Factory(:page,
82
+ :page_type => @story_page_type, :parent => @blog,
83
+ :publish_at => DateTime.new(2001,1,14,8,30),
84
+ :is_published => true)
85
+
86
+ @stories << Factory(:page,
87
+ :page_type => @story_page_type, :parent => @blog,
88
+ :publish_at => DateTime.new(2001,1,14,8,30),
89
+ :is_published => true)
90
+ @stories << Factory(:page,
91
+ :page_type => @story_page_type, :parent => @blog,
92
+ :publish_at => DateTime.new(2001,1,20,8,30),
93
+ :is_published => true)
94
+ @stories << Factory(:page,
95
+ :page_type => @story_page_type, :parent => @blog,
96
+ :publish_at => DateTime.new(2001,2,6,8,30),
97
+ :is_published => true)
98
+
99
+ @stories << Factory(:page,
100
+ :page_type => @story_page_type, :parent => @blog,
101
+ :publish_at => DateTime.new(2001,2,17,8,30),
102
+ :is_published => true)
103
+
104
+ @stories << Factory(:page,
105
+ :page_type => @story_page_type, :parent => @blog,
106
+ :publish_at => DateTime.new(2001,3,21,8,30),
107
+ :is_published => true)
108
+
109
+ @stories << Factory(:page,
110
+ :page_type => @story_page_type, :parent => @blog,
111
+ :publish_at => DateTime.new(2002,3,14,8,30),
112
+ :is_published => true)
113
+
114
+ @stories << Factory(:page,
115
+ :page_type => @story_page_type, :parent => @blog,
116
+ :publish_at => DateTime.new(2002,4,19,8,30),
117
+ :is_published => true)
118
+ @stories << Factory(:page,
119
+ :page_type => @story_page_type, :parent => @blog,
120
+ :publish_at => DateTime.new(2002,4,21,8,30),
121
+ :is_published => true)
122
+ end
123
+
124
+
125
+ after(:all) do
126
+ @blog_page_type.destroy
127
+ @story_page_type.destroy
128
+ @blog.destroy
129
+ @stories.each do |story|
130
+ story.destroy
131
+ end
132
+ end
133
+
134
+ it "should return the last 10 published stories by default" do
135
+ @blog.blog_stories.length.should eql 10
136
+ end
137
+
138
+ it "should return the last 5 when limited to 5" do
139
+ @blog.blog_stories(:limit => 5).length.should eql 5
140
+ end
141
+
142
+ it "should return the last 11 when limited to 11" do
143
+ @blog.blog_stories(:limit => 11).length.should eql 11
144
+ end
145
+
146
+ it "should return all the stories from 2001" do
147
+ @blog.blog_stories(:year => 2001).length.should eql 9
148
+ end
149
+
150
+ it "should return all the stories from feb of 2001" do
151
+ @blog.blog_stories(:year => 2001, :month => 2).length.should eql 2
152
+ end
153
+
154
+ it "should return all the stories from jan 14th of 2001" do
155
+ @blog.blog_stories(:year => 2001, :month => 1, :day => 14).length.should eql 2
156
+ end
157
+
158
+ end
159
+
160
+
161
+ describe "alias?" do
162
+ pending "should return true if page_type is set to alias"
163
+ end
164
+
165
+ describe "dom_id" do
166
+ before do
167
+ load_awesome_co
168
+ end
169
+
170
+ after do
171
+ unload_awesome_co
172
+ end
173
+
174
+ it "@who_we_are's parent should be @about_us" do
175
+ @who_we_are.parent.should eql @about_us
176
+ end
177
+
178
+ it "should return a unique id for the page usable in css" do
179
+ @who_we_are.save #Factory Girl not triggering the after save
180
+ @who_we_are.dom_id.should eql "about_us_who_we_are"
181
+ end
182
+ end
183
+
184
+
185
+ describe "get_content_areas" do
186
+ before do
187
+ load_awesome_co
188
+ end
189
+
190
+ after do
191
+ unload_awesome_co
192
+ end
193
+
194
+ it "should return content if there is one" do
195
+ @homepage.get_content(1).html.should eql "<p>Its a lot of work being this awesome</p>"
196
+ end
197
+
198
+ it "should return a new content if there isn't one" do
199
+ content = @homepage.get_content(100)
200
+ content.should be_instance_of DeluxePublisher::Content
201
+ content.should be_a_new_record
202
+ end
203
+
204
+ it "should return a stashed content if there is one" do
205
+ content = Factory(:content, :position => 0)
206
+ @about_us.stash_content(0, content)
207
+
208
+ @about_us.get_content(0).should eql content
209
+
210
+ end
211
+ end
212
+
213
+ describe "all_contents" do
214
+ before do
215
+ load_awesome_co
216
+ end
217
+
218
+ after do
219
+ unload_awesome_co
220
+ end
221
+
222
+ it "should return an array of with a length equal to the number of content areas" do
223
+ @homepage.all_contents.length.should eql @homepage.number_of_contents
224
+ end
225
+
226
+ it "should return an array of page contents" do
227
+ contents = @homepage.all_contents
228
+ contents[1].html.should eql "<p>Its a lot of work being this awesome</p>"
229
+ end
230
+
231
+ it "should include stashed contents" do
232
+ content = Factory(:content, :position => 0)
233
+ @homepage.stash_content(0, content)
234
+ @homepage.all_contents[0].should eql content
235
+ end
236
+
237
+ it "should return stashed attributes when stashed by attributes" do
238
+ @homepage.stash_content_attributes({"0" => Factory.attributes_for(:content, :position => 0, :html => "<p>Awesome Awesome Awesome Awesome</p>"),
239
+ "1" => Factory.attributes_for(:content, :position => 1, :html => "<p>Rad Rad Rad</p>"),
240
+ "2" => Factory.attributes_for(:content, :position => 2, :html => "<p>Awesome is the way to be.</p>")
241
+ })
242
+ @homepage.get_content(1).html.should eql "<p>Rad Rad Rad</p>"
243
+ @homepage.all_contents[2].html.should eql "<p>Awesome is the way to be.</p>"
244
+
245
+ end
246
+ end
247
+
248
+ describe "descriptor_for_position" do
249
+ before do
250
+ load_awesome_co
251
+ end
252
+
253
+ after do
254
+ unload_awesome_co
255
+ end
256
+
257
+ it "should return the content descriptor based on page type" do
258
+ @homepage.descriptor_for_position(1).should eql @homepage.page_type.content_descriptors.first(:conditions => {:position => 1})
259
+ end
260
+
261
+ it "should return a generic content descriptor if there is no page type set (like a new page)" do
262
+ descriptor = Factory.build(:page, :page_type => nil).descriptor_for_position(1)
263
+ descriptor.title.should eql "Content"
264
+ descriptor.content_type.should eql "text"
265
+ end
266
+ end
267
+
268
+
269
+ describe "Saving" do
270
+ before do
271
+ load_awesome_co
272
+ end
273
+
274
+ after do
275
+ unload_awesome_co
276
+ end
277
+
278
+ it "should set the path" do
279
+ @who_we_are.path = nil
280
+ @who_we_are.save
281
+ @who_we_are.path.should eql "/about_us/who_we_are"
282
+ end
283
+
284
+ it "should set the paths of all descendants" do
285
+ @about_us.file_name = "about_awesome_co"
286
+ @about_us.save
287
+ who_we_are = DeluxePublisher::Page.find(@who_we_are.id)
288
+ who_we_are.path.should eql "/about_awesome_co/who_we_are"
289
+ end
290
+
291
+ it "should set the path with creating a new page" do
292
+ page = Factory(:page, :parent => @who_we_are, :file_name => "sales")
293
+ page.path.should eql "/about_us/who_we_are/sales"
294
+ end
295
+
296
+
297
+ end
298
+
299
+
300
+ describe "number_of_contents" do
301
+ before do
302
+ load_awesome_co
303
+ end
304
+
305
+ after do
306
+ unload_awesome_co
307
+ end
308
+
309
+ it "should return number of content areas for the page's page type" do
310
+ @homepage.number_of_contents.should eql @homepage.page_type.number_of_content_areas
311
+ end
312
+
313
+ it "should default to 1 if page_type has not been set" do
314
+ Factory.build(:page, {:page_type => nil}).number_of_contents.should eql 1
315
+ end
316
+ end
317
+
318
+ describe "new_contents" do
319
+ it "should return a list of new contents" do
320
+ page = Factory.build(:page)
321
+ contents = page.new_contents
322
+
323
+ contents.length.should eql page.number_of_contents
324
+ contents.first.should be_instance_of(DeluxePublisher::Content)
325
+ contents.first.should be_new_record
326
+
327
+ end
328
+ end
329
+
330
+
331
+ describe "Class Methods" do
332
+ before do
333
+ reload_awesome_co
334
+ end
335
+
336
+ after do
337
+ unload_awesome_co
338
+ end
339
+
340
+ describe ".get_site_root" do
341
+ it "should return the site root if one exist already" do
342
+
343
+ DeluxePublisher::Page.get_site_root(1).should eql @root_page
344
+
345
+ end
346
+ end
347
+
348
+ describe ".find_with_content" do
349
+ it "should return page with the correct number on content areas" do
350
+ page = DeluxePublisher::Page.find_with_content(@about_us.id)
351
+
352
+ page.contents.length.should eql @about_us.page_type.number_of_content_areas
353
+ end
354
+ end
355
+ end
356
+
357
+
358
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe DeluxePublisher::PageType do
4
+ include AwesomeCo
5
+ describe "should not be valid if missing required field" do
6
+ [:name, :position, :function_as, :template].each do |required_field|
7
+ it required_field do
8
+ Factory.build(:page_type, required_field => nil).should_not be_valid
9
+ end
10
+ end
11
+ end
12
+
13
+ describe "get_content_descriptor" do
14
+ before do
15
+ load_awesome_co
16
+ end
17
+
18
+ after do
19
+ unload_awesome_co
20
+ end
21
+
22
+ it "should return descriptor if there is one" do
23
+ @simple_page_type.get_content_descriptor(0).title.should eql "Bitch'n Content"
24
+ end
25
+
26
+ it "should return a new content descriptor if there isn't one" do
27
+ descriptor = Factory(:page_type).get_content_descriptor(1)
28
+ descriptor.should be_an_instance_of(DeluxePublisher::ContentDescriptor)
29
+ descriptor.should be_a_new_record
30
+ end
31
+
32
+ it "should return stashed descriptors" do
33
+ page_type = Factory.build(:page_type, :number_of_content_areas => 4)
34
+ descriptor = Factory.build(:content_descriptor, :page_type => page_type, :position => 1, :title=>"Trick Topic")
35
+ page_type.stash_descriptor(1, descriptor)
36
+ page_type.all_content_descriptors[1].should eql descriptor
37
+ end
38
+ end
39
+
40
+ describe "all_content_descriptors" do
41
+
42
+ it "should return stashed descriptors at the proper position" do
43
+ page_type = Factory.build(:page_type, :number_of_content_areas => 4)
44
+ descriptor = Factory.build(:content_descriptor, :page_type => page_type, :position => 1, :title=>"Trick Topic")
45
+ page_type.stash_descriptor(1, descriptor)
46
+ page_type.all_content_descriptors[1].should eql descriptor
47
+ end
48
+
49
+ it "should return stashed descriptors when stashed by attributes" do
50
+ page_type = Factory.build(:page_type, :number_of_content_areas => 6)
51
+ content_descriptors_attributes = {"0"=>Factory.attributes_for(:content_descriptor, :position =>"0", :title => "Awesome Headlines"),
52
+ "1"=>Factory.attributes_for(:content_descriptor, :position =>"1", :title => "Wicked Watch List"),
53
+ "2"=>Factory.attributes_for(:content_descriptor, :position =>"2", :title => "Cherry Choices"),
54
+ "3"=>Factory.attributes_for(:content_descriptor, :position =>"3", :title => "Phat Financial Outlook"),
55
+ "4"=>Factory.attributes_for(:content_descriptor, :position =>"4", :title => "Breathtaking Briefs")
56
+ }
57
+ page_type.stash_descriptor_attributes(content_descriptors_attributes)
58
+ page_type.all_content_descriptors[3].title.should eql "Phat Financial Outlook"
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe DeluxePublisher::Redirect do
4
+
5
+ it "should be valid when created with default factory" do
6
+ Factory.build(:redirect).should be_valid
7
+ end
8
+
9
+ describe "should be invalid when missing required field" do
10
+ [:incoming_url, :direct_to_url].each do |required_field|
11
+ it required_field do
12
+ Factory.build(:redirect, required_field => nil).should_not be_valid
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "DeluxePublisher::Comments" do
4
+ describe "GET /deluxe_publisher_comments" do
5
+ it "works! (now write some real specs)" do
6
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
+ get deluxe_publisher_page_comments_path(1)
8
+ response.status.should be(200)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "DeluxePublisher::PageTypes" do
4
+ describe "GET /deluxe_publisher_page_types" do
5
+ it "works! (now write some real specs)" do
6
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
+ get deluxe_publisher_page_types_path
8
+ response.status.should be(200)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "DeluxePublisher::Redirects" do
4
+ describe "GET /deluxe_publisher_redirects" do
5
+ it "works! (now write some real specs)" do
6
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
+ get deluxe_publisher_redirects_path
8
+ response.status.should be(200)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Pages" do
4
+ describe "GET /pages" do
5
+ it "works! (now write some real specs)" do
6
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
+ get deluxe_publisher_pages_path
8
+ response.status.should be(200)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe DeluxePublisher::CommentsController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/deluxe_publisher/pages/100/comments" }.should route_to(:controller => "deluxe_publisher/comments", :page_id => "100", :action => "index")
8
+ end
9
+
10
+ it "recognizes and generates #new" do
11
+ { :get => "/deluxe_publisher/pages/100/comments/new" }.should route_to(:controller => "deluxe_publisher/comments", :page_id => "100", :action => "new")
12
+ end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/deluxe_publisher/pages/100/comments/1" }.should route_to(:controller => "deluxe_publisher/comments", :action => "show", :page_id => "100", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/deluxe_publisher/pages/100/comments/1/edit" }.should route_to(:controller => "deluxe_publisher/comments", :action => "edit", :page_id => "100", :id => "1")
20
+ end
21
+
22
+ it "recognizes and generates #create" do
23
+ { :post => "/deluxe_publisher/pages/100/comments" }.should route_to(:controller => "deluxe_publisher/comments", :action => "create", :page_id => "100")
24
+ end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/deluxe_publisher/pages/100/comments/1" }.should route_to(:controller => "deluxe_publisher/comments", :action => "update", :page_id => "100", :id => "1")
28
+ end
29
+
30
+ it "recognizes and generates #destroy" do
31
+ { :delete => "/deluxe_publisher/pages/100/comments/1" }.should route_to(:controller => "deluxe_publisher/comments", :action => "destroy", :page_id => "100", :id => "1")
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ describe DeluxePublisher::PageTypesController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/deluxe_publisher/page_types" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "index")
8
+ end
9
+
10
+ it "recognizes and generates #new" do
11
+ { :get => "/deluxe_publisher/page_types/new" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "new")
12
+ end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/deluxe_publisher/page_types/1" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "show", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/deluxe_publisher/page_types/1/edit" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "edit", :id => "1")
20
+ end
21
+
22
+ it "recognizes and generates #create" do
23
+ { :post => "/deluxe_publisher/page_types" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "create")
24
+ end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/deluxe_publisher/page_types/1" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "update", :id => "1")
28
+ end
29
+
30
+ it "recognizes and generates #destroy" do
31
+ { :delete => "/deluxe_publisher/page_types/1" }.should route_to(:controller => "deluxe_publisher/page_types", :action => "destroy", :id => "1")
32
+ end
33
+
34
+ it "recognizes and generates #content_areas_change" do
35
+ { :put => "/deluxe_publisher/page_types/1/content_areas_change.js" }.should route_to(:controller => "deluxe_publisher/page_types",
36
+ :action => "content_areas_change",
37
+ :id => "1",
38
+ :format => "js")
39
+ end
40
+
41
+ it "recognizes and generates #content_areas_change" do
42
+ { :post => "/deluxe_publisher/page_types/content_areas_change.js" }.should route_to(:controller => "deluxe_publisher/page_types",
43
+ :action => "content_areas_change",
44
+ :format => "js")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ describe DeluxePublisher::PagesController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/deluxe_publisher/pages" }.should route_to(:controller => "deluxe_publisher/pages", :action => "index")
8
+ end
9
+
10
+ it "recognizes and generates #new" do
11
+ { :get => "/deluxe_publisher/pages/new" }.should route_to(:controller => "deluxe_publisher/pages", :action => "new")
12
+ end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/deluxe_publisher/pages/1" }.should route_to(:controller => "deluxe_publisher/pages", :action => "show", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/deluxe_publisher/pages/1/edit" }.should route_to(:controller => "deluxe_publisher/pages", :action => "edit", :id => "1")
20
+ end
21
+
22
+ it "recognizes and generates #create" do
23
+ { :post => "/deluxe_publisher/pages" }.should route_to(:controller => "deluxe_publisher/pages", :action => "create")
24
+ end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/deluxe_publisher/pages/1" }.should route_to(:controller => "deluxe_publisher/pages", :action => "update", :id => "1")
28
+ end
29
+
30
+ it "recognizes and generates #destroy" do
31
+ { :delete => "/deluxe_publisher/pages/1" }.should route_to(:controller => "deluxe_publisher/pages", :action => "destroy", :id => "1")
32
+ end
33
+
34
+ it "recognizes and generates #page_type_change" do
35
+ { :put => "/deluxe_publisher/pages/1/page_type_change.js"}.should route_to(:controller => "deluxe_publisher/pages",
36
+ :action => "page_type_change", :id => "1",
37
+ :format => "js")
38
+ end
39
+
40
+ it "recognizes and generates #page_type_change" do
41
+ { :post => "/deluxe_publisher/pages/page_type_change.js"}.should route_to(:controller => "deluxe_publisher/pages",
42
+ :action => "page_type_change",
43
+ :format => "js")
44
+ end
45
+
46
+ end
47
+ end