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
@@ -8,37 +8,37 @@ module Alchemy
8
8
  describe '#dependencies' do
9
9
  context 'with alchemy/pages/show given as template name' do
10
10
  let(:name) { 'alchemy/pages/show' }
11
- before { PageLayout.stub(:all).and_return([{'name' => 'intro'}, {'name' => 'contact'}]) }
11
+ before { allow(PageLayout).to receive(:all).and_return([{'name' => 'intro'}, {'name' => 'contact'}]) }
12
12
 
13
13
  it "returns all page layout view partial names" do
14
- should include('alchemy/page_layouts/_intro', 'alchemy/page_layouts/_contact')
14
+ is_expected.to include('alchemy/page_layouts/_intro', 'alchemy/page_layouts/_contact')
15
15
  end
16
16
  end
17
17
 
18
18
  context 'with a page layout given as template name' do
19
19
  let(:name) { 'alchemy/page_layouts/_intro' }
20
20
  let(:page_layout) { {'name' => 'intro', 'elements' => ['text']} }
21
- before { PageLayout.stub(:get).and_return(page_layout) }
21
+ before { allow(PageLayout).to receive(:get).and_return(page_layout) }
22
22
 
23
23
  it "returns all element layout view partial names for that layout" do
24
- should include('alchemy/elements/_text_view')
24
+ is_expected.to include('alchemy/elements/_text_view')
25
25
  end
26
26
 
27
27
  context 'and page layout having cells' do
28
28
  let(:page_layout) { {'name' => 'intro', 'elements' => ['text'], 'cells' => ['header']} }
29
29
 
30
30
  it "returns all cell view partial names for that layout" do
31
- should include('alchemy/cells/_header')
31
+ is_expected.to include('alchemy/cells/_header')
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
36
  context 'with a cell given as template name' do
37
37
  let(:name) { 'alchemy/cells/_header' }
38
- before { Cell.stub(:definition_for).and_return({'name' => 'header', 'elements' => ['text']}) }
38
+ before { allow(Cell).to receive(:definition_for).and_return({'name' => 'header', 'elements' => ['text']}) }
39
39
 
40
40
  it "returns all element layout view partial names for that cell" do
41
- should include('alchemy/elements/_text_view')
41
+ is_expected.to include('alchemy/elements/_text_view')
42
42
  end
43
43
  end
44
44
 
@@ -47,17 +47,17 @@ module Alchemy
47
47
  let(:elements) { [{'name' => 'text', 'contents' => [{'type' => 'EssenceText'}]}] }
48
48
 
49
49
  context 'that is having a description' do
50
- before { Element.stub(:descriptions).and_return(elements) }
50
+ before { allow(Element).to receive(:descriptions).and_return(elements) }
51
51
 
52
52
  it "returns all essence layout view partial names for that element" do
53
- should include('alchemy/essences/_essence_text_view')
53
+ is_expected.to include('alchemy/essences/_essence_text_view')
54
54
  end
55
55
 
56
56
  context 'and element has picture_gallery enabled' do
57
57
  let(:elements) { [{'name' => 'text', 'picture_gallery' => true}] }
58
58
 
59
59
  it "has EssencePicture as template dependency" do
60
- should include('alchemy/essences/_essence_picture_view')
60
+ is_expected.to include('alchemy/essences/_essence_picture_view')
61
61
  end
62
62
  end
63
63
 
@@ -65,16 +65,16 @@ module Alchemy
65
65
  let(:elements) { [{'name' => 'text', 'available_contents' => ['type' => 'EssenceFile']}] }
66
66
 
67
67
  it "has these essences as template dependency" do
68
- should include('alchemy/essences/_essence_file_view')
68
+ is_expected.to include('alchemy/essences/_essence_file_view')
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
73
  context 'that has no description' do
74
- before { Element.stub(:descriptions).and_return([]) }
74
+ before { allow(Element).to receive(:descriptions).and_return([]) }
75
75
 
76
76
  it "returns empty array" do
77
- should be_empty
77
+ is_expected.to be_empty
78
78
  end
79
79
  end
80
80
  end
@@ -83,7 +83,7 @@ module Alchemy
83
83
  let(:name) { 'shop/cart' }
84
84
 
85
85
  it "calls rails template tracker" do
86
- ActionView::DependencyTracker::ERBTracker.should_receive(:call).with(name, nil)
86
+ expect(ActionView::DependencyTracker::ERBTracker).to receive(:call).with(name, nil)
87
87
  subject
88
88
  end
89
89
  end
@@ -7,7 +7,7 @@ module Alchemy
7
7
  subject { Tinymce.init }
8
8
 
9
9
  it "returns the default config" do
10
- should eq(Tinymce.class_variable_get('@@init'))
10
+ is_expected.to eq(Tinymce.class_variable_get('@@init'))
11
11
  end
12
12
  end
13
13
 
@@ -16,7 +16,7 @@ module Alchemy
16
16
 
17
17
  it "merges the default config with given config" do
18
18
  Tinymce.init = another_config
19
- Tinymce.init.should include(another_config)
19
+ expect(Tinymce.init).to include(another_config)
20
20
  end
21
21
  end
22
22
 
@@ -28,26 +28,26 @@ module Alchemy
28
28
  subject { Tinymce.custom_config_contents }
29
29
 
30
30
  before do
31
- Element.stub(:definitions).and_return([element_definition])
31
+ allow(Element).to receive(:definitions).and_return([element_definition])
32
32
  # Preventing memoization
33
33
  Tinymce.class_variable_set('@@custom_config_contents', nil)
34
34
  end
35
35
 
36
36
  it "returns an array of content definitions that contain custom tinymce config and element name" do
37
- should be_an(Array)
38
- should include({'element' => element_definition['name']}.merge(content_definition))
37
+ is_expected.to be_an(Array)
38
+ is_expected.to include({'element' => element_definition['name']}.merge(content_definition))
39
39
  end
40
40
 
41
41
  context 'with no contents having custom tinymce config' do
42
42
  let(:content_definition) { {'name' => 'text'} }
43
- it { should eq([]) }
43
+ it { is_expected.to eq([]) }
44
44
  end
45
45
 
46
46
  context 'with element definition having nil as contents value' do
47
47
  let(:element_definition) { {'name' => 'element', 'contents' => nil} }
48
48
 
49
49
  it "returns empty array" do
50
- should eq([])
50
+ is_expected.to eq([])
51
51
  end
52
52
  end
53
53
 
@@ -57,7 +57,7 @@ module Alchemy
57
57
 
58
58
  it "only returns custom tinymce config for elements of that page" do
59
59
  expect(page).to receive(:element_definitions).and_return([element_definition])
60
- should include({'element' => element_definition['name']}.merge(content_definition))
60
+ is_expected.to include({'element' => element_definition['name']}.merge(content_definition))
61
61
  end
62
62
  end
63
63
  end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe 'Alchemy::AuthAccessors' do
4
4
  describe '.user_class' do
5
5
  it "injects userstamp class methods" do
6
- Alchemy.user_class.should respond_to(:stamper_class_name)
7
- Alchemy.user_class.stamper_class_name.should eq(:DummyUser)
6
+ expect(Alchemy.user_class).to respond_to(:stamper_class_name)
7
+ expect(Alchemy.user_class.stamper_class_name).to eq(:DummyUser)
8
8
  end
9
9
  end
10
10
  end
@@ -7,16 +7,16 @@ module Alchemy
7
7
  let(:mail) { Messages.contact_form_mail(message, 'admin@page.com', 'contact@page.com', 'Subject') }
8
8
 
9
9
  it "delivers a mail to owner" do
10
- mail.to.should == ['admin@page.com']
11
- mail.subject.should == 'Subject'
10
+ expect(mail.to).to eq(['admin@page.com'])
11
+ expect(mail.subject).to eq('Subject')
12
12
  end
13
13
 
14
14
  it "reply_to should be set to senders email" do
15
- mail.reply_to.should == [message.email]
15
+ expect(mail.reply_to).to eq([message.email])
16
16
  end
17
17
 
18
18
  it "mail body includes message" do
19
- mail.body.should match /#{message.message}/
19
+ expect(mail.body).to match /#{message.message}/
20
20
  end
21
21
 
22
22
  end
@@ -9,7 +9,7 @@ module Alchemy
9
9
  describe 'after assign' do
10
10
  it "stores the file mime type into database" do
11
11
  attachment.update(file: file)
12
- attachment.file_mime_type.should_not be_blank
12
+ expect(attachment.file_mime_type).not_to be_blank
13
13
  end
14
14
  end
15
15
 
@@ -17,11 +17,11 @@ module Alchemy
17
17
  before { attachment.save! }
18
18
 
19
19
  it "should have a humanized name" do
20
- attachment.name.should == "image with spaces"
20
+ expect(attachment.name).to eq("image with spaces")
21
21
  end
22
22
 
23
23
  it "should have a valid file_name" do
24
- attachment.file_name.should == "image-with-spaces.png"
24
+ expect(attachment.file_name).to eq("image-with-spaces.png")
25
25
  end
26
26
 
27
27
  after { attachment.destroy }
@@ -31,19 +31,19 @@ module Alchemy
31
31
  it "should sanitize url characters in the filename" do
32
32
  attachment.file_name = 'f#%&cking cute kitten pic.png'
33
33
  attachment.save!
34
- attachment.urlname.should == 'f-cking-cute-kitten-pic.png'
34
+ expect(attachment.urlname).to eq('f-cking-cute-kitten-pic.png')
35
35
  end
36
36
 
37
37
  it "should sanitize lot of dots in the name" do
38
38
  attachment.file_name = 'cute.kitten.pic.png'
39
39
  attachment.save!
40
- attachment.urlname.should == 'cute-kitten-pic.png'
40
+ expect(attachment.urlname).to eq('cute-kitten-pic.png')
41
41
  end
42
42
 
43
43
  it "should sanitize umlauts in the name" do
44
44
  attachment.file_name = 'süßes katzenbild.png'
45
45
  attachment.save!
46
- attachment.urlname.should == 'suesses-katzenbild.png'
46
+ expect(attachment.urlname).to eq('suesses-katzenbild.png')
47
47
  end
48
48
 
49
49
  after { attachment.destroy }
@@ -52,18 +52,18 @@ module Alchemy
52
52
  describe 'validations' do
53
53
 
54
54
  context "having a png, but only pdf allowed" do
55
- before { Config.stub(:get).and_return({'allowed_filetypes' => {'attachments' => ['pdf']}}) }
55
+ before { allow(Config).to receive(:get).and_return({'allowed_filetypes' => {'attachments' => ['pdf']}}) }
56
56
 
57
57
  it "should not be valid" do
58
- attachment.should_not be_valid
58
+ expect(attachment).not_to be_valid
59
59
  end
60
60
  end
61
61
 
62
62
  context "having a png and everything allowed" do
63
- before { Config.stub(:get).and_return({'allowed_filetypes' => {'attachments' => ['*']}}) }
63
+ before { allow(Config).to receive(:get).and_return({'allowed_filetypes' => {'attachments' => ['*']}}) }
64
64
 
65
65
  it "should be valid" do
66
- attachment.should be_valid
66
+ expect(attachment).to be_valid
67
67
  end
68
68
  end
69
69
 
@@ -71,73 +71,129 @@ module Alchemy
71
71
 
72
72
  context 'PNG image' do
73
73
  subject { stub_model(Attachment, file_name: 'kitten.png') }
74
- its(:extension) { should == "png" }
74
+
75
+ describe '#extension' do
76
+ subject { super().extension }
77
+ it { is_expected.to eq("png") }
78
+ end
75
79
  end
76
80
 
77
81
  describe 'css classes' do
78
82
  context 'mp3 file' do
79
83
  subject { stub_model(Attachment, file_mime_type: 'audio/mpeg') }
80
- its(:icon_css_class) { should == "audio" }
84
+
85
+ describe '#icon_css_class' do
86
+ subject { super().icon_css_class }
87
+ it { is_expected.to eq("audio") }
88
+ end
81
89
  end
82
90
 
83
91
  context 'video file' do
84
92
  subject { stub_model(Attachment, file_mime_type: 'video/mpeg') }
85
- its(:icon_css_class) { should == "video" }
93
+
94
+ describe '#icon_css_class' do
95
+ subject { super().icon_css_class }
96
+ it { is_expected.to eq("video") }
97
+ end
86
98
  end
87
99
 
88
100
  context 'png file' do
89
101
  subject { stub_model(Attachment, file_mime_type: 'image/png') }
90
- its(:icon_css_class) { should == "image" }
102
+
103
+ describe '#icon_css_class' do
104
+ subject { super().icon_css_class }
105
+ it { is_expected.to eq("image") }
106
+ end
91
107
  end
92
108
 
93
109
  context 'vcf file' do
94
110
  subject { stub_model(Attachment, file_mime_type: 'application/vcard') }
95
- its(:icon_css_class) { should == "vcard" }
111
+
112
+ describe '#icon_css_class' do
113
+ subject { super().icon_css_class }
114
+ it { is_expected.to eq("vcard") }
115
+ end
96
116
  end
97
117
 
98
118
  context 'zip file' do
99
119
  subject { stub_model(Attachment, file_mime_type: 'application/zip') }
100
- its(:icon_css_class) { should == "archive" }
120
+
121
+ describe '#icon_css_class' do
122
+ subject { super().icon_css_class }
123
+ it { is_expected.to eq("archive") }
124
+ end
101
125
  end
102
126
 
103
127
  context 'flash file' do
104
128
  subject { stub_model(Attachment, file_mime_type: 'application/x-shockwave-flash') }
105
- its(:icon_css_class) { should == "flash" }
129
+
130
+ describe '#icon_css_class' do
131
+ subject { super().icon_css_class }
132
+ it { is_expected.to eq("flash") }
133
+ end
106
134
  end
107
135
 
108
136
  context 'photoshop file' do
109
137
  subject { stub_model(Attachment, file_mime_type: 'image/x-psd') }
110
- its(:icon_css_class) { should == "psd" }
138
+
139
+ describe '#icon_css_class' do
140
+ subject { super().icon_css_class }
141
+ it { is_expected.to eq("psd") }
142
+ end
111
143
  end
112
144
 
113
145
  context 'text file' do
114
146
  subject { stub_model(Attachment, file_mime_type: 'text/plain') }
115
- its(:icon_css_class) { should == "text" }
147
+
148
+ describe '#icon_css_class' do
149
+ subject { super().icon_css_class }
150
+ it { is_expected.to eq("text") }
151
+ end
116
152
  end
117
153
 
118
154
  context 'rtf file' do
119
155
  subject { stub_model(Attachment, file_mime_type: 'application/rtf') }
120
- its(:icon_css_class) { should == "rtf" }
156
+
157
+ describe '#icon_css_class' do
158
+ subject { super().icon_css_class }
159
+ it { is_expected.to eq("rtf") }
160
+ end
121
161
  end
122
162
 
123
163
  context 'pdf file' do
124
164
  subject { stub_model(Attachment, file_mime_type: 'application/pdf') }
125
- its(:icon_css_class) { should == "pdf" }
165
+
166
+ describe '#icon_css_class' do
167
+ subject { super().icon_css_class }
168
+ it { is_expected.to eq("pdf") }
169
+ end
126
170
  end
127
171
 
128
172
  context 'word file' do
129
173
  subject { stub_model(Attachment, file_mime_type: 'application/msword') }
130
- its(:icon_css_class) { should == "word" }
174
+
175
+ describe '#icon_css_class' do
176
+ subject { super().icon_css_class }
177
+ it { is_expected.to eq("word") }
178
+ end
131
179
  end
132
180
 
133
181
  context 'excel file' do
134
182
  subject { stub_model(Attachment, file_mime_type: 'application/vnd.ms-excel') }
135
- its(:icon_css_class) { should == "excel" }
183
+
184
+ describe '#icon_css_class' do
185
+ subject { super().icon_css_class }
186
+ it { is_expected.to eq("excel") }
187
+ end
136
188
  end
137
189
 
138
190
  context 'unknown file' do
139
191
  subject { stub_model(Attachment, file_mime_type: '') }
140
- its(:icon_css_class) { should == "file" }
192
+
193
+ describe '#icon_css_class' do
194
+ subject { super().icon_css_class }
195
+ it { is_expected.to eq("file") }
196
+ end
141
197
  end
142
198
  end
143
199
 
@@ -147,11 +203,11 @@ module Alchemy
147
203
  context 'if only on restricted pages' do
148
204
  before do
149
205
  pages = double(any?: true)
150
- pages.should_receive(:not_restricted).and_return([])
151
- attachment.should_receive(:pages).twice.and_return(pages)
206
+ expect(pages).to receive(:not_restricted).and_return([])
207
+ expect(attachment).to receive(:pages).twice.and_return(pages)
152
208
  end
153
209
 
154
- it { should be_true }
210
+ it { is_expected.to be_truthy }
155
211
  end
156
212
 
157
213
  context 'if not only on restricted pages' do
@@ -159,11 +215,11 @@ module Alchemy
159
215
 
160
216
  before do
161
217
  pages = double(any?: true)
162
- pages.should_receive(:not_restricted).and_return([page])
163
- attachment.should_receive(:pages).twice.and_return(pages)
218
+ expect(pages).to receive(:not_restricted).and_return([page])
219
+ expect(attachment).to receive(:pages).twice.and_return(pages)
164
220
  end
165
221
 
166
- it { should be_false }
222
+ it { is_expected.to be_falsey }
167
223
  end
168
224
  end
169
225
 
@@ -30,7 +30,7 @@ module Alchemy
30
30
 
31
31
  describe ".definitions_for_element" do
32
32
  before do
33
- Cell.stub(:definitions).and_return([
33
+ allow(Cell).to receive(:definitions).and_return([
34
34
  {'name' => 'cell_1', 'elements' => ['target', 'other']},
35
35
  {'name' => 'cell_2', 'elements' => ['other', 'other']},
36
36
  {'name' => 'cell_3', 'elements' => ['other', 'target']}
@@ -58,15 +58,15 @@ module Alchemy
58
58
  describe "#available_elements" do
59
59
  context "without assigned elements" do
60
60
  it "should return an empty Array" do
61
- cell.stub(:definition).and_return({})
62
- cell.available_elements.should == []
61
+ allow(cell).to receive(:definition).and_return({})
62
+ expect(cell.available_elements).to eq([])
63
63
  end
64
64
  end
65
65
 
66
66
  context "with assigned elements" do
67
67
  it "should return an Array of element names" do
68
- cell.stub(:definition).and_return({'elements' => ['test_element', 'test_element_2']})
69
- cell.available_elements.should == ['test_element', 'test_element_2']
68
+ allow(cell).to receive(:definition).and_return({'elements' => ['test_element', 'test_element_2']})
69
+ expect(cell.available_elements).to eq(['test_element', 'test_element_2'])
70
70
  end
71
71
  end
72
72
  end
@@ -74,22 +74,22 @@ module Alchemy
74
74
  describe "#definition" do
75
75
  context "without a definition for the expected cellname" do
76
76
  it "should return an empty Hash" do
77
- Cell.stub(:definition_for).and_return({})
78
- cell.definition.should == {}
77
+ allow(Cell).to receive(:definition_for).and_return({})
78
+ expect(cell.definition).to eq({})
79
79
  end
80
80
  end
81
81
 
82
82
  context "with a definition for the expected cellname found" do
83
83
  it "should return its definition Hash" do
84
- Cell.stub(:definition_for).and_return({'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']})
85
- cell.definition.should == {'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']}
84
+ allow(Cell).to receive(:definition_for).and_return({'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']})
85
+ expect(cell.definition).to eq({'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']})
86
86
  end
87
87
  end
88
88
  end
89
89
 
90
90
  describe "#name_for_label" do
91
91
  it "should call translated_label_for" do
92
- Cell.should_receive(:translated_label_for).with(cell.name)
92
+ expect(Cell).to receive(:translated_label_for).with(cell.name)
93
93
  cell.name_for_label
94
94
  end
95
95
  end