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
@@ -10,22 +10,22 @@ describe "Resources" do
10
10
 
11
11
  it "should have a button for creating a new resource items" do
12
12
  visit '/admin/events'
13
- page.should have_selector('#toolbar div.button_with_label a.icon_button span.icon.create')
13
+ expect(page).to have_selector('#toolbar div.button_with_label a.icon_button span.icon.create')
14
14
  end
15
15
 
16
16
  it "should list existing items" do
17
17
  event
18
18
  second_event
19
19
  visit '/admin/events'
20
- page.should have_content("My Event")
21
- page.should have_content("something fancy")
22
- page.should have_content("12.32")
20
+ expect(page).to have_content("My Event")
21
+ expect(page).to have_content("something fancy")
22
+ expect(page).to have_content("12.32")
23
23
  end
24
24
 
25
25
  it "should list existing resource-items nicely formatted" do
26
26
  event
27
27
  visit '/admin/events'
28
- page.should have_selector('div#archive_all table.list')
28
+ expect(page).to have_selector('div#archive_all table.list')
29
29
  end
30
30
 
31
31
  end
@@ -33,16 +33,16 @@ describe "Resources" do
33
33
  describe "form for creating and updating items" do
34
34
  it "renders an input field according to the attribute's type" do
35
35
  visit '/admin/events/new'
36
- page.should have_selector('input#event_name[type="text"]')
37
- page.should have_selector('input#event_starts_at[type="date"]')
38
- page.should have_selector('textarea#event_description')
39
- page.should have_selector('input#event_published[type="checkbox"]')
36
+ expect(page).to have_selector('input#event_name[type="text"]')
37
+ expect(page).to have_selector('input#event_starts_at[type="date"]')
38
+ expect(page).to have_selector('textarea#event_description')
39
+ expect(page).to have_selector('input#event_published[type="checkbox"]')
40
40
  end
41
41
 
42
42
  it "should have a select box for associated models" do
43
43
  visit '/admin/events/new'
44
44
  within('form') do
45
- page.should have_selector('select')
45
+ expect(page).to have_selector('select')
46
46
  end
47
47
  end
48
48
  end
@@ -58,12 +58,12 @@ describe "Resources" do
58
58
  end
59
59
 
60
60
  it "lists the new item" do
61
- page.should have_content "My second event"
62
- page.should have_content "03 Mar 2012"
61
+ expect(page).to have_content "My second event"
62
+ expect(page).to have_content "03 Mar 2012"
63
63
  end
64
64
 
65
65
  it "shows a success message" do
66
- page.should have_content("Succesfully created")
66
+ expect(page).to have_content("Succesfully created")
67
67
  end
68
68
  end
69
69
 
@@ -75,15 +75,15 @@ describe "Resources" do
75
75
  end
76
76
 
77
77
  it "shows the form again" do
78
- page.should have_selector "form input#event_name"
78
+ expect(page).to have_selector "form input#event_name"
79
79
  end
80
80
 
81
81
  it "lists invalid fields" do
82
- page.should have_content("can't be blank")
82
+ expect(page).to have_content("can't be blank")
83
83
  end
84
84
 
85
85
  it "should not display success notice" do
86
- page.should_not have_content("successfully created")
86
+ expect(page).not_to have_content("successfully created")
87
87
  end
88
88
  end
89
89
 
@@ -97,11 +97,11 @@ describe "Resources" do
97
97
  end
98
98
 
99
99
  it "shows the updated value" do
100
- page.should have_content("New event name")
100
+ expect(page).to have_content("New event name")
101
101
  end
102
102
 
103
103
  it "shows a success message" do
104
- page.should have_content("Succesfully updated")
104
+ expect(page).to have_content("Succesfully updated")
105
105
  end
106
106
  end
107
107
 
@@ -116,12 +116,12 @@ describe "Resources" do
116
116
  end
117
117
 
118
118
  it "shouldn't be on the list anymore" do
119
- page.should have_content "My Event"
120
- page.should_not have_content "My second Event"
119
+ expect(page).to have_content "My Event"
120
+ expect(page).not_to have_content "My second Event"
121
121
  end
122
122
 
123
123
  it "should display success message" do
124
- page.should have_content("Succesfully removed")
124
+ expect(page).to have_content("Succesfully removed")
125
125
  end
126
126
  end
127
127
 
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'TinyMCE Editor' do
4
+ let(:user) { DummyUser.new }
5
+
6
+ before do
7
+ user.update(alchemy_roles: %w(admin), name: "Joe User", id: 1)
8
+ authorize_as_admin(user)
9
+ end
10
+
11
+ it 'base path should be set to tinymce asset folder' do
12
+ visit admin_dashboard_path
13
+ expect(page).to have_content <<-TINYMCE
14
+ var tinyMCEPreInit = {
15
+ base: '/assets/tinymce',
16
+ suffix: '.min'
17
+ };
18
+ TINYMCE
19
+ end
20
+
21
+ context 'with asset host' do
22
+ before do
23
+ expect(ActionController::Base.config).to receive(:asset_host_set?).and_return(true)
24
+ end
25
+
26
+ it 'base path should be set to tinymce asset folder' do
27
+ visit admin_dashboard_path
28
+ expect(page).to have_content <<-TINYMCE
29
+ var tinyMCEPreInit = {
30
+ base: 'http://www.example.com/assets/tinymce',
31
+ suffix: '.min'
32
+ };
33
+ TINYMCE
34
+ end
35
+ end
36
+ end
@@ -4,6 +4,6 @@ describe "Dummy App" do
4
4
  include Capybara::DSL
5
5
 
6
6
  it "should be a valid app" do
7
- ::Rails.application.should be_a(Dummy::Application)
7
+ expect(::Rails.application).to be_a(Dummy::Application)
8
8
  end
9
9
  end
@@ -14,7 +14,7 @@ module Alchemy
14
14
  article = p.elements.find_by_name('article')
15
15
  article.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
16
16
  visit "/#{p.urlname}"
17
- within('div#content div.article div.intro') { page.should have_content('Welcome to Peters Petshop') }
17
+ within('div#content div.article div.intro') { expect(page).to have_content('Welcome to Peters Petshop') }
18
18
  end
19
19
 
20
20
  it "should show the navigation with all visible pages" do
@@ -23,39 +23,39 @@ module Alchemy
23
23
  FactoryGirl.create(:public_page, :visible => true, :name => 'Page 2')
24
24
  ]
25
25
  visit '/'
26
- within('div#navigation ul') { page.should have_selector('li a[href="/page-1"], li a[href="/page-2"]') }
26
+ within('div#navigation ul') { expect(page).to have_selector('li a[href="/page-1"], li a[href="/page-2"]') }
27
27
  end
28
28
 
29
29
  describe "redirecting" do
30
30
  context "in multi language mode" do
31
31
  before do
32
- Config.stub(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
33
- PagesController.any_instance.stub(:multi_language?).and_return(true)
32
+ allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
33
+ allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(true)
34
34
  end
35
35
 
36
36
  context "if no language params are given" do
37
37
  it "should redirect to url with nested language code" do
38
38
  visit "/#{public_page_1.urlname}"
39
- page.current_path.should == "/#{public_page_1.language_code}/#{public_page_1.urlname}"
39
+ expect(page.current_path).to eq("/#{public_page_1.language_code}/#{public_page_1.urlname}")
40
40
  end
41
41
  end
42
42
 
43
43
  context "if requested page is unpublished" do
44
44
  before do
45
- Config.stub(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
45
+ allow(Config).to receive(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
46
46
  public_page_1.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
47
47
  public_child
48
48
  end
49
49
 
50
50
  it "should redirect to public child" do
51
51
  visit "/#{default_language.code}/not-public"
52
- page.current_path.should == "/#{default_language.code}/public-child"
52
+ expect(page.current_path).to eq("/#{default_language.code}/public-child")
53
53
  end
54
54
 
55
55
  context "and url has no language code" do
56
56
  it "should redirect to url of public child with language code of default language" do
57
57
  visit '/not-public'
58
- page.current_path.should == "/#{default_language.code}/public-child"
58
+ expect(page.current_path).to eq("/#{default_language.code}/public-child")
59
59
  end
60
60
  end
61
61
  end
@@ -63,56 +63,56 @@ module Alchemy
63
63
  context "if requested url is index url" do
64
64
  it "should redirect to pages url with default language" do
65
65
  visit '/'
66
- page.current_path.should == "/#{default_language.code}/home"
66
+ expect(page.current_path).to eq("/#{default_language.code}/home")
67
67
  end
68
68
  end
69
69
 
70
70
  context "if requested url is only the language code" do
71
71
  it "should redirect to pages url with default language" do
72
72
  visit "/#{default_language.code}"
73
- page.current_path.should == "/#{default_language.code}/home"
73
+ expect(page.current_path).to eq("/#{default_language.code}/home")
74
74
  end
75
75
  end
76
76
 
77
77
  context "requested url is only the urlname" do
78
78
  it "then it should redirect to pages url with nested language." do
79
79
  visit '/home'
80
- page.current_path.should == '/en/home'
80
+ expect(page.current_path).to eq('/en/home')
81
81
  end
82
82
  end
83
83
 
84
84
  it "should keep additional params" do
85
85
  visit "/#{public_page_1.urlname}?query=Peter"
86
- page.current_url.should match(/\?query=Peter/)
86
+ expect(page.current_url).to match(/\?query=Peter/)
87
87
  end
88
88
 
89
89
  context "wrong language requested" do
90
- before { Alchemy.user_class.stub(:admins).and_return([1, 2]) }
90
+ before { allow(Alchemy.user_class).to receive(:admins).and_return([1, 2]) }
91
91
 
92
92
  it "should render 404 if urlname and lang parameter do not belong to same page" do
93
93
  FactoryGirl.create(:klingonian)
94
94
  visit "/kl/#{public_page_1.urlname}"
95
- page.status_code.should == 404
95
+ expect(page.status_code).to eq(404)
96
96
  end
97
97
 
98
98
  it "should render 404 if requested language does not exist" do
99
99
  public_page_1
100
100
  LegacyPageUrl.delete_all
101
101
  visit "/fo/#{public_page_1.urlname}"
102
- page.status_code.should == 404
102
+ expect(page.status_code).to eq(404)
103
103
  end
104
104
  end
105
105
  end
106
106
 
107
107
  context "not in multi language mode" do
108
108
  before do
109
- PagesController.any_instance.stub(:multi_language?).and_return(false)
110
- Config.stub(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
109
+ allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(false)
110
+ allow(Config).to receive(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
111
111
  end
112
112
 
113
113
  it "should redirect from nested language code url to normal url" do
114
114
  visit "/en/#{public_page_1.urlname}"
115
- page.current_path.should == "/#{public_page_1.urlname}"
115
+ expect(page.current_path).to eq("/#{public_page_1.urlname}")
116
116
  end
117
117
 
118
118
  context "should redirect to public child" do
@@ -123,35 +123,35 @@ module Alchemy
123
123
 
124
124
  it "if requested page is unpublished" do
125
125
  visit '/not-public'
126
- page.current_path.should == '/public-child'
126
+ expect(page.current_path).to eq('/public-child')
127
127
  end
128
128
 
129
129
  it "with normal url, if requested url has nested language code and is not public" do
130
130
  visit '/en/not-public'
131
- page.current_path.should == '/public-child'
131
+ expect(page.current_path).to eq('/public-child')
132
132
  end
133
133
  end
134
134
 
135
135
  it "should redirect to pages url, if requested url is index url" do
136
136
  visit '/'
137
- page.current_path.should == '/home'
137
+ expect(page.current_path).to eq('/home')
138
138
  end
139
139
 
140
140
  it "should keep additional params" do
141
141
  visit "/de/#{public_page_1.urlname}?query=Peter"
142
- page.current_url.should match(/\?query=Peter/)
142
+ expect(page.current_url).to match(/\?query=Peter/)
143
143
  end
144
144
  end
145
145
  end
146
146
 
147
147
  describe "Handling of non-existing pages" do
148
148
  before do
149
- Alchemy.user_class.stub(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
149
+ allow(Alchemy.user_class).to receive(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
150
150
  visit "/non-existing-page"
151
151
  end
152
152
 
153
153
  it "should render public/404.html" do
154
- page.status_code.should == 404
154
+ expect(page.status_code).to eq(404)
155
155
  end
156
156
  end
157
157
 
@@ -165,7 +165,7 @@ module Alchemy
165
165
  context "rendering for guest users" do
166
166
  it "is prohibited" do
167
167
  visit "/#{public_page_1.urlname}"
168
- within('body') { page.should_not have_selector('#alchemy_menubar') }
168
+ within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
169
169
  end
170
170
  end
171
171
 
@@ -173,7 +173,7 @@ module Alchemy
173
173
  it "is prohibited" do
174
174
  authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(member), language: 'en'))
175
175
  visit "/#{public_page_1.urlname}"
176
- within('body') { page.should_not have_selector('#alchemy_menubar') }
176
+ within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
177
177
  end
178
178
  end
179
179
 
@@ -181,7 +181,7 @@ module Alchemy
181
181
  it "is allowed" do
182
182
  authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(author), language: 'en', cache_key: 'aaa'))
183
183
  visit "/#{public_page_1.urlname}"
184
- within('body') { page.should have_selector('#alchemy_menubar') }
184
+ within('body') { expect(page).to have_selector('#alchemy_menubar') }
185
185
  end
186
186
  end
187
187
 
@@ -189,7 +189,7 @@ module Alchemy
189
189
  it "is allowed" do
190
190
  authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(editor), language: 'en', cache_key: 'aaa'))
191
191
  visit "/#{public_page_1.urlname}"
192
- within('body') { page.should have_selector('#alchemy_menubar') }
192
+ within('body') { expect(page).to have_selector('#alchemy_menubar') }
193
193
  end
194
194
  end
195
195
 
@@ -197,7 +197,7 @@ module Alchemy
197
197
  it "is allowed" do
198
198
  authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(admin), language: 'en', cache_key: 'aaa'))
199
199
  visit "/#{public_page_1.urlname}"
200
- within('body') { page.should have_selector('#alchemy_menubar') }
200
+ within('body') { expect(page).to have_selector('#alchemy_menubar') }
201
201
  end
202
202
  end
203
203
 
@@ -208,15 +208,15 @@ module Alchemy
208
208
  end
209
209
 
210
210
  it "a link to the admin area" do
211
- within('#alchemy_menubar') { page.should have_selector("li a[href='#{alchemy.admin_dashboard_path}']") }
211
+ within('#alchemy_menubar') { expect(page).to have_selector("li a[href='#{alchemy.admin_dashboard_path}']") }
212
212
  end
213
213
 
214
214
  it "a link to edit the current page" do
215
- within('#alchemy_menubar') { page.should have_selector("li a[href='#{alchemy.edit_admin_page_path(public_page_1)}']") }
215
+ within('#alchemy_menubar') { expect(page).to have_selector("li a[href='#{alchemy.edit_admin_page_path(public_page_1)}']") }
216
216
  end
217
217
 
218
218
  it "a form and button to logout of alchemy" do
219
- within('#alchemy_menubar') { page.should have_selector("li form[action='#{Alchemy.logout_path}'], li button[type='submit']") }
219
+ within('#alchemy_menubar') { expect(page).to have_selector("li form[action='#{Alchemy.logout_path}'], li button[type='submit']") }
220
220
  end
221
221
  end
222
222
  end
@@ -240,7 +240,7 @@ module Alchemy
240
240
  context 'as a guest user' do
241
241
  it "I am not able to visit the page" do
242
242
  visit restricted_page.urlname
243
- current_path.should == Alchemy.login_path
243
+ expect(current_path).to eq(Alchemy.login_path)
244
244
  end
245
245
  end
246
246
 
@@ -249,7 +249,7 @@ module Alchemy
249
249
 
250
250
  it "I am able to visit the page" do
251
251
  visit restricted_page.urlname
252
- current_path.should == "/#{restricted_page.urlname}"
252
+ expect(current_path).to eq("/#{restricted_page.urlname}")
253
253
  end
254
254
  end
255
255
  end
@@ -5,13 +5,13 @@ describe 'Picture renderung security', :js => true do
5
5
  let(:picture) { Alchemy::Picture.create(:image_file => File.new(File.expand_path('../../fixtures/image.png', __FILE__))) }
6
6
 
7
7
  # Prevent the signup view from being rendered.
8
- before { Alchemy.user_class.stub(:count).and_return 1 }
8
+ before { allow(Alchemy.user_class).to receive(:count).and_return 1 }
9
9
 
10
10
  context "passing no security token" do
11
11
 
12
12
  it 'should return a bad request (400)' do
13
13
  visit "/pictures/#{picture.id}/show/image.png"
14
- page.status_code.should == 400
14
+ expect(page.status_code).to eq(400)
15
15
  end
16
16
 
17
17
  end
@@ -23,11 +23,11 @@ describe 'Picture renderung security', :js => true do
23
23
  end
24
24
 
25
25
  it 'should return image' do
26
- page.body.should match(/img/)
26
+ expect(page.body).to match(/img/)
27
27
  end
28
28
 
29
29
  it 'should return status ok (200)' do
30
- page.status_code.should == 200
30
+ expect(page.status_code).to eq(200)
31
31
  end
32
32
 
33
33
  end
@@ -6,7 +6,7 @@ describe "Security." do
6
6
  context "If user is not logged in" do
7
7
  it "should see login form" do
8
8
  visit '/admin/dashboard'
9
- current_path.should == Alchemy.login_path
9
+ expect(current_path).to eq(Alchemy.login_path)
10
10
  end
11
11
  end
12
12
  end
@@ -6,33 +6,33 @@ describe "Translation integration" do
6
6
 
7
7
  it "should be possible to set the locale of the admin backend via params" do
8
8
  visit admin_dashboard_path(locale: 'de')
9
- page.should have_content('Willkommen')
9
+ expect(page).to have_content('Willkommen')
10
10
  end
11
11
 
12
12
  it "should store the current locale in the session" do
13
13
  visit admin_dashboard_path(locale: 'de')
14
14
  visit admin_dashboard_path
15
- page.should have_content('Willkommen')
15
+ expect(page).to have_content('Willkommen')
16
16
  end
17
17
 
18
18
  it "should be possible to change the current locale in the session" do
19
19
  visit admin_dashboard_path(locale: 'de')
20
- page.should have_content('Willkommen')
20
+ expect(page).to have_content('Willkommen')
21
21
  visit admin_dashboard_path(locale: 'en')
22
- page.should have_content('Welcome')
22
+ expect(page).to have_content('Welcome')
23
23
  end
24
24
 
25
25
  context 'with unknown locale' do
26
26
  it "it uses the users default language" do
27
27
  visit admin_dashboard_path(locale: 'ko')
28
- page.should have_content('Willkommen')
28
+ expect(page).to have_content('Willkommen')
29
29
  end
30
30
  end
31
31
 
32
32
  context "if no other parameter is given" do
33
33
  it "should use the current users language setting" do
34
34
  visit admin_dashboard_path
35
- page.should have_content('Willkommen')
35
+ expect(page).to have_content('Willkommen')
36
36
  end
37
37
  end
38
38
 
@@ -41,7 +41,7 @@ describe "Translation integration" do
41
41
 
42
42
  it "should use the browsers language setting if no other parameter is given" do
43
43
  visit admin_dashboard_path
44
- page.should have_content('Willkommen')
44
+ expect(page).to have_content('Willkommen')
45
45
  end
46
46
  end
47
47
  end