alchemy_cms 2.2.4 → 2.3.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +3 -4
  3. data/Gemfile +1 -0
  4. data/README.md +10 -6
  5. data/alchemy_cms.gemspec +5 -2
  6. data/app/assets/images/alchemy/icons.png +0 -0
  7. data/app/assets/images/sassy-ie-overlay.png +0 -0
  8. data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
  9. data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
  10. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
  11. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
  12. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
  13. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
  16. data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
  17. data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
  18. data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
  19. data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
  20. data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
  21. data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
  22. data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
  23. data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
  24. data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
  25. data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
  26. data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
  27. data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
  28. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
  29. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  30. data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
  31. data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
  32. data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
  33. data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
  34. data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
  35. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
  36. data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
  37. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
  38. data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
  39. data/app/controllers/alchemy/admin/base_controller.rb +1 -9
  40. data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
  41. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  42. data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
  43. data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
  44. data/app/controllers/alchemy/attachments_controller.rb +8 -2
  45. data/app/controllers/alchemy/base_controller.rb +47 -5
  46. data/app/controllers/alchemy/elements_controller.rb +1 -1
  47. data/app/controllers/alchemy/messages_controller.rb +12 -12
  48. data/app/controllers/alchemy/pages_controller.rb +5 -1
  49. data/app/controllers/alchemy/pictures_controller.rb +9 -4
  50. data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
  51. data/app/helpers/alchemy/admin/base_helper.rb +98 -19
  52. data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
  53. data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
  54. data/app/helpers/alchemy/base_helper.rb +6 -5
  55. data/app/helpers/alchemy/elements_helper.rb +2 -2
  56. data/app/helpers/alchemy/essences_helper.rb +4 -5
  57. data/app/helpers/alchemy/pages_helper.rb +15 -79
  58. data/app/helpers/alchemy/url_helper.rb +67 -0
  59. data/app/mailers/alchemy/messages.rb +1 -1
  60. data/app/mailers/alchemy/notifications.rb +1 -1
  61. data/app/models/alchemy/attachment.rb +11 -2
  62. data/app/models/alchemy/cell.rb +20 -10
  63. data/app/models/alchemy/content.rb +4 -3
  64. data/app/models/alchemy/element.rb +170 -178
  65. data/app/models/alchemy/language/code.rb +4 -1
  66. data/app/models/alchemy/message.rb +19 -3
  67. data/app/models/alchemy/page.rb +45 -40
  68. data/app/models/alchemy/picture.rb +24 -2
  69. data/app/models/alchemy/user.rb +2 -3
  70. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
  71. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  72. data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
  73. data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
  74. data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
  75. data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
  76. data/app/views/alchemy/admin/contents/create.js.erb +54 -0
  77. data/app/views/alchemy/admin/contents/new.html.erb +9 -4
  78. data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
  79. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
  80. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
  81. data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
  82. data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
  83. data/app/views/alchemy/admin/elements/index.html.erb +24 -24
  84. data/app/views/alchemy/admin/elements/list.js.erb +11 -9
  85. data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
  86. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
  87. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
  88. data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
  89. data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
  90. data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
  91. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  92. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  93. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
  94. data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
  95. data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
  96. data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
  97. data/app/views/alchemy/admin/pages/index.html.erb +26 -24
  98. data/app/views/alchemy/admin/pages/link.html.erb +2 -5
  99. data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
  100. data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
  101. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
  102. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
  103. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
  104. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
  105. data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
  106. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
  107. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
  108. data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
  109. data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
  110. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
  111. data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
  112. data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
  113. data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
  114. data/app/views/alchemy/admin/resources/index.html.erb +3 -1
  115. data/app/views/alchemy/admin/users/_table.html.erb +1 -1
  116. data/app/views/alchemy/admin/users/index.html.erb +27 -23
  117. data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
  118. data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
  119. data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
  120. data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
  121. data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
  122. data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
  123. data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
  124. data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
  125. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
  126. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
  127. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
  128. data/app/views/alchemy/search/_form.html.erb +8 -0
  129. data/app/views/alchemy/search/_result.html.erb +3 -2
  130. data/app/views/alchemy/search/_results.html.erb +28 -0
  131. data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
  132. data/app/views/alchemy/user_sessions/login.html.erb +1 -2
  133. data/app/views/layouts/alchemy/admin.html.erb +30 -10
  134. data/app/views/layouts/alchemy/login.html.erb +2 -39
  135. data/config/alchemy/elements.yml +1 -2
  136. data/config/alchemy/page_layouts.yml +8 -5
  137. data/config/authorization_rules.rb +27 -18
  138. data/config/initializers/localeapp.rb +9 -0
  139. data/config/locales/alchemy.de.yml +93 -56
  140. data/config/locales/alchemy.en.yml +73 -50
  141. data/config/routes.rb +3 -1
  142. data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
  143. data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
  144. data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
  145. data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
  146. data/lib/alchemy/capistrano.rb +2 -2
  147. data/lib/alchemy/essence.rb +14 -0
  148. data/lib/alchemy/page_layout.rb +0 -6
  149. data/lib/alchemy/resource.rb +9 -15
  150. data/lib/alchemy/upgrader.rb +18 -3
  151. data/lib/alchemy/version.rb +5 -1
  152. data/lib/alchemy_cms.rb +4 -1
  153. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
  154. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
  155. data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
  156. data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
  157. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
  158. data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
  159. data/lib/tasks/fleximage.rake +2 -2
  160. data/spec/controllers/admin/contents_controller_spec.rb +2 -2
  161. data/spec/controllers/admin/elements_controller_spec.rb +30 -1
  162. data/spec/controllers/admin/pages_controller_spec.rb +35 -18
  163. data/spec/controllers/admin/trash_controller_spec.rb +40 -16
  164. data/spec/controllers/attachments_controller_spec.rb +62 -0
  165. data/spec/controllers/base_controller_spec.rb +43 -42
  166. data/spec/controllers/elements_controller_spec.rb +30 -0
  167. data/spec/controllers/pages_controller_spec.rb +22 -5
  168. data/spec/controllers/pictures_controller_spec.rb +82 -0
  169. data/spec/dummy/app/models/event.rb +2 -1
  170. data/spec/dummy/config/database.yml +3 -2
  171. data/spec/dummy/db/schema.rb +51 -27
  172. data/spec/factories.rb +29 -8
  173. data/spec/helpers/admin/base_helper_spec.rb +134 -21
  174. data/spec/helpers/admin/contents_helper_spec.rb +2 -2
  175. data/spec/helpers/admin/elements_helper_spec.rb +17 -9
  176. data/spec/helpers/admin/essences_helper_spec.rb +7 -6
  177. data/spec/helpers/essences_helper_spec.rb +8 -7
  178. data/spec/helpers/pages_helper_spec.rb +208 -325
  179. data/spec/helpers/url_helper_spec.rb +171 -0
  180. data/spec/integration/admin/link_overlay_spec.rb +53 -0
  181. data/spec/integration/admin/modules_integration_spec.rb +22 -26
  182. data/spec/integration/admin/pages_controller_spec.rb +10 -19
  183. data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
  184. data/spec/integration/admin/resources_integration_spec.rb +68 -75
  185. data/spec/integration/pages_controller_spec.rb +70 -61
  186. data/spec/integration/security_spec.rb +3 -5
  187. data/spec/integration/translation_integration_spec.rb +56 -0
  188. data/spec/libraries/essence_spec.rb +18 -0
  189. data/spec/libraries/resource_spec.rb +101 -79
  190. data/spec/libraries/resources_helper_spec.rb +3 -0
  191. data/spec/models/content_spec.rb +63 -60
  192. data/spec/models/element_spec.rb +203 -93
  193. data/spec/models/language_spec.rb +90 -65
  194. data/spec/models/page_layout_spec.rb +37 -0
  195. data/spec/models/page_spec.rb +181 -113
  196. data/spec/models/picture_spec.rb +73 -26
  197. data/spec/models/resource_spec.rb +52 -23
  198. data/spec/support/alchemy/specs_helpers.rb +2 -0
  199. data/spec/support/image.png +0 -0
  200. data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
  201. data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
  202. data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
  203. metadata +106 -33
  204. data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
  205. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
  206. data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
  207. data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
  208. data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
  209. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
  210. data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
  211. data/spec/dummy/config/locales/en.yml +0 -5
  212. data/spec/dummy/config/locales/fo.yml +0 -5
  213. data/spec/page_layout_spec.rb +0 -35
  214. data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
  215. data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -1,41 +1,154 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Alchemy::Admin::BaseHelper do
3
+ module Alchemy
4
+ module Admin
4
5
 
5
- context "maximum amount of images option" do
6
+ describe BaseHelper do
6
7
 
7
- before(:each) do
8
- @options = {}
9
- end
8
+ context "maximum amount of images option" do
9
+
10
+ before(:each) do
11
+ @options = {}
12
+ end
13
+
14
+ context "with max_images option" do
15
+
16
+ it "should return nil for empty string" do
17
+ @options[:max_images] = ""
18
+ max_image_count.should be(nil)
19
+ end
20
+
21
+ it "should return an integer for string number" do
22
+ @options[:max_images] = "1"
23
+ max_image_count.should be(1)
24
+ end
25
+
26
+ end
27
+
28
+ context "with maximum_amount_of_images option" do
29
+
30
+ it "should return nil for empty string" do
31
+ @options[:maximum_amount_of_images] = ""
32
+ max_image_count.should be(nil)
33
+ end
10
34
 
11
- context "with max_images option" do
35
+ it "should return an integer for string number" do
36
+ @options[:maximum_amount_of_images] = "1"
37
+ max_image_count.should be(1)
38
+ end
39
+
40
+ end
12
41
 
13
- it "should return nil for empty string" do
14
- @options[:max_images] = ""
15
- max_image_count.should be(nil)
16
42
  end
17
43
 
18
- it "should return an integer for string number" do
19
- @options[:max_images] = "1"
20
- max_image_count.should be(1)
44
+ describe "#merge_params" do
45
+ before(:each) do
46
+ controller.stub!(:params).and_return({:first => '1', :second => '2'})
47
+ end
48
+
49
+ it "returns a hash that contains the current params and additional params given as attributes" do
50
+ helper.merge_params(:third => '3', :fourth => '4').should == {:first => '1', :second => '2', :third => '3', :fourth => '4'}
51
+ end
21
52
  end
22
53
 
23
- end
54
+ describe "#merge_params_without" do
55
+ before(:each) do
56
+ controller.stub!(:params).and_return({:first => '1', :second => '2'})
57
+ end
58
+ it "can delete a single param" do
59
+ helper.merge_params_without(:second).should == {:first => '1'}
60
+ end
61
+
62
+ it "can delete several params" do
63
+ helper.merge_params_without([:first, :second]).should == {}
64
+ end
24
65
 
25
- context "with maximum_amount_of_images option" do
66
+ it "can delete a param and add new params at the same time" do
67
+ helper.merge_params_without([:first], {:third => '3'}).should == {:second => '2', :third => '3'}
68
+ end
26
69
 
27
- it "should return nil for empty string" do
28
- @options[:maximum_amount_of_images] = ""
29
- max_image_count.should be(nil)
70
+ it "should not change params" do
71
+ helper.merge_params_without([:first])
72
+ controller.params.should == {:first => '1', :second => '2'}
73
+ end
30
74
  end
31
75
 
32
- it "should return an integer for string number" do
33
- @options[:maximum_amount_of_images] = "1"
34
- max_image_count.should be(1)
76
+ describe "#merge_params_only" do
77
+
78
+ before(:each) do
79
+ controller.stub!(:params).and_return({:first => '1', :second => '2', :third => '3'})
80
+ end
81
+
82
+ it "can keep a single param" do
83
+ helper.merge_params_only(:second).should == {:second => '2'}
84
+ end
85
+
86
+ it "can keep several params" do
87
+ helper.merge_params_only([:first, :second]).should == {:first => '1', :second => '2'}
88
+ end
89
+
90
+ it "can keep a param and add new params at the same time" do
91
+ helper.merge_params_only([:first], {:third => '3'}).should == {:first => '1', :third => '3'}
92
+ end
93
+
94
+ it "should not change params" do
95
+ helper.merge_params_only([:first])
96
+ controller.params.should == {:first => '1', :second => '2', :third => '3'}
97
+ end
98
+
99
+ end
100
+
101
+ context "Filtering pictures depending on tags from params" do
102
+
103
+ let(:tag) do
104
+ mock_model(ActsAsTaggableOn::Tag, :name => "foo")
105
+ end
106
+
107
+ describe "#pictures_filtered_by_tag?" do
108
+ it "should return true if the filterlist contains the given tag" do
109
+ controller.params[:tagged_with] = "foo,bar,baz"
110
+ helper.pictures_filtered_by_tag?(tag).should == true
111
+ end
112
+
113
+ it "should return false if the filterlist does not contain the given tag" do
114
+ controller.params[:tagged_with] = "bar,baz"
115
+ helper.pictures_filtered_by_tag?(tag).should == false
116
+ end
117
+ end
118
+
119
+ describe "#add_to_picture_tag_filter" do
120
+ context "if params[:tagged_with] is not present" do
121
+ it "should return an Array with the given tag name" do
122
+ helper.add_to_picture_tag_filter(tag).should == ["foo"]
123
+ end
124
+ end
125
+
126
+ context "if params[:tagged_with] contains some tag names" do
127
+ it "should return an Array of tag names including the given one" do
128
+ controller.params[:tagged_with] = "bar,baz"
129
+ helper.add_to_picture_tag_filter(tag).should == ["bar", "baz", "foo"]
130
+ end
131
+ end
132
+ end
133
+
134
+ describe "#remove_from_picture_tag_filter" do
135
+ context "if params[:tagged_with] is not present" do
136
+ it "should return an empty Array" do
137
+ helper.remove_from_picture_tag_filter(tag).should be_empty
138
+ end
139
+ end
140
+
141
+ context "if params[:tagged_with] contains some tag names" do
142
+ it "should return an Array of tag names without the given one" do
143
+ controller.params[:tagged_with] = "bar,baz,foo"
144
+ helper.remove_from_picture_tag_filter(tag).should == ["bar", "baz"]
145
+ end
146
+ end
147
+ end
148
+
35
149
  end
36
150
 
37
151
  end
38
152
 
39
153
  end
40
-
41
154
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Alchemy::Admin::ContentsHelper do
4
4
 
5
5
  before(:each) do
6
- @element = FactoryGirl.create(:element, :name => 'article')
6
+ @element = FactoryGirl.create(:element, :name => 'article', :create_contents_after_create => true)
7
7
  end
8
8
 
9
9
  it "should render a dom id" do
@@ -21,7 +21,7 @@ describe Alchemy::Admin::ContentsHelper do
21
21
 
22
22
  it "should render a link to create a content in element" do
23
23
  helper.stub!(:render_icon).and_return('')
24
- helper.render_create_content_link(@element, 'headline').should match(/a.+href.*admin\/contents.+class.+button new_content_link.*data-method.+post/)
24
+ helper.render_create_content_link(@element, 'headline').should match(/a.+href.*admin\/contents.+class.+new_content_link.*data-method.+post/)
25
25
  end
26
26
 
27
27
  end
@@ -4,21 +4,29 @@ include Alchemy::BaseHelper
4
4
 
5
5
  describe Alchemy::Admin::ElementsHelper do
6
6
 
7
- before(:each) do
8
- @page = FactoryGirl.create(:public_page)
9
- @element = FactoryGirl.create(:element, :page => @page)
10
- end
7
+ context "partial rendering" do
11
8
 
12
- it "should render an element editor partial" do
13
- helper.render_editor(@element).should match(/class="content_editor".+id="essence_text_\d{1,}"/)
14
- end
9
+ before do
10
+ @page = FactoryGirl.create(:public_page)
11
+ @element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
12
+ end
13
+
14
+ it "should render an element editor partial" do
15
+ helper.render_editor(@element).should match(/class="content_editor".+id="essence_text_\d{1,}"/)
16
+ end
17
+
18
+ it "should render a picture gallery editor partial" do
19
+ helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
20
+ end
15
21
 
16
- it "should render a picture editor partial" do
17
- helper.render_picture_editor(@element).should match(/class="essence_picture_editor"/)
18
22
  end
19
23
 
20
24
  describe "#grouped_elements_for_select" do
21
25
 
26
+ before do
27
+ @page = FactoryGirl.create(:public_page)
28
+ end
29
+
22
30
  before(:each) do
23
31
  @page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
24
32
  cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
@@ -2,22 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe Alchemy::Admin::EssencesHelper do
4
4
 
5
- before(:each) do
6
- @element = FactoryGirl.create(:element, :name => 'article')
7
- @element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
5
+ let(:element) { FactoryGirl.create(:element, :name => 'article', :create_contents_after_create => true) }
6
+
7
+ before do
8
+ element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
8
9
  end
9
10
 
10
11
  it "should render an essence editor" do
11
- content = @element.content_by_name('intro')
12
+ content = element.content_by_name('intro')
12
13
  helper.render_essence_editor(content).should match(/input.+type="text".+value="hello!/)
13
14
  end
14
15
 
15
16
  it "should render an essence editor by name" do
16
- helper.render_essence_editor_by_name(@element, 'intro').should match(/input.+type="text".+value="hello!/)
17
+ helper.render_essence_editor_by_name(element, 'intro').should match(/input.+type="text".+value="hello!/)
17
18
  end
18
19
 
19
20
  it "should render an essence editor by type" do
20
- helper.render_essence_editor_by_type(@element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
21
+ helper.render_essence_editor_by_type(element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
21
22
  end
22
23
 
23
24
  end
@@ -2,27 +2,28 @@ require 'spec_helper'
2
2
 
3
3
  describe Alchemy::EssencesHelper do
4
4
 
5
- before(:each) do
6
- @element = FactoryGirl.create(:element)
7
- @element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
5
+ let(:element) { FactoryGirl.create(:element, :create_contents_after_create => true) }
6
+
7
+ before do
8
+ element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
8
9
  end
9
10
 
10
11
  it "should render an essence" do
11
- content = @element.content_by_name('intro')
12
+ content = element.content_by_name('intro')
12
13
  render_essence(content).should match(/hello!/)
13
14
  end
14
15
 
15
16
  it "should render an essence view" do
16
- content = @element.content_by_name('intro')
17
+ content = element.content_by_name('intro')
17
18
  render_essence_view(content).should match(/hello!/)
18
19
  end
19
20
 
20
21
  it "should render an essence view by name" do
21
- render_essence_view_by_name(@element, 'intro').should match(/hello!/)
22
+ render_essence_view_by_name(element, 'intro').should match(/hello!/)
22
23
  end
23
24
 
24
25
  it "should render an essence view by type" do
25
- render_essence_view_by_type(@element, 'EssenceText').should match(/hello!/)
26
+ render_essence_view_by_type(element, 'EssenceText').should match(/hello!/)
26
27
  end
27
28
 
28
29
  end
@@ -2,424 +2,308 @@ require 'spec_helper'
2
2
 
3
3
  include Alchemy::BaseHelper
4
4
 
5
- describe Alchemy::PagesHelper do
6
-
7
- before(:each) do
8
- helper.stub(:configuration).and_return(false)
9
- end
10
-
11
- it "should render the current page layout" do
12
- @page = FactoryGirl.create(:public_page)
13
- render_page_layout.should have_selector('div#content')
14
- end
15
-
16
- describe "#render_navigation" do
17
-
18
- before(:each) do
19
- @language = Alchemy::Language.get_default
20
- @root_page = FactoryGirl.create(:language_root_page, :language => @language, :name => 'Home')
21
- @page = FactoryGirl.create(:public_page, :language => @language, :parent_id => @root_page.id, :visible => true)
5
+ module Alchemy
6
+ describe PagesHelper do
7
+
8
+ # Fixtures
9
+ let(:language) { mock_model('Language', :code => 'en') }
10
+ let(:default_language) { Language.get_default }
11
+ let(:language_root) { FactoryGirl.create(:language_root_page) }
12
+ let(:public_page) { FactoryGirl.create(:public_page) }
13
+ let(:visible_page) { FactoryGirl.create(:public_page, :visible => true) }
14
+ let(:level_2_page) { FactoryGirl.create(:public_page, :parent_id => visible_page.id, :visible => true, :name => 'Level 2') }
15
+ let(:level_3_page) { FactoryGirl.create(:public_page, :parent_id => level_2_page.id, :visible => true, :name => 'Level 3') }
16
+ let(:level_4_page) { FactoryGirl.create(:public_page, :parent_id => level_3_page.id, :visible => true, :name => 'Level 4') }
17
+ let(:klingonian) { FactoryGirl.create(:klingonian) }
18
+ let(:klingonian_language_root) { FactoryGirl.create(:language_root_page, :language => klingonian) }
19
+ let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
20
+
21
+ before do
22
+ @root_page = language_root # We need this instance variable in the helpers
23
+ helper.stub(:configuration).and_return(false)
22
24
  end
23
25
 
24
- context "not in multi_language mode" do
26
+ it "should render the current page layout" do
27
+ @page = public_page
28
+ helper.render_page_layout.should have_selector('div#content')
29
+ end
25
30
 
26
- before(:each) do
27
- helper.stub(:multi_language?).and_return(false)
28
- end
31
+ describe "#render_navigation" do
29
32
 
30
- it "should render the page navigation" do
31
- helper.render_navigation.should have_selector("ul.navigation.level_1 li.#{@page.urlname}.active.last a.active[href=\"/alchemy/#{@page.urlname}\"]")
33
+ before do
34
+ visible_page
32
35
  end
33
36
 
34
- context "with enabled url nesting" do
37
+ context "not in multi_language mode" do
35
38
 
36
- before(:each) do
37
- helper.stub!(:configuration).and_return(true)
38
- @level2 = FactoryGirl.create(:public_page, :parent_id => @page.id, :language => @language, :visible => true)
39
- @level3 = FactoryGirl.create(:public_page, :parent_id => @level2.id, :language => @language, :visible => true)
39
+ before do
40
+ helper.stub(:multi_language?).and_return(false)
40
41
  end
41
42
 
42
- it "should render nested page links" do
43
- helper.render_navigation(:all_sub_menues => true).should have_selector("ul li a[href=\"/alchemy/#{@page.urlname}/#{@level2.urlname}/#{@level3.urlname}\"]")
43
+ it "should render the page navigation" do
44
+ helper.render_navigation.should have_selector("ul.navigation.level_1 li.#{visible_page.urlname} a[href=\"/alchemy/#{visible_page.urlname}\"]")
44
45
  end
45
46
 
46
- end
47
-
48
- end
49
-
50
- context "with id and class in the html options" do
51
- it "should append id to the generated ul tag" do
52
- helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
53
- end
54
- it "should replace the default css class from the generated ul tag" do
55
- helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
56
- end
57
- end
58
-
59
- end
60
-
61
- describe '#render_subnavigation' do
62
-
63
- before(:each) do
64
- @language = Alchemy::Language.get_default
65
- @language_root = FactoryGirl.create(:language_root_page, :language => @language, :name => 'Intro')
66
- @level_1 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @language_root.id, :visible => true, :name => 'Level 1')
67
- @level_2 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_1.id, :visible => true, :name => 'Level 2')
68
- @level_3 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_2.id, :visible => true, :name => 'Level 3')
69
- @level_4 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_3.id, :visible => true, :name => 'Level 4')
70
- helper.stub(:multi_language?).and_return(false)
71
- end
72
-
73
- it "should return nil if no @page is set" do
74
- helper.render_subnavigation.should be(nil)
75
- end
47
+ context "with enabled url nesting" do
76
48
 
77
- context "showing a page with level 2" do
49
+ before do
50
+ helper.stub!(:configuration).and_return(true)
51
+ level_3_page
52
+ end
78
53
 
79
- before(:each) do
80
- @page = @level_2
81
- end
54
+ it "should render nested page links" do
55
+ helper.render_navigation(:all_sub_menues => true).should have_selector("ul li a[href=\"/alchemy/#{visible_page.urlname}/#{level_2_page.urlname}/#{level_3_page.urlname}\"]")
56
+ end
82
57
 
83
- it "should render the navigation from current page" do
84
- helper.render_subnavigation.should have_selector('ul > li > a[href="/alchemy/level-2"]')
85
- end
58
+ end
86
59
 
87
- it "should set current page active" do
88
- helper.render_subnavigation.should have_selector('a[href="/alchemy/level-2"].active')
89
60
  end
90
61
 
91
- end
92
-
93
- context "showing a page with level 3" do
62
+ context "with id and class in the html options" do
94
63
 
95
- before(:each) do
96
- @page = @level_3
97
- end
64
+ it "should append id to the generated ul tag" do
65
+ helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
66
+ end
98
67
 
99
- it "should render the navigation from current pages parent" do
100
- helper.render_subnavigation.should have_selector('ul > li > ul > li > a[href="/alchemy/level-3"]')
101
- end
68
+ it "should replace the default css class from the generated ul tag" do
69
+ helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
70
+ end
102
71
 
103
- it "should set current page active" do
104
- helper.render_subnavigation.should have_selector('a[href="/alchemy/level-3"].active')
105
72
  end
106
73
 
107
74
  end
108
75
 
109
- context "showing a page with level 4" do
76
+ describe '#render_subnavigation' do
110
77
 
111
- before(:each) do
112
- @page = @level_4
113
- end
114
-
115
- it "should render the navigation from current pages parents parent" do
116
- helper.render_subnavigation.should have_selector('ul > li > ul > li > ul > li > a[href="/alchemy/level-4"]')
117
- end
118
-
119
- it "should set current page active" do
120
- helper.render_subnavigation.should have_selector('a[href="/alchemy/level-4"].active')
78
+ before do
79
+ helper.stub(:multi_language?).and_return(false)
121
80
  end
122
81
 
123
- context "beginning with level 3" do
124
-
125
- it "should render the navigation beginning from its parent" do
126
- helper.render_subnavigation(:level => 3).should have_selector('ul > li > ul > li > a[href="/alchemy/level-4"]')
127
- end
128
-
82
+ it "should return nil if no @page is set" do
83
+ helper.render_subnavigation.should be(nil)
129
84
  end
130
85
 
131
- end
132
-
133
- end
134
-
135
- describe "#render_breadcrumb" do
136
-
137
- before(:each) do
138
- helper.stub(:multi_language?).and_return(false)
139
- @root = mock_model('Page', :urlname => 'root', :name => 'Root', :title => 'Root', :visible? => false, :public? => false, :restricted? => false, :parent => nil)
140
- @language_root = mock_model('Page', :urlname => 'language_root', :name => 'Language Root', :title => 'Language Root', :visible? => true, :public? => true, :restricted? => false, :parent => @root)
141
- @page = mock_model('Page', :urlname => 'a-public-page', :name => 'A Public Page', :title => 'A Public Page', :visible? => true, :public? => true, :restricted? => false, :parent => @language_root)
142
- end
143
-
144
- it "should render a breadcrumb to current page" do
145
- helper.render_breadcrumb.should have_selector('a.active.last[href="/alchemy/a-public-page"]')
146
- end
147
-
148
- it "should render a breadcrumb with a alternative seperator" do
149
- helper.render_breadcrumb(:seperator => '<span>###</span>').should have_selector('span[contains("###")]')
150
- end
151
-
152
- it "should render a breadcrumb in reversed order" do
153
- helper.render_breadcrumb(:reverse => true).should have_selector('a.active.first[href="/alchemy/a-public-page"]')
154
- end
155
-
156
- it "should render a breadcrumb of restricted pages only" do
157
- @page.stub!(:restricted? => true, :urlname => 'a-restricted-public-page', :name => 'A restricted Public Page', :title => 'A restricted Public Page')
158
- helper.render_breadcrumb(:restricted_only => true).should match(/^(<a(.[^>]+)>)A restricted Public Page/)
159
- end
160
-
161
- it "should render a breadcrumb of visible pages only" do
162
- @page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
163
- helper.render_breadcrumb(:visible_only => true).should_not match(/A invisible Public Page/)
164
- end
165
-
166
- it "should render a breadcrumb of visible and invisible pages" do
167
- @page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
168
- helper.render_breadcrumb(:visible_only => false).should match(/A invisible Public Page/)
169
- end
170
-
171
- it "should render a breadcrumb of published pages only" do
172
- @page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
173
- helper.render_breadcrumb(:public_only => true).should_not match(/A Unpublic Page/)
174
- end
175
-
176
- it "should render a breadcrumb of published and unpublished pages" do
177
- @page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
178
- helper.render_breadcrumb(:public_only => false).should match(/A Unpublic Page/)
179
- end
180
-
181
- it "should render a breadcrumb without the page named 'Not Me'" do
182
- @page.stub!(:urlname => 'not-me', :name => 'Not Me', :title => 'Not Me')
183
- helper.render_breadcrumb(:without => @page).should_not match(/Not Me/)
184
- end
185
-
186
- end
187
-
188
- describe "using own url helpers" do
189
-
190
- before(:each) do
191
- @page = mock_model(Alchemy::Page, :urlname => 'testpage', :language_code => 'en')
192
- end
193
-
194
- describe "#show_page_path_params" do
195
-
196
- context "when multi_language" do
86
+ context "showing a page with level 2" do
197
87
 
198
- before(:each) do
199
- helper.stub!(:multi_language?).and_return(true)
200
- end
88
+ before { @page = level_2_page }
201
89
 
202
- it "should return a Hash with urlname and language_id parameter" do
203
- helper.stub!(:multi_language?).and_return(true)
204
- helper.show_page_path_params(@page).should include(:urlname => 'testpage', :lang => 'en')
90
+ it "should render the navigation from current page" do
91
+ helper.render_subnavigation.should have_selector("ul > li > a[href='/alchemy/#{level_2_page.urlname}']")
205
92
  end
206
93
 
207
- it "should return a Hash with urlname, language_id and query parameter" do
208
- helper.stub!(:multi_language?).and_return(true)
209
- helper.show_page_path_params(@page, {:query => 'test'}).should include(:urlname => 'testpage', :lang => 'en', :query => 'test')
94
+ it "should set current page active" do
95
+ helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_2_page.urlname}'].active")
210
96
  end
211
97
 
212
98
  end
213
99
 
214
- context "not multi_language" do
100
+ context "showing a page with level 3" do
215
101
 
216
- before(:each) do
217
- helper.stub!(:multi_language?).and_return(false)
218
- end
102
+ before { @page = level_3_page }
219
103
 
220
- it "should return a Hash with the urlname but without language_id parameter" do
221
- helper.show_page_path_params(@page).should include(:urlname => 'testpage')
222
- helper.show_page_path_params(@page).should_not include(:lang => 'en')
104
+ it "should render the navigation from current pages parent" do
105
+ helper.render_subnavigation.should have_selector("ul > li > ul > li > a[href='/alchemy/#{level_3_page.urlname}']")
223
106
  end
224
107
 
225
- it "should return a Hash with urlname and query parameter" do
226
- helper.show_page_path_params(@page, {:query => 'test'}).should include(:urlname => 'testpage', :query => 'test')
227
- helper.show_page_path_params(@page).should_not include(:lang => 'en')
108
+ it "should set current page active" do
109
+ helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_3_page.urlname}'].active")
228
110
  end
229
111
 
230
112
  end
231
113
 
232
- end
233
-
234
- describe "#show_alchemy_page_path" do
114
+ context "showing a page with level 4" do
235
115
 
236
- context "when multi_language" do
116
+ before { @page = level_4_page }
237
117
 
238
- before(:each) do
239
- helper.stub!(:multi_language?).and_return(true)
118
+ it "should render the navigation from current pages parents parent" do
119
+ helper.render_subnavigation.should have_selector("ul > li > ul > li > ul > li > a[href='/alchemy/#{level_4_page.urlname}']")
240
120
  end
241
121
 
242
- it "should return the correct relative path string" do
243
- helper.show_alchemy_page_path(@page).should == "/alchemy/#{@page.language_code}/testpage"
122
+ it "should set current page active" do
123
+ helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_4_page.urlname}'].active")
244
124
  end
245
125
 
246
- it "should return the correct relative path string with additional parameters" do
247
- helper.show_alchemy_page_path(@page, {:query => 'test'}).should == "/alchemy/#{@page.language_code}/testpage?query=test"
248
- end
249
-
250
- end
251
-
252
- context "not multi_language" do
126
+ context "beginning with level 3" do
253
127
 
254
- before(:each) do
255
- helper.stub!(:multi_language?).and_return(false)
256
- end
257
-
258
- it "should return the correct relative path string" do
259
- helper.show_alchemy_page_path(@page).should == "/alchemy/testpage"
260
- end
128
+ it "should render the navigation beginning from its parent" do
129
+ helper.render_subnavigation(:level => 3).should have_selector("ul > li > ul > li > a[href='/alchemy/#{level_4_page.urlname}']")
130
+ end
261
131
 
262
- it "should return the correct relative path string with additional parameter" do
263
- helper.show_alchemy_page_path(@page, {:query => 'test'}).should == "/alchemy/testpage?query=test"
264
132
  end
265
133
 
266
134
  end
267
135
 
268
136
  end
269
137
 
270
- describe "#show_alchemy_page_url" do
271
-
272
- context "when multi_language" do
138
+ describe "#render_breadcrumb" do
273
139
 
274
- before(:each) do
275
- helper.stub!(:multi_language?).and_return(true)
276
- end
140
+ before do
141
+ helper.stub(:multi_language?).and_return(false)
142
+ @root = mock_model('Page', :urlname => 'root', :name => 'Root', :title => 'Root', :visible? => false, :public? => false, :restricted? => false, :parent => nil)
143
+ @language_root = mock_model('Page', :urlname => 'language_root', :name => 'Language Root', :title => 'Language Root', :visible? => true, :public? => true, :restricted? => false, :parent => @root)
144
+ @page = mock_model('Page', :urlname => 'a-public-page', :name => 'A Public Page', :title => 'A Public Page', :visible? => true, :public? => true, :restricted? => false, :parent => @language_root)
145
+ end
277
146
 
278
- it "should return the correct url string" do
279
- helper.show_alchemy_page_url(@page).should == "http://#{helper.request.host}/alchemy/#{@page.language_code}/testpage"
280
- end
147
+ it "should render a breadcrumb to current page" do
148
+ helper.render_breadcrumb.should have_selector('.active.last[contains("A Public Page")]')
149
+ end
281
150
 
282
- it "should return the correct url string with additional parameters" do
283
- helper.show_alchemy_page_url(@page, {:query => 'test'}).should == "http://#{helper.request.host}/alchemy/#{@page.language_code}/testpage?query=test"
284
- end
151
+ it "should render a breadcrumb with a alternative seperator" do
152
+ helper.render_breadcrumb(:seperator => '<span>###</span>').should have_selector('span[contains("###")]')
153
+ end
285
154
 
155
+ it "should render a breadcrumb in reversed order" do
156
+ helper.render_breadcrumb(:reverse => true).should have_selector('.active.first[contains("A Public Page")]')
286
157
  end
287
158
 
288
- context "not multi_language" do
159
+ it "should render a breadcrumb of restricted pages only" do
160
+ @page.stub!(:restricted? => true, :urlname => 'a-restricted-public-page', :name => 'A restricted Public Page', :title => 'A restricted Public Page')
161
+ helper.render_breadcrumb(:restricted_only => true).should match(/^(<span(.[^>]+)>)A restricted Public Page/)
162
+ end
289
163
 
290
- before(:each) do
291
- helper.stub!(:multi_language?).and_return(false)
292
- end
164
+ it "should render a breadcrumb of visible pages only" do
165
+ @page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
166
+ helper.render_breadcrumb(:visible_only => true).should_not match(/A invisible Public Page/)
167
+ end
293
168
 
294
- it "should return the correct url string" do
295
- helper.show_alchemy_page_url(@page).should == "http://#{helper.request.host}/alchemy/testpage"
296
- end
169
+ it "should render a breadcrumb of visible and invisible pages" do
170
+ @page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
171
+ helper.render_breadcrumb(:visible_only => false).should match(/A invisible Public Page/)
172
+ end
297
173
 
298
- it "should return the correct url string with additional parameter" do
299
- helper.show_alchemy_page_url(@page, {:query => 'test'}).should == "http://#{helper.request.host}/alchemy/testpage?query=test"
300
- end
174
+ it "should render a breadcrumb of published pages only" do
175
+ @page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
176
+ helper.render_breadcrumb(:public_only => true).should_not match(/A Unpublic Page/)
177
+ end
301
178
 
179
+ it "should render a breadcrumb of published and unpublished pages" do
180
+ @page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
181
+ helper.render_breadcrumb(:public_only => false).should match(/A Unpublic Page/)
302
182
  end
303
- end
304
- end
305
183
 
306
- describe "#render_meta_data" do
184
+ it "should render a breadcrumb without the page named 'Not Me'" do
185
+ @page.stub!(:urlname => 'not-me', :name => 'Not Me', :title => 'Not Me')
186
+ helper.render_breadcrumb(:without => @page).should_not match(/Not Me/)
187
+ end
307
188
 
308
- let(:language) do
309
- mock_model('Language', :code => 'en')
310
189
  end
311
190
 
312
- it "should render meta keywords of current page" do
313
- @page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => '', :meta_keywords => 'keyword1, keyword2', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
314
- helper.render_meta_data.should have_selector('meta[name="keywords"][content="keyword1, keyword2"]')
315
- end
191
+ describe "#render_meta_data" do
316
192
 
317
- it "should render meta description 'blah blah' of current page" do
318
- @page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => 'blah blah', :meta_keywords => '', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
319
- helper.render_meta_data.should have_selector('meta[name="description"][content="blah blah"]')
320
- end
321
- end
193
+ it "should render meta keywords of current page" do
194
+ @page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => '', :meta_keywords => 'keyword1, keyword2', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
195
+ helper.render_meta_data.should have_selector('meta[name="keywords"][content="keyword1, keyword2"]')
196
+ end
322
197
 
323
- describe "#render_title_tag" do
324
- it "should render a title tag for current page" do
325
- @page = mock_model('Page', :title => 'A Public Page')
326
- helper.render_title_tag.should have_selector('title[contains("A Public Page")]')
198
+ it "should render meta description 'blah blah' of current page" do
199
+ @page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => 'blah blah', :meta_keywords => '', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
200
+ helper.render_meta_data.should have_selector('meta[name="description"][content="blah blah"]')
201
+ end
327
202
  end
328
203
 
329
- it "should render a title tag for current page with a prefix and a seperator" do
330
- @page = mock_model('Page', :title => 'A Public Page')
331
- helper.render_title_tag(:prefix => 'Peters Petshop', :seperator => ' ### ').should have_selector('title[contains("Peters Petshop ### A Public Page")]')
332
- end
333
- end
204
+ describe "#render_title_tag" do
334
205
 
335
- describe "#language_switcher" do
206
+ it "should render a title tag for current page" do
207
+ @page = mock_model('Page', :title => 'A Public Page')
208
+ helper.render_title_tag.should have_selector('title[contains("A Public Page")]')
209
+ end
336
210
 
337
- before :each do
338
- @default_language = Alchemy::Language.get_default
339
- @klingonian = FactoryGirl.create(:language)
340
- # simulates link_to_public_child = true
341
- helper.stub(:multi_language?).and_return(true)
342
- helper.stub(:configuration) { |arg| arg == :redirect_to_public_child ? true : false }
343
- end
211
+ it "should render a title tag for current page with a prefix and a seperator" do
212
+ @page = mock_model('Page', :title => 'A Public Page')
213
+ helper.render_title_tag(:prefix => 'Peters Petshop', :seperator => ' ### ').should have_selector('title[contains("Peters Petshop ### A Public Page")]')
214
+ end
344
215
 
345
- it "should return nil when having only one public language" do
346
- helper.language_switcher.should be nil
347
216
  end
348
217
 
349
- context "with two public languages and two language_roots" do
218
+ describe "#language_switcher" do
350
219
 
351
- before :each do
352
- @default_language_root = FactoryGirl.create(:language_root_page, :language => @default_language, :name => 'Default Language Root')
353
- @klingonian_language_root = FactoryGirl.create(:language_root_page)
220
+ before do
221
+ # simulates link_to_public_child = true
222
+ helper.stub(:multi_language?).and_return(true)
223
+ helper.stub(:configuration) { |arg| arg == :redirect_to_public_child ? true : false }
354
224
  end
355
225
 
356
- context "and config redirect_to_public_child is set to TRUE" do
357
-
358
- it "should return nil if only one language_root is public and both do not have children" do
359
- @klingonian_language_root.update_attributes(:public => false)
360
- helper.language_switcher.should == nil
361
- end
362
-
363
- it "should return nil if only one language_root is public and both have none public children" do
364
- @klingonian_language_root.update_attributes(:public => false)
365
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => false, :name => "child1")
366
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => false, :name => "child1")
367
- helper.language_switcher.should == nil
368
- end
369
-
370
- it "should render two links when having two public language_root pages" do
371
- helper.language_switcher.should have_selector('a', :count => 2)
372
- end
373
-
374
- it "should render two links when having just one public language_root but a public children in both language_roots" do
375
- @klingonian_language_root.update_attributes(:public => false)
376
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
377
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
378
- helper.language_switcher.should have_selector('a', :count => 2)
379
- end
380
-
381
- it "should render two links when having two not public language_roots but a public children in both" do
382
- @default_language_root.update_attributes(:public => false)
383
- @klingonian_language_root.update_attributes(:public => false)
384
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
385
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
386
- helper.language_switcher.should have_selector('a', :count => 2)
387
- end
388
-
389
- it "should return nil when having two not public language_roots and a public children in only one of them" do
390
- @default_language_root.update_attributes(:public => false)
391
- @klingonian_language_root.update_attributes(:public => false)
392
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => false, :name => "child1")
393
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
394
- helper.language_switcher.should == nil
395
- end
396
-
226
+ it "should return nil when having only one public language" do
227
+ helper.language_switcher.should be nil
397
228
  end
398
229
 
399
- context "and config redirect_to_public_child is set to FALSE" do
230
+ context "with two public languages and two language_roots" do
400
231
 
401
- before :each do
402
- # simulates link_to_public_child = false
403
- helper.stub(:configuration).and_return(false)
232
+ before do
233
+ language_root
404
234
  end
405
235
 
406
- it "should render two links when having two public language_root pages" do
407
- helper.language_switcher.should have_selector('a', :count => 2)
408
- end
236
+ context "and config redirect_to_public_child is set to TRUE" do
237
+
238
+ it "should return nil if only one language_root is public and both do not have children" do
239
+ klingonian_language_root.update_attributes(:public => false)
240
+ helper.language_switcher.should == nil
241
+ end
242
+
243
+ it "should return nil if only one language_root is public and both have none public children" do
244
+ klingonian_language_root.update_attributes(:public => false)
245
+ FactoryGirl.create(:page)
246
+ FactoryGirl.create(:page, :language => klingonian, :parent_id => klingonian_language_root.id)
247
+ helper.language_switcher.should == nil
248
+ end
249
+
250
+ it "should render two links when having two public language_root pages" do
251
+ klingonian_language_root
252
+ helper.language_switcher.should have_selector('a', :count => 2)
253
+ end
254
+
255
+ it "should render two links when having just one public language_root but a public children in both language_roots" do
256
+ klingonian_language_root.update_attributes(:public => false)
257
+ public_page
258
+ klingonian_public_page
259
+ helper.language_switcher.should have_selector('a', :count => 2)
260
+ end
261
+
262
+ it "should render two links when having two not public language_roots but a public children in both" do
263
+ language_root.update_attributes(:public => false)
264
+ klingonian_language_root.update_attributes(:public => false)
265
+ public_page
266
+ klingonian_public_page
267
+ helper.language_switcher.should have_selector('a', :count => 2)
268
+ end
269
+
270
+ it "should return nil when having two not public language_roots and a public children in only one of them" do
271
+ language_root.update_attributes(:public => false)
272
+ klingonian_language_root.update_attributes(:public => false)
273
+ FactoryGirl.create(:page)
274
+ klingonian_public_page
275
+ helper.language_switcher.should == nil
276
+ end
409
277
 
410
- it "should render nil when having just one public language_root but a public children in both language_roots" do
411
- @klingonian_language_root.update_attributes(:public => false)
412
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
413
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
414
- helper.language_switcher.should == nil
415
278
  end
416
279
 
417
- it "should render nil when having two not public language_roots but a public children in both" do
418
- @default_language_root.update_attributes(:public => false)
419
- @klingonian_language_root.update_attributes(:public => false)
420
- @default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
421
- @klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
422
- helper.language_switcher.should == nil
280
+ context "and config redirect_to_public_child is set to FALSE" do
281
+
282
+ before do
283
+ klingonian_language_root
284
+ # simulates link_to_public_child = false
285
+ helper.stub(:configuration).and_return(false)
286
+ end
287
+
288
+ it "should render two links when having two public language_root pages" do
289
+ helper.language_switcher.should have_selector('a', :count => 2)
290
+ end
291
+
292
+ it "should render nil when having just one public language_root but a public children in both language_roots" do
293
+ klingonian_language_root.update_attributes(:public => false)
294
+ public_page
295
+ klingonian_public_page
296
+ helper.language_switcher.should == nil
297
+ end
298
+
299
+ it "should render nil when having two not public language_roots but a public children in both" do
300
+ language_root.update_attributes(:public => false)
301
+ klingonian_language_root.update_attributes(:public => false)
302
+ public_page
303
+ klingonian_public_page
304
+ helper.language_switcher.should == nil
305
+ end
306
+
423
307
  end
424
308
 
425
309
  end
@@ -427,5 +311,4 @@ describe Alchemy::PagesHelper do
427
311
  end
428
312
 
429
313
  end
430
-
431
314
  end