alchemy_cms 3.0.4 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -6
  3. data/Gemfile +4 -7
  4. data/README.md +207 -115
  5. data/alchemy_cms.gemspec +10 -9
  6. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
  7. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +2 -2
  8. data/app/assets/javascripts/alchemy/alchemy.js +6 -7
  9. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -43
  10. data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +1 -1
  11. data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
  12. data/app/assets/stylesheets/alchemy/buttons.scss +0 -5
  13. data/app/assets/stylesheets/alchemy/dialogs.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/frame.scss +9 -12
  15. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +11 -2
  16. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +9 -1
  17. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -4
  18. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +34 -38
  19. data/app/controllers/alchemy/api/base_controller.rb +19 -0
  20. data/app/controllers/alchemy/api/contents_controller.rb +35 -0
  21. data/app/controllers/alchemy/api/elements_controller.rb +29 -0
  22. data/app/controllers/alchemy/api/pages_controller.rb +32 -0
  23. data/app/controllers/alchemy/contents_controller.rb +1 -0
  24. data/app/controllers/alchemy/elements_controller.rb +5 -2
  25. data/app/controllers/alchemy/pages_controller.rb +4 -1
  26. data/app/controllers/alchemy/pictures_controller.rb +4 -36
  27. data/app/helpers/alchemy/admin/essences_helper.rb +5 -2
  28. data/app/helpers/alchemy/essences_helper.rb +14 -1
  29. data/app/models/alchemy/content.rb +32 -4
  30. data/app/models/alchemy/element.rb +2 -16
  31. data/app/models/alchemy/element/presenters.rb +2 -2
  32. data/app/models/alchemy/essence_file.rb +5 -0
  33. data/app/models/alchemy/essence_picture.rb +12 -8
  34. data/app/models/alchemy/picture.rb +1 -74
  35. data/app/models/alchemy/picture/transformations.rb +249 -0
  36. data/app/serializers/alchemy/content_serializer.rb +3 -10
  37. data/app/serializers/alchemy/element_serializer.rb +6 -3
  38. data/app/serializers/alchemy/legacy_element_serializer.rb +17 -0
  39. data/app/views/alchemy/admin/dashboard/_sites.html.erb +14 -4
  40. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +8 -5
  41. data/app/views/alchemy/admin/pages/edit.html.erb +9 -9
  42. data/app/views/alchemy/admin/pictures/info.html.erb +2 -3
  43. data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
  44. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +8 -7
  45. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -3
  46. data/app/views/alchemy/essences/_essence_date_editor.html.erb +8 -2
  47. data/app/views/alchemy/essences/_essence_date_view.html.erb +10 -8
  48. data/app/views/alchemy/essences/_essence_file_editor.html.erb +48 -53
  49. data/app/views/alchemy/essences/_essence_file_view.html.erb +5 -5
  50. data/app/views/alchemy/essences/_essence_html_editor.html.erb +5 -4
  51. data/app/views/alchemy/essences/_essence_link_editor.html.erb +17 -15
  52. data/app/views/alchemy/essences/_essence_link_view.html.erb +11 -7
  53. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -2
  54. data/app/views/alchemy/essences/_essence_picture_view.html.erb +4 -2
  55. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +5 -4
  56. data/app/views/alchemy/essences/_essence_select_editor.html.erb +22 -32
  57. data/app/views/alchemy/essences/_essence_text_view.html.erb +7 -6
  58. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +1 -1
  59. data/app/views/layouts/alchemy/admin.html.erb +5 -3
  60. data/config/initializers/inflections.rb +3 -0
  61. data/config/initializers/simple_form.rb +1 -1
  62. data/config/locales/alchemy.en.yml +0 -1
  63. data/config/routes.rb +14 -0
  64. data/lib/alchemy/capistrano.rb +71 -0
  65. data/lib/alchemy/engine.rb +0 -3
  66. data/lib/alchemy/essence.rb +1 -1
  67. data/lib/alchemy/permissions.rb +19 -5
  68. data/lib/alchemy/picture_attributes.rb +1 -1
  69. data/lib/alchemy/test_support/auth_helpers.rb +1 -1
  70. data/lib/alchemy/test_support/essence_shared_examples.rb +37 -22
  71. data/lib/alchemy/test_support/integration_helpers.rb +1 -1
  72. data/lib/alchemy/tinymce.rb +21 -4
  73. data/lib/alchemy/upgrader/three_point_one.rb +43 -0
  74. data/lib/alchemy/upgrader/three_point_zero.rb +13 -0
  75. data/lib/alchemy/version.rb +2 -1
  76. data/lib/rails/generators/alchemy/module/module_generator.rb +30 -0
  77. data/lib/rails/generators/alchemy/module/templates/ability.rb.tt +11 -0
  78. data/lib/rails/generators/alchemy/module/templates/controller.rb.tt +2 -0
  79. data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +15 -0
  80. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -1
  81. data/lib/rails/templates/alchemy.rb +2 -2
  82. data/lib/tasks/alchemy/db.rake +7 -1
  83. data/spec/controllers/admin/attachments_controller_spec.rb +38 -38
  84. data/spec/controllers/admin/base_controller_spec.rb +18 -18
  85. data/spec/controllers/admin/clipboard_controller_spec.rb +23 -18
  86. data/spec/controllers/admin/contents_controller_spec.rb +33 -27
  87. data/spec/controllers/admin/dashboard_controller_spec.rb +14 -14
  88. data/spec/controllers/admin/elements_controller_spec.rb +125 -105
  89. data/spec/controllers/admin/essence_files_controller_spec.rb +6 -7
  90. data/spec/controllers/admin/essence_pictures_controller_spec.rb +52 -42
  91. data/spec/controllers/admin/languages_controller_spec.rb +3 -3
  92. data/spec/controllers/admin/pages_controller_spec.rb +81 -71
  93. data/spec/controllers/admin/pictures_controller_spec.rb +69 -72
  94. data/spec/controllers/admin/resources_controller_spec.rb +5 -5
  95. data/spec/controllers/admin/trash_controller_spec.rb +15 -12
  96. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +8 -8
  97. data/spec/controllers/alchemy/api/contents_controller_spec.rb +73 -0
  98. data/spec/controllers/alchemy/api/elements_controller_spec.rb +69 -0
  99. data/spec/controllers/alchemy/api/pages_controller_spec.rb +86 -0
  100. data/spec/controllers/attachments_controller_spec.rb +8 -8
  101. data/spec/controllers/contents_controller_spec.rb +22 -0
  102. data/spec/controllers/elements_controller_spec.rb +10 -4
  103. data/spec/controllers/messages_controller_spec.rb +35 -34
  104. data/spec/controllers/pages_controller_spec.rb +37 -28
  105. data/spec/controllers/pictures_controller_spec.rb +90 -23
  106. data/spec/dummy/app/models/dummy_user.rb +0 -4
  107. data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +11 -0
  108. data/spec/dummy/config/alchemy/elements.yml +22 -1
  109. data/spec/dummy/config/alchemy/page_layouts.yml +4 -0
  110. data/spec/dummy/config/application.rb +2 -1
  111. data/spec/dummy/config/environments/test.rb +3 -1
  112. data/spec/features/admin/dashboard_spec.rb +41 -6
  113. data/spec/features/admin/language_tree_feature_spec.rb +3 -3
  114. data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
  115. data/spec/features/admin/link_overlay_spec.rb +7 -7
  116. data/spec/features/admin/locale_select_feature_spec.rb +5 -2
  117. data/spec/features/admin/modules_integration_spec.rb +1 -1
  118. data/spec/features/admin/page_creation_feature_spec.rb +3 -2
  119. data/spec/features/admin/page_editing_feature_spec.rb +66 -79
  120. data/spec/features/admin/picture_library_integration_spec.rb +8 -8
  121. data/spec/features/admin/resources_integration_spec.rb +21 -21
  122. data/spec/features/admin/tinymce_feature_spec.rb +36 -0
  123. data/spec/features/navigation_spec.rb +1 -1
  124. data/spec/features/page_feature_spec.rb +34 -34
  125. data/spec/features/picture_security_spec.rb +4 -4
  126. data/spec/features/security_spec.rb +1 -1
  127. data/spec/features/translation_integration_spec.rb +7 -7
  128. data/spec/helpers/admin/base_helper_spec.rb +51 -49
  129. data/spec/helpers/admin/contents_helper_spec.rb +11 -11
  130. data/spec/helpers/admin/elements_helper_spec.rb +20 -17
  131. data/spec/helpers/admin/essences_helper_spec.rb +42 -11
  132. data/spec/helpers/admin/navigation_helper_spec.rb +64 -54
  133. data/spec/helpers/admin/pages_helper_spec.rb +10 -10
  134. data/spec/helpers/admin/tags_helper_spec.rb +16 -16
  135. data/spec/helpers/base_helper_spec.rb +11 -11
  136. data/spec/helpers/elements_block_helper_spec.rb +24 -24
  137. data/spec/helpers/elements_helper_spec.rb +46 -46
  138. data/spec/helpers/essences_helper_spec.rb +90 -17
  139. data/spec/helpers/pages_helper_spec.rb +53 -53
  140. data/spec/helpers/picture_url_helpers_spec.rb +6 -6
  141. data/spec/helpers/url_helper_spec.rb +32 -32
  142. data/spec/libraries/config_spec.rb +9 -9
  143. data/spec/libraries/controller_actions_spec.rb +14 -14
  144. data/spec/libraries/i18n_spec.rb +6 -6
  145. data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +4 -4
  146. data/spec/libraries/modules_spec.rb +4 -4
  147. data/spec/libraries/mount_point_spec.rb +13 -13
  148. data/spec/libraries/page_layout_spec.rb +24 -24
  149. data/spec/libraries/permissions_spec.rb +97 -80
  150. data/spec/libraries/resource_spec.rb +37 -37
  151. data/spec/libraries/resources_helper_spec.rb +19 -19
  152. data/spec/libraries/shell_spec.rb +17 -17
  153. data/spec/libraries/template_tracker_spec.rb +14 -14
  154. data/spec/libraries/tinymce_spec.rb +8 -8
  155. data/spec/libraries/userstamp_spec.rb +2 -2
  156. data/spec/mailers/messages_spec.rb +4 -4
  157. data/spec/models/attachment_spec.rb +86 -30
  158. data/spec/models/cell_spec.rb +10 -10
  159. data/spec/models/content_spec.rb +106 -46
  160. data/spec/models/element_spec.rb +94 -115
  161. data/spec/models/essence_date_spec.rb +1 -1
  162. data/spec/models/essence_file_spec.rb +4 -4
  163. data/spec/models/essence_picture_spec.rb +56 -25
  164. data/spec/models/essence_richtext_spec.rb +1 -1
  165. data/spec/models/essence_text_spec.rb +7 -7
  166. data/spec/models/language_spec.rb +12 -12
  167. data/spec/models/legacy_page_url_spec.rb +2 -2
  168. data/spec/models/message_spec.rb +12 -5
  169. data/spec/models/page_spec.rb +259 -235
  170. data/spec/models/picture_spec.rb +72 -166
  171. data/spec/models/site_spec.rb +41 -41
  172. data/spec/models/tag_spec.rb +7 -7
  173. data/spec/routing/api_routing_spec.rb +150 -0
  174. data/spec/routing/routing_spec.rb +28 -28
  175. data/spec/spec_helper.rb +6 -5
  176. data/spec/support/hint_examples.rb +5 -5
  177. data/spec/support/transformation_examples.rb +173 -0
  178. data/spec/tasks/helpers_spec.rb +29 -29
  179. data/spec/views/essences/essence_boolean_editor_spec.rb +32 -0
  180. data/spec/views/essences/essence_boolean_view_spec.rb +2 -2
  181. data/spec/views/essences/essence_date_view_spec.rb +1 -1
  182. data/spec/views/essences/essence_link_view_spec.rb +11 -0
  183. data/spec/views/essences/essence_picture_view_spec.rb +56 -11
  184. data/spec/views/essences/essence_richtext_view_spec.rb +12 -0
  185. data/spec/views/essences/essence_text_view_spec.rb +12 -0
  186. data/vendor/assets/javascripts/tinymce/langs/de.js +20 -2
  187. data/vendor/assets/javascripts/tinymce/langs/fr.js +14 -1
  188. data/vendor/assets/javascripts/tinymce/langs/nl.js +22 -4
  189. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +1 -1
  190. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -1
  191. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -1
  192. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -1
  193. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -1
  194. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -1
  195. data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +1 -1
  196. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -1
  197. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -1
  198. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -1
  199. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -1
  200. data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -1
  201. data/vendor/assets/javascripts/tinymce/tinymce.min.js +11 -10
  202. metadata +72 -42
  203. data/app/views/alchemy/messages/contact_form_mail.es.text.erb +0 -12
  204. data/config/locales/alchemy.es.yml +0 -958
  205. data/config/locales/alchemy.ru.yml +0 -837
  206. data/config/locales/simple_form.es.yml +0 -6
  207. data/config/locales/simple_form.ru.yml +0 -25
  208. data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +0 -31
  209. data/vendor/assets/javascripts/tinymce/langs/es.js +0 -197
  210. data/vendor/assets/javascripts/tinymce/langs/ru.js +0 -197
@@ -7,27 +7,27 @@ describe Alchemy::EssencesHelper do
7
7
 
8
8
  before do
9
9
  allow_message_expectations_on_nil
10
- content.stub(:essence).and_return(essence)
10
+ allow(content).to receive(:essence).and_return(essence)
11
11
  end
12
12
 
13
13
  describe 'render_essence' do
14
14
  subject { render_essence(content) }
15
15
 
16
16
  it "renders an essence view partial" do
17
- should have_content 'hello!'
17
+ is_expected.to have_content 'hello!'
18
18
  end
19
19
 
20
20
  context 'with editor given as view part' do
21
21
  subject { helper.render_essence(content, :editor) }
22
22
 
23
23
  before do
24
- helper.stub(:label_and_remove_link)
25
- content.stub(:settings).and_return({})
24
+ allow(helper).to receive(:label_and_remove_link)
25
+ allow(content).to receive(:settings).and_return({})
26
26
  end
27
27
 
28
28
  it "renders an essence editor partial" do
29
- content.should_receive(:form_field_name)
30
- should have_selector 'input[type="text"]'
29
+ expect(content).to receive(:form_field_name)
30
+ is_expected.to have_selector 'input[type="text"]'
31
31
  end
32
32
  end
33
33
 
@@ -35,16 +35,17 @@ describe Alchemy::EssencesHelper do
35
35
  let(:content) { nil }
36
36
 
37
37
  it "returns empty string" do
38
- should == ''
38
+ is_expected.to eq('')
39
39
  end
40
40
 
41
41
  context 'editor given as part' do
42
42
  subject { helper.render_essence(content, :editor) }
43
- before { helper.stub(_t: '') }
43
+
44
+ before { allow(helper).to receive(:_t).and_return('') }
44
45
 
45
46
  it "displays warning" do
46
- helper.should_receive(:warning).and_return('')
47
- should == ''
47
+ expect(helper).to receive(:warning).and_return('')
48
+ is_expected.to eq('')
48
49
  end
49
50
  end
50
51
  end
@@ -53,16 +54,17 @@ describe Alchemy::EssencesHelper do
53
54
  let(:essence) { nil }
54
55
 
55
56
  it "returns empty string" do
56
- should == ''
57
+ is_expected.to eq('')
57
58
  end
58
59
 
59
60
  context 'editor given as part' do
60
61
  subject { helper.render_essence(content, :editor) }
61
- before { helper.stub(_t: '') }
62
+
63
+ before { allow(helper).to receive(:_t).and_return('') }
62
64
 
63
65
  it "displays warning" do
64
- helper.should_receive(:warning).and_return('')
65
- should == ''
66
+ expect(helper).to receive(:warning).and_return('')
67
+ is_expected.to eq('')
66
68
  end
67
69
  end
68
70
  end
@@ -70,14 +72,85 @@ describe Alchemy::EssencesHelper do
70
72
 
71
73
  describe 'render_essence_view' do
72
74
  it "renders an essence view partial" do
73
- render_essence_view(content).should have_content 'hello!'
75
+ expect(render_essence_view(content)).to have_content 'hello!'
74
76
  end
75
77
  end
76
78
 
77
79
  describe "render_essence_view_by_name" do
78
80
  it "renders an essence view partial by content name" do
79
- element.should_receive(:content_by_name).and_return(content)
80
- render_essence_view_by_name(element, 'intro').should have_content 'hello!'
81
+ expect(element).to receive(:content_by_name).and_return(content)
82
+ expect(render_essence_view_by_name(element, 'intro')).to have_content 'hello!'
83
+ end
84
+ end
85
+
86
+ describe 'content_settings_value' do
87
+ subject { content_settings_value(content, key, options) }
88
+
89
+ let(:key) { :key }
90
+
91
+ context 'with content having settings' do
92
+ let(:content) { double(settings: {key: 'content_settings_value'}) }
93
+
94
+ context 'and empty options' do
95
+ let(:options) { {} }
96
+
97
+ it "returns the value for key from content settings" do
98
+ expect(subject).to eq('content_settings_value')
99
+ end
100
+ end
101
+
102
+ context 'and nil options' do
103
+ let(:options) { nil }
104
+
105
+ it "returns the value for key from content settings" do
106
+ expect(subject).to eq('content_settings_value')
107
+ end
108
+ end
109
+
110
+ context 'but same key present in options' do
111
+ let(:options) { {key: 'options_value'} }
112
+
113
+ it "returns the value for key from options" do
114
+ expect(subject).to eq('options_value')
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'with content having no settings' do
120
+ let(:content) { double(settings: {}) }
121
+
122
+ context 'and empty options' do
123
+ let(:options) { {} }
124
+
125
+ it { expect(subject).to eq(nil) }
126
+ end
127
+
128
+ context 'but key present in options' do
129
+ let(:options) { {key: 'options_value'} }
130
+
131
+ it "returns the value for key from options" do
132
+ expect(subject).to eq('options_value')
133
+ end
134
+ end
135
+ end
136
+
137
+ context 'with content having settings with string as key' do
138
+ let(:content) { double(settings: {'key' => 'value_from_string_key'}) }
139
+ let(:options) { {} }
140
+
141
+ it "returns value" do
142
+ expect(subject).to eq('value_from_string_key')
143
+ end
144
+ end
145
+
146
+ context 'with key passed as string' do
147
+ let(:content) { double(settings: {key: 'value_from_symbol_key'}) }
148
+ let(:key) { 'key' }
149
+ let(:options) { {} }
150
+
151
+ it "returns value" do
152
+ expect(subject).to eq('value_from_symbol_key')
153
+ end
81
154
  end
82
155
  end
83
156
  end
@@ -21,14 +21,14 @@ module Alchemy
21
21
  let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
22
22
 
23
23
  before do
24
- Config.stub(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
24
+ allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
25
25
  @root_page = language_root # We need this instance variable in the helpers
26
26
  end
27
27
 
28
28
  describe "#render_page_layout" do
29
29
  it "should render the current page layout" do
30
30
  @page = public_page
31
- helper.render_page_layout.should have_selector('div#content')
31
+ expect(helper.render_page_layout).to have_selector('div#content')
32
32
  end
33
33
  end
34
34
 
@@ -36,14 +36,14 @@ module Alchemy
36
36
  let(:default_site) { Alchemy::Site.default }
37
37
 
38
38
  it "renders the partial for current site" do
39
- helper.should_receive(:current_alchemy_site).and_return(default_site)
40
- helper.should_receive(:render).with(default_site)
39
+ expect(helper).to receive(:current_alchemy_site).and_return(default_site)
40
+ expect(helper).to receive(:render).with(default_site)
41
41
  helper.render_site_layout
42
42
  end
43
43
 
44
44
  context "with missing partial" do
45
45
  it "returns empty string and logges warning" do
46
- helper.should_receive(:current_alchemy_site).twice.and_return(default_site)
46
+ expect(helper).to receive(:current_alchemy_site).twice.and_return(default_site)
47
47
  expect(helper.render_site_layout).to eq("")
48
48
  end
49
49
  end
@@ -54,31 +54,31 @@ module Alchemy
54
54
 
55
55
  before do
56
56
  visible_page
57
- helper.stub(:current_ability).and_return(Alchemy::Permissions.new(user))
57
+ allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
58
58
  end
59
59
 
60
60
  it "should render only visible pages" do
61
61
  not_visible_page = FactoryGirl.create(:page, visible: false)
62
- helper.render_navigation.should_not match(/#{not_visible_page.name}/)
62
+ expect(helper.render_navigation).not_to match(/#{not_visible_page.name}/)
63
63
  end
64
64
 
65
65
  it "should render visible unpublished pages" do
66
66
  unpublished_visible_page = FactoryGirl.create(:page, visible: true, public: false)
67
- helper.render_navigation.should match(/#{unpublished_visible_page.name}/)
67
+ expect(helper.render_navigation).to match(/#{unpublished_visible_page.name}/)
68
68
  end
69
69
 
70
70
  context "not in multi_language mode" do
71
- before { helper.stub(:multi_language?).and_return(false) }
71
+ before { allow(helper).to receive(:multi_language?).and_return(false) }
72
72
 
73
73
  it "should render the page navigation" do
74
- helper.render_navigation.should have_selector("ul.navigation.level_1 li.#{visible_page.urlname} a[href=\"/#{visible_page.urlname}\"]")
74
+ expect(helper.render_navigation).to have_selector("ul.navigation.level_1 li.#{visible_page.urlname} a[href=\"/#{visible_page.urlname}\"]")
75
75
  end
76
76
 
77
77
  context "as guest user" do
78
78
  before { restricted_page }
79
79
 
80
80
  it "should not render restricted pages" do
81
- helper.render_navigation.should_not have_selector("ul.navigation.level_1 li a[href=\"/#{restricted_page.urlname}\"]")
81
+ expect(helper.render_navigation).not_to have_selector("ul.navigation.level_1 li a[href=\"/#{restricted_page.urlname}\"]")
82
82
  end
83
83
  end
84
84
 
@@ -89,30 +89,30 @@ module Alchemy
89
89
 
90
90
  it "should render also restricted pages" do
91
91
  not_restricted_page = FactoryGirl.create(:public_page, restricted: false, visible: true)
92
- helper.render_navigation.should match(/#{restricted_page.name}/)
93
- helper.render_navigation.should match(/#{not_restricted_page.name}/)
92
+ expect(helper.render_navigation).to match(/#{restricted_page.name}/)
93
+ expect(helper.render_navigation).to match(/#{not_restricted_page.name}/)
94
94
  end
95
95
  end
96
96
 
97
97
  context "with enabled url nesting" do
98
98
  before do
99
- helper.stub(:configuration).and_return(true)
99
+ allow(helper).to receive(:configuration).and_return(true)
100
100
  level_3_page
101
101
  end
102
102
 
103
103
  it "should render nested page links" do
104
- helper.render_navigation(:all_sub_menues => true).should have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
104
+ expect(helper.render_navigation(:all_sub_menues => true)).to have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
105
105
  end
106
106
  end
107
107
  end
108
108
 
109
109
  context "with id and class in the html options" do
110
110
  it "should append id to the generated ul tag" do
111
- helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
111
+ expect(helper.render_navigation({}, {:id => 'foobar_id'})).to have_selector("ul[id='foobar_id']")
112
112
  end
113
113
 
114
114
  it "should replace the default css class from the generated ul tag" do
115
- helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
115
+ expect(helper.render_navigation({}, {:class => 'foobar_class'})).to have_selector("ul[class='foobar_class']")
116
116
  end
117
117
  end
118
118
 
@@ -121,8 +121,8 @@ module Alchemy
121
121
 
122
122
  it "shows only pages up to this depth" do
123
123
  output = helper.render_navigation(deepness: 3, all_sub_menues: true)
124
- output.should have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
125
- output.should_not have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
124
+ expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
125
+ expect(output).not_to have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
126
126
  end
127
127
  end
128
128
 
@@ -133,13 +133,13 @@ module Alchemy
133
133
  before { FactoryGirl.create(:public_page, visible: true) }
134
134
 
135
135
  it "should render the given spacer" do
136
- helper.render_navigation(spacer: '•').should match(/•/)
136
+ expect(helper.render_navigation(spacer: '•')).to match(/•/)
137
137
  end
138
138
  end
139
139
 
140
140
  context "only one page in current level" do
141
141
  it "should not render the spacer" do
142
- helper.render_navigation(spacer: '•').should_not match(/•/)
142
+ expect(helper.render_navigation(spacer: '•')).not_to match(/•/)
143
143
  end
144
144
  end
145
145
  end
@@ -150,17 +150,17 @@ module Alchemy
150
150
  context "passing a page object" do
151
151
  it "should render the pages underneath the given one" do
152
152
  output = helper.render_navigation(from_page: visible_page)
153
- output.should_not have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
154
- output.should have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
153
+ expect(output).not_to have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
154
+ expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
155
155
  end
156
156
  end
157
157
 
158
158
  context "passing a page_layout" do
159
159
  it "should render the pages underneath the page with the given page_layout" do
160
- helper.stub(:page_or_find).with('contact').and_return(visible_page)
160
+ allow(helper).to receive(:page_or_find).with('contact').and_return(visible_page)
161
161
  output = helper.render_navigation(from_page: 'contact')
162
- output.should_not have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
163
- output.should have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
162
+ expect(output).not_to have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
163
+ expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
164
164
  end
165
165
  end
166
166
 
@@ -176,23 +176,23 @@ module Alchemy
176
176
  let(:user) { nil }
177
177
 
178
178
  before {
179
- helper.stub(:multi_language?).and_return(false)
180
- helper.stub(:current_ability).and_return(Alchemy::Permissions.new(user))
179
+ allow(helper).to receive(:multi_language?).and_return(false)
180
+ allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
181
181
  }
182
182
 
183
183
  it "should return nil if no @page is set" do
184
- helper.render_subnavigation.should be(nil)
184
+ expect(helper.render_subnavigation).to be(nil)
185
185
  end
186
186
 
187
187
  context "showing a page with level 2" do
188
188
  before { @page = level_2_page }
189
189
 
190
190
  it "should render the navigation from current page" do
191
- helper.render_subnavigation.should have_selector("ul > li > a[href='/#{level_2_page.urlname}']")
191
+ expect(helper.render_subnavigation).to have_selector("ul > li > a[href='/#{level_2_page.urlname}']")
192
192
  end
193
193
 
194
194
  it "should set current page active" do
195
- helper.render_subnavigation.should have_selector("a[href='/#{level_2_page.urlname}'].active")
195
+ expect(helper.render_subnavigation).to have_selector("a[href='/#{level_2_page.urlname}'].active")
196
196
  end
197
197
  end
198
198
 
@@ -200,11 +200,11 @@ module Alchemy
200
200
  before { @page = level_3_page }
201
201
 
202
202
  it "should render the navigation from current pages parent" do
203
- helper.render_subnavigation.should have_selector("ul > li > ul > li > a[href='/#{level_3_page.urlname}']")
203
+ expect(helper.render_subnavigation).to have_selector("ul > li > ul > li > a[href='/#{level_3_page.urlname}']")
204
204
  end
205
205
 
206
206
  it "should set current page active" do
207
- helper.render_subnavigation.should have_selector("a[href='/#{level_3_page.urlname}'].active")
207
+ expect(helper.render_subnavigation).to have_selector("a[href='/#{level_3_page.urlname}'].active")
208
208
  end
209
209
  end
210
210
 
@@ -212,16 +212,16 @@ module Alchemy
212
212
  before { @page = level_4_page }
213
213
 
214
214
  it "should render the navigation from current pages parents parent" do
215
- helper.render_subnavigation.should have_selector("ul > li > ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
215
+ expect(helper.render_subnavigation).to have_selector("ul > li > ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
216
216
  end
217
217
 
218
218
  it "should set current page active" do
219
- helper.render_subnavigation.should have_selector("a[href='/#{level_4_page.urlname}'].active")
219
+ expect(helper.render_subnavigation).to have_selector("a[href='/#{level_4_page.urlname}'].active")
220
220
  end
221
221
 
222
222
  context "beginning with level 3" do
223
223
  it "should render the navigation beginning from its parent" do
224
- helper.render_subnavigation(:level => 3).should have_selector("ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
224
+ expect(helper.render_subnavigation(:level => 3)).to have_selector("ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
225
225
  end
226
226
  end
227
227
  end
@@ -233,23 +233,23 @@ module Alchemy
233
233
  let(:user) { nil }
234
234
 
235
235
  before do
236
- helper.stub(:multi_language?).and_return(false)
237
- helper.stub(:current_ability).and_return(Alchemy::Permissions.new(user))
236
+ allow(helper).to receive(:multi_language?).and_return(false)
237
+ allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
238
238
  end
239
239
 
240
240
  it "should render a breadcrumb to current page" do
241
- helper.render_breadcrumb(page: page).should have_selector(".active.last[contains('#{page.name}')]")
241
+ expect(helper.render_breadcrumb(page: page)).to have_selector(".active.last[contains('#{page.name}')]")
242
242
  end
243
243
 
244
244
  context "with options[:separator] given" do
245
245
  it "should render a breadcrumb with an alternative separator" do
246
- helper.render_breadcrumb(page: page, separator: '<span>###</span>').should have_selector('span[contains("###")]')
246
+ expect(helper.render_breadcrumb(page: page, separator: '<span>###</span>')).to have_selector('span[contains("###")]')
247
247
  end
248
248
  end
249
249
 
250
250
  context "with options[:reverse] set to true" do
251
251
  it "should render a breadcrumb in reversed order" do
252
- helper.render_breadcrumb(page: page, reverse: true).should have_selector('.active.first[contains("A Public Page")]')
252
+ expect(helper.render_breadcrumb(page: page, reverse: true)).to have_selector('.active.first[contains("A Public Page")]')
253
253
  end
254
254
  end
255
255
 
@@ -258,39 +258,39 @@ module Alchemy
258
258
 
259
259
  it "should render a breadcrumb of restricted pages only" do
260
260
  page.update_attributes!(restricted: true, urlname: 'a-restricted-public-page', name: 'A restricted Public Page', title: 'A restricted Public Page')
261
- helper.render_breadcrumb(page: page, restricted_only: true).strip.should match(/^(<span(.[^>]+)>)A restricted Public Page/)
261
+ expect(helper.render_breadcrumb(page: page, restricted_only: true).strip).to match(/^(<span(.[^>]+)>)A restricted Public Page/)
262
262
  end
263
263
  end
264
264
 
265
265
  it "should render a breadcrumb of visible pages only" do
266
266
  page.update_attributes!(visible: false, urlname: 'a-invisible-page', name: 'A Invisible Page', title: 'A Invisible Page')
267
- helper.render_breadcrumb(page: page).should_not match(/A Invisible Page/)
267
+ expect(helper.render_breadcrumb(page: page)).not_to match(/A Invisible Page/)
268
268
  end
269
269
 
270
270
  it "should render a breadcrumb of visible and unpublished pages" do
271
271
  page.update_attributes!(public: false, urlname: 'a-unpublic-page', name: 'A Unpublic Page', title: 'A Unpublic Page')
272
- helper.render_breadcrumb(page: page).should match(/A Unpublic Page/)
272
+ expect(helper.render_breadcrumb(page: page)).to match(/A Unpublic Page/)
273
273
  end
274
274
 
275
275
  context "with options[:without]" do
276
276
  it "should render a breadcrumb without this page" do
277
277
  page.update_attributes!(urlname: 'not-me', name: 'Not Me', title: 'Not Me')
278
- helper.render_breadcrumb(page: page, without: page).should_not match(/Not Me/)
278
+ expect(helper.render_breadcrumb(page: page, without: page)).not_to match(/Not Me/)
279
279
  end
280
280
  end
281
281
 
282
282
  context "with options[:without] as array" do
283
283
  it "should render a breadcrumb without these pages." do
284
284
  page.update_attributes!(urlname: 'not-me', name: 'Not Me', title: 'Not Me')
285
- helper.render_breadcrumb(page: page, without: [page]).should_not match(/Not Me/)
285
+ expect(helper.render_breadcrumb(page: page, without: [page])).not_to match(/Not Me/)
286
286
  end
287
287
  end
288
288
  end
289
289
 
290
290
  describe "#render_meta_data" do
291
291
  context "@page is not set" do
292
- it "should reutrn nil" do
293
- expect(helper.render_meta_data.should).to eq(nil)
292
+ it "should return nil" do
293
+ expect(helper.render_meta_data).to eq(nil)
294
294
  end
295
295
  end
296
296
 
@@ -300,11 +300,11 @@ module Alchemy
300
300
  subject { helper.render_meta_data }
301
301
 
302
302
  it "should render meta keywords of current page" do
303
- should match /meta name="keywords" content="keyword1, keyword2"/
303
+ is_expected.to match /meta name="keywords" content="keyword1, keyword2"/
304
304
  end
305
305
 
306
306
  it "should render meta description 'blah blah' of current page" do
307
- should match /meta name="description" content="blah blah"/
307
+ is_expected.to match /meta name="description" content="blah blah"/
308
308
  end
309
309
  end
310
310
  end
@@ -314,11 +314,11 @@ module Alchemy
314
314
  before { helper.instance_variable_set('@page', page) }
315
315
 
316
316
  it "should render a title tag for current page" do
317
- helper.render_title_tag.should match /<title>A Public Page<\/title>/
317
+ expect(helper.render_title_tag).to match /<title>A Public Page<\/title>/
318
318
  end
319
319
 
320
320
  it "should render a title tag for current page with a prefix and a separator" do
321
- helper.render_title_tag(prefix: 'Peters Petshop', separator: ' ### ').should match /<title>Peters Petshop ### A Public Page<\/title>/
321
+ expect(helper.render_title_tag(prefix: 'Peters Petshop', separator: ' ### ')).to match /<title>Peters Petshop ### A Public Page<\/title>/
322
322
  end
323
323
  end
324
324
 
@@ -384,7 +384,7 @@ module Alchemy
384
384
  context "with options[:show_title]" do
385
385
  context "set to true" do
386
386
  it "should render the language links with titles" do
387
- helper.stub(:_t).and_return("my title")
387
+ allow(helper).to receive(:_t).and_return("my title")
388
388
  expect(helper.language_links(show_title: true)).to have_selector('a[title="my title"]')
389
389
  end
390
390
  end