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
@@ -6,31 +6,31 @@ describe Alchemy::MountPoint do
6
6
  describe '.get' do
7
7
 
8
8
  it "returns the path of alchemy's mount point" do
9
- Alchemy::MountPoint.stub(:mount_point).and_return('/cms')
10
- Alchemy::MountPoint.get.should == '/cms'
9
+ allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/cms')
10
+ expect(Alchemy::MountPoint.get).to eq('/cms')
11
11
  end
12
12
 
13
13
  it "removes the leading slash if root mount point" do
14
- Alchemy::MountPoint.stub(:mount_point).and_return('/')
15
- Alchemy::MountPoint.get.should == ''
14
+ allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/')
15
+ expect(Alchemy::MountPoint.get).to eq('')
16
16
  end
17
17
 
18
18
  context "with remove_leading_slash_if_blank set to false" do
19
19
  before {
20
- Alchemy::MountPoint.stub(:mount_point).and_return('/')
20
+ allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/')
21
21
  }
22
22
 
23
23
  it "does not remove the leading white slash of path" do
24
- Alchemy::MountPoint.get(false).should == '/'
24
+ expect(Alchemy::MountPoint.get(false)).to eq('/')
25
25
  end
26
26
 
27
27
  context "and with mount point not root" do
28
28
  before {
29
- Alchemy::MountPoint.stub(:mount_point).and_return('/cms')
29
+ allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/cms')
30
30
  }
31
31
 
32
32
  it "does not remove the leading white slash of path" do
33
- Alchemy::MountPoint.get(false).should == '/cms'
33
+ expect(Alchemy::MountPoint.get(false)).to eq('/cms')
34
34
  end
35
35
  end
36
36
  end
@@ -38,23 +38,23 @@ describe Alchemy::MountPoint do
38
38
 
39
39
  describe '.routes' do
40
40
  it "returns the routes object from alchemy engine" do
41
- Alchemy::MountPoint.routes.should be_instance_of(ActionDispatch::Journey::Route)
41
+ expect(Alchemy::MountPoint.routes).to be_instance_of(ActionDispatch::Journey::Route)
42
42
  end
43
43
  end
44
44
 
45
45
  describe '.mount_point' do
46
46
  it 'returns the raw mount point path from routes' do
47
- Alchemy::MountPoint.stub(:routes).and_return(OpenStruct.new(path: OpenStruct.new(spec: '/cms')))
48
- Alchemy::MountPoint.mount_point.should == '/cms'
47
+ allow(Alchemy::MountPoint).to receive(:routes).and_return(OpenStruct.new(path: OpenStruct.new(spec: '/cms')))
48
+ expect(Alchemy::MountPoint.mount_point).to eq('/cms')
49
49
  end
50
50
 
51
51
  context "Alchemy routes could not be found" do
52
52
  before {
53
- Alchemy::MountPoint.stub(:routes).and_return(nil)
53
+ allow(Alchemy::MountPoint).to receive(:routes).and_return(nil)
54
54
  }
55
55
 
56
56
  it "falls back to root path" do
57
- Alchemy::MountPoint.mount_point.should == '/'
57
+ expect(Alchemy::MountPoint.mount_point).to eq('/')
58
58
  end
59
59
  end
60
60
  end
@@ -10,20 +10,20 @@ module Alchemy
10
10
  subject { PageLayout.all }
11
11
 
12
12
  it "should return all page_layouts" do
13
- should be_instance_of(Array)
14
- subject.collect { |l| l['name'] }.should include('standard')
13
+ is_expected.to be_instance_of(Array)
14
+ expect(subject.collect { |l| l['name'] }).to include('standard')
15
15
  end
16
16
 
17
17
  context "with empty layouts file" do
18
- before { YAML.should_receive(:load_file).and_return(false) }
18
+ before { expect(YAML).to receive(:load_file).and_return(false) }
19
19
 
20
20
  it "returns empty array" do
21
- should == []
21
+ is_expected.to eq([])
22
22
  end
23
23
  end
24
24
 
25
25
  context "with missing layouts file" do
26
- before { File.should_receive(:exists?).and_return(false) }
26
+ before { expect(File).to receive(:exists?).and_return(false) }
27
27
 
28
28
  it "raises error empty array" do
29
29
  expect { subject }.to raise_error(LoadError)
@@ -34,19 +34,19 @@ module Alchemy
34
34
  describe '.add' do
35
35
  it "adds a definition to all definitions" do
36
36
  PageLayout.add({'name' => 'foo'})
37
- PageLayout.all.should include({'name' => 'foo'})
37
+ expect(PageLayout.all).to include({'name' => 'foo'})
38
38
  end
39
39
 
40
40
  it "adds a array of definitions to all definitions" do
41
41
  PageLayout.add([{'name' => 'foo'}, {'name' => 'bar'}])
42
- PageLayout.all.should include({'name' => 'foo'})
43
- PageLayout.all.should include({'name' => 'bar'})
42
+ expect(PageLayout.all).to include({'name' => 'foo'})
43
+ expect(PageLayout.all).to include({'name' => 'bar'})
44
44
  end
45
45
  end
46
46
 
47
47
  describe ".get" do
48
48
  it "should return the page_layout description found by given name" do
49
- PageLayout.stub(:all).and_return([{'name' => 'default'}, {'name' => 'contact'}])
49
+ allow(PageLayout).to receive(:all).and_return([{'name' => 'default'}, {'name' => 'contact'}])
50
50
  expect(PageLayout.get('default')).to eq({'name' => 'default'})
51
51
  end
52
52
  end
@@ -55,7 +55,7 @@ module Alchemy
55
55
  it "should not hold a layout twice" do
56
56
  layouts = PageLayout.layouts_with_own_for_select('standard', 1, false)
57
57
  layouts = layouts.collect(&:last)
58
- layouts.select { |l| l == "standard" }.length.should == 1
58
+ expect(layouts.select { |l| l == "standard" }.length).to eq(1)
59
59
  end
60
60
  end
61
61
 
@@ -65,35 +65,35 @@ module Alchemy
65
65
  subject { PageLayout.selectable_layouts(language.id) }
66
66
 
67
67
  it "should not display hidden page layouts" do
68
- subject.each { |l| l['hide'].should_not == true }
68
+ subject.each { |l| expect(l['hide']).not_to eq(true) }
69
69
  end
70
70
 
71
71
  context "with already taken layouts" do
72
- before {
73
- PageLayout.stub(:all).and_return([{'unique' => true}])
74
- Page.stub_chain(:where, :pluck).and_return([1])
75
- }
72
+ before do
73
+ allow(PageLayout).to receive(:all).and_return([{'unique' => true}])
74
+ allow(Page).to receive(:where).and_return double(pluck: [1])
75
+ end
76
76
 
77
77
  it "should not include unique layouts" do
78
- subject.each { |l| l['unique'].should_not == true }
78
+ subject.each { |l| expect(l['unique']).not_to eq(true) }
79
79
  end
80
80
  end
81
81
 
82
82
  context "with sites layouts present" do
83
83
  let(:site) { Site.new }
84
84
  let(:definitions) { [{'name' => 'default_site', 'page_layouts' => %w(intro)}] }
85
- before { Site.stub(:layout_definitions).and_return(definitions) }
85
+ before { allow(Site).to receive(:layout_definitions).and_return(definitions) }
86
86
 
87
87
  it "should only return layouts for site" do
88
- subject.length.should == 1
89
- subject.first['name'].should == 'intro'
88
+ expect(subject.length).to eq(1)
89
+ expect(subject.first['name']).to eq('intro')
90
90
  end
91
91
  end
92
92
  end
93
93
 
94
94
  describe ".element_names_for" do
95
95
  it "should return all element names for the given pagelayout" do
96
- PageLayout.stub(:get).with('default').and_return({'name' => 'default', 'elements' => ['element_1', 'element_2']})
96
+ allow(PageLayout).to receive(:get).with('default').and_return({'name' => 'default', 'elements' => ['element_1', 'element_2']})
97
97
  expect(PageLayout.element_names_for('default')).to eq(['element_1', 'element_2'])
98
98
  end
99
99
 
@@ -105,7 +105,7 @@ module Alchemy
105
105
 
106
106
  context "when page_layout description does not contain the elements key" do
107
107
  it "should return an empty array" do
108
- PageLayout.stub(:get).with('layout_without_elements_key').and_return({'name' => 'layout_without_elements_key'})
108
+ allow(PageLayout).to receive(:get).with('layout_without_elements_key').and_return({'name' => 'layout_without_elements_key'})
109
109
  expect(PageLayout.element_names_for('layout_without_elements_key')).to eq([])
110
110
  end
111
111
  end
@@ -117,15 +117,15 @@ module Alchemy
117
117
 
118
118
  context "with no translation present" do
119
119
  it "returns the name capitalized" do
120
- should == 'Contact'
120
+ is_expected.to eq('Contact')
121
121
  end
122
122
  end
123
123
 
124
124
  context "with translation present" do
125
- before { I18n.should_receive(:t).and_return('Kontakt') }
125
+ before { expect(I18n).to receive(:t).and_return('Kontakt') }
126
126
 
127
127
  it "returns the translated name" do
128
- should == 'Kontakt'
128
+ is_expected.to eq('Kontakt')
129
129
  end
130
130
  end
131
131
  end
@@ -15,45 +15,58 @@ describe Alchemy::Permissions do
15
15
  let(:not_visible_page) { build_stubbed(:public_page, restricted: false, visible: false) }
16
16
  let(:restricted_page) { build_stubbed(:public_page, public: true, restricted: true) }
17
17
  let(:visible_restricted_page) { build_stubbed(:page, visible: true, restricted: true) }
18
- let(:published_element) { mock_model(Alchemy::Element, public: true, page: public_page) }
19
- let(:restricted_element) { mock_model(Alchemy::Element, public: true, page: restricted_page) }
18
+ let(:published_element) { mock_model(Alchemy::Element, restricted?: false, public?: true, trashed?: false) }
19
+ let(:restricted_element) { mock_model(Alchemy::Element, restricted?: true, public?: true, trashed?: false) }
20
+ let(:published_content) { mock_model(Alchemy::Content, restricted?: false, public?: true, trashed?: false) }
21
+ let(:restricted_content) { mock_model(Alchemy::Content, restricted?: true, public?: true, trashed?: false) }
20
22
 
21
23
  context "A guest user" do
22
24
  let(:user) { nil }
23
25
 
24
26
  it "can only download not restricted attachments" do
25
- should be_able_to(:download, attachment)
26
- should_not be_able_to(:download, restricted_attachment)
27
+ is_expected.to be_able_to(:download, attachment)
28
+ is_expected.not_to be_able_to(:download, restricted_attachment)
27
29
  end
28
30
 
29
31
  it "can only see not restricted attachments" do
30
- should be_able_to(:show, attachment)
31
- should_not be_able_to(:show, restricted_attachment)
32
+ is_expected.to be_able_to(:show, attachment)
33
+ is_expected.not_to be_able_to(:show, restricted_attachment)
32
34
  end
33
35
 
34
36
  it "can only download not restricted pictures" do
35
- should be_able_to(:download, picture)
36
- should_not be_able_to(:download, restricted_picture)
37
+ is_expected.to be_able_to(:download, picture)
38
+ is_expected.not_to be_able_to(:download, restricted_picture)
37
39
  end
38
40
 
39
41
  it "can only see not restricted pictures" do
40
- should be_able_to(:show, picture)
41
- should_not be_able_to(:show, restricted_picture)
42
+ is_expected.to be_able_to(:show, picture)
43
+ is_expected.not_to be_able_to(:show, restricted_picture)
42
44
  end
43
45
 
44
46
  it "can only visit not restricted pages" do
45
- should be_able_to(:show, public_page)
46
- should_not be_able_to(:show, restricted_page)
47
+ is_expected.to be_able_to(:show, public_page)
48
+ is_expected.not_to be_able_to(:show, restricted_page)
49
+ is_expected.to be_able_to(:index, public_page)
50
+ is_expected.not_to be_able_to(:index, restricted_page)
47
51
  end
48
52
 
49
53
  it "can only see visible not restricted pages" do
50
- should be_able_to(:see, visible_page)
51
- should_not be_able_to(:see, not_visible_page)
54
+ is_expected.to be_able_to(:see, visible_page)
55
+ is_expected.not_to be_able_to(:see, not_visible_page)
52
56
  end
53
57
 
54
58
  it "can only see public not restricted elements" do
55
- should be_able_to(:show, published_element)
56
- should_not be_able_to(:show, restricted_element)
59
+ is_expected.to be_able_to(:show, published_element)
60
+ is_expected.not_to be_able_to(:show, restricted_element)
61
+ is_expected.to be_able_to(:index, published_element)
62
+ is_expected.not_to be_able_to(:index, restricted_element)
63
+ end
64
+
65
+ it "can only see public not restricted contents" do
66
+ is_expected.to be_able_to(:show, published_content)
67
+ is_expected.not_to be_able_to(:show, restricted_content)
68
+ is_expected.to be_able_to(:index, published_content)
69
+ is_expected.not_to be_able_to(:index, restricted_content)
57
70
  end
58
71
  end
59
72
 
@@ -61,42 +74,53 @@ describe Alchemy::Permissions do
61
74
  let(:user) { member_user }
62
75
 
63
76
  it "can download all attachments" do
64
- should be_able_to(:download, attachment)
65
- should be_able_to(:download, restricted_attachment)
77
+ is_expected.to be_able_to(:download, attachment)
78
+ is_expected.to be_able_to(:download, restricted_attachment)
66
79
  end
67
80
 
68
81
  it "can see all attachments" do
69
- should be_able_to(:show, attachment)
70
- should be_able_to(:show, restricted_attachment)
82
+ is_expected.to be_able_to(:show, attachment)
83
+ is_expected.to be_able_to(:show, restricted_attachment)
71
84
  end
72
85
 
73
86
  it "can download all pictures" do
74
- should be_able_to(:download, picture)
75
- should be_able_to(:download, restricted_picture)
87
+ is_expected.to be_able_to(:download, picture)
88
+ is_expected.to be_able_to(:download, restricted_picture)
76
89
  end
77
90
 
78
91
  it "can see all pictures" do
79
- should be_able_to(:show, picture)
80
- should be_able_to(:show, restricted_picture)
92
+ is_expected.to be_able_to(:show, picture)
93
+ is_expected.to be_able_to(:show, restricted_picture)
81
94
  end
82
95
 
83
96
  it "can visit restricted pages" do
84
- should be_able_to(:show, public_page)
85
- should be_able_to(:show, restricted_page)
97
+ is_expected.to be_able_to(:show, public_page)
98
+ is_expected.to be_able_to(:show, restricted_page)
99
+ is_expected.to be_able_to(:index, public_page)
100
+ is_expected.to be_able_to(:index, restricted_page)
86
101
  end
87
102
 
88
103
  it "can see visible restricted pages" do
89
- should be_able_to(:see, visible_page)
90
- should be_able_to(:see, visible_restricted_page)
104
+ is_expected.to be_able_to(:see, visible_page)
105
+ is_expected.to be_able_to(:see, visible_restricted_page)
91
106
  end
92
107
 
93
108
  it "can not see invisible pages" do
94
- should_not be_able_to(:see, not_visible_page)
109
+ is_expected.not_to be_able_to(:see, not_visible_page)
95
110
  end
96
111
 
97
112
  it "can see public restricted elements" do
98
- should be_able_to(:show, published_element)
99
- should be_able_to(:show, restricted_element)
113
+ is_expected.to be_able_to(:show, published_element)
114
+ is_expected.to be_able_to(:show, restricted_element)
115
+ is_expected.to be_able_to(:index, published_element)
116
+ is_expected.to be_able_to(:index, restricted_element)
117
+ end
118
+
119
+ it "can see public restricted contents" do
120
+ is_expected.to be_able_to(:show, published_content)
121
+ is_expected.to be_able_to(:show, restricted_content)
122
+ is_expected.to be_able_to(:index, published_content)
123
+ is_expected.to be_able_to(:index, restricted_content)
100
124
  end
101
125
  end
102
126
 
@@ -104,68 +128,65 @@ describe Alchemy::Permissions do
104
128
  let(:user) { author_user }
105
129
 
106
130
  it "can visit the dashboard" do
107
- should be_able_to(:index, :alchemy_admin_dashboard)
108
- should be_able_to(:info, :alchemy_admin_dashboard)
131
+ is_expected.to be_able_to(:index, :alchemy_admin_dashboard)
132
+ is_expected.to be_able_to(:info, :alchemy_admin_dashboard)
109
133
  end
110
134
 
111
135
  it "can see picture thumbnails" do
112
- should be_able_to(:thumbnail, Alchemy::Picture)
136
+ is_expected.to be_able_to(:thumbnail, Alchemy::Picture)
113
137
  end
114
138
 
115
139
  it "can edit page content" do
116
- should be_able_to(:show, unpublic_page)
117
- should be_able_to(:index, Alchemy::Page)
118
- should be_able_to(:info, Alchemy::Page)
119
- should be_able_to(:configure, Alchemy::Page)
120
- should be_able_to(:update, Alchemy::Page)
121
- should be_able_to(:fold, Alchemy::Page)
122
- should be_able_to(:link, Alchemy::Page)
123
- should be_able_to(:visit, Alchemy::Page)
124
- should be_able_to(:unlock, Alchemy::Page)
125
- end
126
-
127
- it "can not publish pages" do
128
- should_not be_able_to(:publish, Alchemy::Page)
140
+ is_expected.to be_able_to(:show, unpublic_page)
141
+ is_expected.to be_able_to(:index, Alchemy::Page)
142
+ is_expected.to be_able_to(:info, Alchemy::Page)
143
+ is_expected.to be_able_to(:configure, Alchemy::Page)
144
+ is_expected.to be_able_to(:update, Alchemy::Page)
145
+ is_expected.to be_able_to(:fold, Alchemy::Page)
146
+ is_expected.to be_able_to(:link, Alchemy::Page)
147
+ is_expected.to be_able_to(:visit, Alchemy::Page)
148
+ is_expected.to be_able_to(:unlock, Alchemy::Page)
149
+ is_expected.to be_able_to(:publish, Alchemy::Page)
129
150
  end
130
151
 
131
152
  it "can manage elements" do
132
- should be_able_to(:manage, Alchemy::Element)
153
+ is_expected.to be_able_to(:manage, Alchemy::Element)
133
154
  end
134
155
 
135
156
  it "can see all attachments" do
136
- should be_able_to(:read, Alchemy::Attachment)
137
- should be_able_to(:download, Alchemy::Attachment)
157
+ is_expected.to be_able_to(:read, Alchemy::Attachment)
158
+ is_expected.to be_able_to(:download, Alchemy::Attachment)
138
159
  end
139
160
 
140
161
  it "can see all pictures" do
141
- should be_able_to(:read, Alchemy::Picture)
142
- should be_able_to(:info, Alchemy::Picture)
162
+ is_expected.to be_able_to(:read, Alchemy::Picture)
163
+ is_expected.to be_able_to(:info, Alchemy::Picture)
143
164
  end
144
165
 
145
166
  it "can manage contents" do
146
- should be_able_to(:manage, Alchemy::Content)
167
+ is_expected.to be_able_to(:manage, Alchemy::Content)
147
168
  end
148
169
 
149
170
  it "can manage essences" do
150
- should be_able_to(:manage, Alchemy::EssencePicture)
151
- should be_able_to(:manage, Alchemy::EssenceFile)
171
+ is_expected.to be_able_to(:manage, Alchemy::EssencePicture)
172
+ is_expected.to be_able_to(:manage, Alchemy::EssenceFile)
152
173
  end
153
174
 
154
175
  it "can see the trash" do
155
- should be_able_to(:index, :trash)
176
+ is_expected.to be_able_to(:index, :trash)
156
177
  end
157
178
 
158
179
  it "can manage the clipboard" do
159
- should be_able_to(:manage, :alchemy_admin_clipboard)
180
+ is_expected.to be_able_to(:manage, :alchemy_admin_clipboard)
160
181
  end
161
182
 
162
183
  it "can see tags" do
163
- should be_able_to(:read, Alchemy::Tag)
164
- should be_able_to(:autocomplete, Alchemy::Tag)
184
+ is_expected.to be_able_to(:read, Alchemy::Tag)
185
+ is_expected.to be_able_to(:autocomplete, Alchemy::Tag)
165
186
  end
166
187
 
167
188
  it "can index layoutpages" do
168
- should be_able_to(:index, :alchemy_admin_layoutpages)
189
+ is_expected.to be_able_to(:index, :alchemy_admin_layoutpages)
169
190
  end
170
191
  end
171
192
 
@@ -173,38 +194,34 @@ describe Alchemy::Permissions do
173
194
  let(:user) { editor_user }
174
195
 
175
196
  it "can manage pages" do
176
- should be_able_to(:copy, Alchemy::Page)
177
- should be_able_to(:copy_language_tree, Alchemy::Page)
178
- should be_able_to(:create, Alchemy::Page)
179
- should be_able_to(:destroy, Alchemy::Page)
180
- should be_able_to(:flush, Alchemy::Page)
181
- should be_able_to(:order, Alchemy::Page)
182
- should be_able_to(:sort, Alchemy::Page)
183
- should be_able_to(:switch_language, Alchemy::Page)
184
- end
185
-
186
- it "can publish pages" do
187
- should be_able_to(:publish, Alchemy::Page)
197
+ is_expected.to be_able_to(:copy, Alchemy::Page)
198
+ is_expected.to be_able_to(:copy_language_tree, Alchemy::Page)
199
+ is_expected.to be_able_to(:create, Alchemy::Page)
200
+ is_expected.to be_able_to(:destroy, Alchemy::Page)
201
+ is_expected.to be_able_to(:flush, Alchemy::Page)
202
+ is_expected.to be_able_to(:order, Alchemy::Page)
203
+ is_expected.to be_able_to(:sort, Alchemy::Page)
204
+ is_expected.to be_able_to(:switch_language, Alchemy::Page)
188
205
  end
189
206
 
190
207
  it "can not see invisible pages" do
191
- should_not be_able_to(:see, not_visible_page)
208
+ is_expected.not_to be_able_to(:see, not_visible_page)
192
209
  end
193
210
 
194
211
  it "can clear the trash" do
195
- should be_able_to(:clear, :trash)
212
+ is_expected.to be_able_to(:clear, :trash)
196
213
  end
197
214
 
198
215
  it "can manage attachments" do
199
- should be_able_to(:manage, Alchemy::Attachment)
216
+ is_expected.to be_able_to(:manage, Alchemy::Attachment)
200
217
  end
201
218
 
202
219
  it "can manage pictures" do
203
- should be_able_to(:manage, Alchemy::Picture)
220
+ is_expected.to be_able_to(:manage, Alchemy::Picture)
204
221
  end
205
222
 
206
223
  it "can manage tags" do
207
- should be_able_to(:manage, Alchemy::Tag)
224
+ is_expected.to be_able_to(:manage, Alchemy::Tag)
208
225
  end
209
226
  end
210
227
 
@@ -212,15 +229,15 @@ describe Alchemy::Permissions do
212
229
  let(:user) { admin_user }
213
230
 
214
231
  it "can check for alchemy updates" do
215
- should be_able_to(:update_check, :alchemy_admin_dashboard)
232
+ is_expected.to be_able_to(:update_check, :alchemy_admin_dashboard)
216
233
  end
217
234
 
218
235
  it "can manage languages" do
219
- should be_able_to(:manage, Alchemy::Language)
236
+ is_expected.to be_able_to(:manage, Alchemy::Language)
220
237
  end
221
238
 
222
239
  it "can manage sites" do
223
- should be_able_to(:manage, Alchemy::Site)
240
+ is_expected.to be_able_to(:manage, Alchemy::Site)
224
241
  end
225
242
  end
226
243
  end