alchemy_cms 3.2.0.beta → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +661 -863
  3. data/README.md +5 -63
  4. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +11 -10
  5. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +6 -0
  6. data/app/assets/stylesheets/alchemy/_extends.scss +0 -6
  7. data/app/assets/stylesheets/alchemy/_mixins.scss +6 -0
  8. data/app/assets/stylesheets/alchemy/buttons.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/elements.scss +1 -1
  10. data/app/assets/stylesheets/alchemy/menubar.scss +1 -1
  11. data/app/assets/stylesheets/alchemy/selects.scss +5 -1
  12. data/app/assets/stylesheets/alchemy/upload.scss +1 -1
  13. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  14. data/app/controllers/alchemy/base_controller.rb +4 -57
  15. data/app/controllers/alchemy/messages_controller.rb +2 -2
  16. data/app/controllers/alchemy/pages_controller.rb +22 -31
  17. data/app/controllers/alchemy/pictures_controller.rb +2 -2
  18. data/app/helpers/alchemy/admin/base_helper.rb +7 -0
  19. data/app/helpers/alchemy/admin/elements_helper.rb +31 -15
  20. data/app/helpers/alchemy/admin/pages_helper.rb +17 -0
  21. data/app/helpers/alchemy/base_helper.rb +0 -28
  22. data/app/helpers/alchemy/pages_helper.rb +18 -12
  23. data/app/helpers/alchemy/url_helper.rb +2 -2
  24. data/app/models/alchemy/cell.rb +1 -1
  25. data/app/models/alchemy/content/factory.rb +12 -6
  26. data/app/models/alchemy/element.rb +3 -3
  27. data/app/models/alchemy/element/definitions.rb +1 -1
  28. data/app/models/alchemy/element_to_page.rb +7 -0
  29. data/app/models/alchemy/language.rb +1 -1
  30. data/app/models/alchemy/page.rb +8 -1
  31. data/app/models/alchemy/page/page_cells.rb +2 -2
  32. data/app/models/alchemy/page/page_elements.rb +23 -5
  33. data/app/models/alchemy/page/page_natures.rb +3 -3
  34. data/app/models/alchemy/page/page_scopes.rb +1 -1
  35. data/app/models/alchemy/picture.rb +1 -1
  36. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +1 -1
  37. data/app/views/alchemy/admin/pages/_form.html.erb +1 -1
  38. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  39. data/app/views/alchemy/breadcrumb/_page.html.erb +3 -2
  40. data/app/views/alchemy/breadcrumb/_separator.html.erb +1 -0
  41. data/app/views/alchemy/breadcrumb/_wrapper.html.erb +13 -0
  42. data/app/views/alchemy/language_links/_language.html.erb +1 -1
  43. data/app/views/alchemy/navigation/_link.html.erb +1 -1
  44. data/app/views/alchemy/pages/show.rss.builder +5 -7
  45. data/app/views/layouts/alchemy/admin.html.erb +5 -0
  46. data/config/routes.rb +13 -10
  47. data/lib/alchemy/configuration_methods.rb +29 -0
  48. data/lib/alchemy/controller_actions.rb +12 -4
  49. data/lib/alchemy/engine.rb +3 -0
  50. data/lib/alchemy/errors.rb +1 -1
  51. data/lib/alchemy/essence.rb +14 -12
  52. data/lib/alchemy/on_page_layout.rb +58 -0
  53. data/lib/alchemy/page_layout.rb +1 -1
  54. data/lib/alchemy/permissions.rb +21 -16
  55. data/lib/alchemy/routing_constraints.rb +49 -0
  56. data/lib/alchemy/seeder.rb +4 -2
  57. data/lib/alchemy/ssl_protection.rb +30 -0
  58. data/lib/alchemy/test_support/essence_shared_examples.rb +118 -25
  59. data/lib/alchemy/test_support/factories.rb +5 -8
  60. data/lib/alchemy/test_support/integration_helpers.rb +16 -10
  61. data/lib/alchemy/upgrader/three_point_two.rb +34 -4
  62. data/lib/alchemy/version.rb +1 -1
  63. data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_editor.html.erb +0 -0
  64. data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_view.html.erb +0 -0
  65. data/lib/rails/generators/alchemy/{scaffold → install}/files/_standard.html.erb +0 -0
  66. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.de.yml +0 -0
  67. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.elements.css.scss +0 -0
  68. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.en.yml +0 -0
  69. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.es.yml +0 -0
  70. data/lib/rails/generators/alchemy/{scaffold → install}/files/application.html.erb +0 -0
  71. data/lib/rails/generators/alchemy/install/install_generator.rb +69 -0
  72. data/lib/rails/generators/alchemy/{scaffold/files/elements.yml → install/templates/elements.yml.tt} +2 -0
  73. data/lib/rails/generators/alchemy/{scaffold → install}/templates/page_layouts.yml.tt +2 -0
  74. data/lib/rails/generators/alchemy/views/views_generator.rb +41 -0
  75. data/lib/rails/templates/alchemy.rb +2 -2
  76. data/lib/tasks/alchemy/db.rake +0 -5
  77. data/lib/tasks/alchemy/install.rake +10 -5
  78. data/lib/tasks/alchemy/tidy.rake +2 -0
  79. data/spec/controllers/admin/attachments_controller_spec.rb +1 -1
  80. data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
  81. data/spec/controllers/admin/contents_controller_spec.rb +1 -1
  82. data/spec/controllers/admin/dashboard_controller_spec.rb +2 -2
  83. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  84. data/spec/controllers/admin/essence_files_controller_spec.rb +1 -1
  85. data/spec/controllers/admin/essence_pictures_controller_spec.rb +1 -1
  86. data/spec/controllers/admin/languages_controller_spec.rb +1 -1
  87. data/spec/controllers/admin/layoutpages_controller_spec.rb +1 -1
  88. data/spec/controllers/admin/pages_controller_spec.rb +4 -4
  89. data/spec/controllers/admin/pictures_controller_spec.rb +1 -1
  90. data/spec/controllers/admin/resources_controller_spec.rb +1 -1
  91. data/spec/controllers/admin/trash_controller_spec.rb +1 -1
  92. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +1 -1
  93. data/spec/controllers/attachments_controller_spec.rb +1 -1
  94. data/spec/controllers/base_controller_spec.rb +22 -0
  95. data/spec/controllers/elements_controller_spec.rb +1 -1
  96. data/spec/controllers/pages_controller_spec.rb +15 -16
  97. data/spec/controllers/pictures_controller_spec.rb +212 -162
  98. data/spec/dummy/app/controllers/login_controller.rb +5 -0
  99. data/spec/dummy/app/models/dummy_model.rb +3 -0
  100. data/spec/dummy/config/alchemy/cells.yml +4 -1
  101. data/spec/dummy/config/alchemy/elements.yml +8 -0
  102. data/spec/dummy/config/alchemy/page_layouts.yml +5 -1
  103. data/spec/dummy/config/routes.rb +1 -2
  104. data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +7 -0
  105. data/spec/dummy/db/schema.rb +30 -26
  106. data/spec/features/admin/dashboard_spec.rb +11 -9
  107. data/spec/features/admin/language_tree_feature_spec.rb +5 -6
  108. data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
  109. data/spec/features/admin/link_overlay_spec.rb +1 -1
  110. data/spec/features/admin/locale_select_feature_spec.rb +1 -1
  111. data/spec/features/admin/modules_integration_spec.rb +1 -1
  112. data/spec/features/admin/navigation_feature_spec.rb +1 -1
  113. data/spec/features/admin/page_creation_feature_spec.rb +1 -1
  114. data/spec/features/admin/page_editing_feature_spec.rb +3 -3
  115. data/spec/features/admin/picture_library_integration_spec.rb +1 -1
  116. data/spec/features/admin/resources_integration_spec.rb +1 -1
  117. data/spec/features/admin/site_select_feature_spec.rb +32 -0
  118. data/spec/features/admin/tinymce_feature_spec.rb +1 -3
  119. data/spec/features/page_feature_spec.rb +36 -27
  120. data/spec/features/security_spec.rb +1 -1
  121. data/spec/features/translation_integration_spec.rb +3 -3
  122. data/spec/helpers/admin/elements_helper_spec.rb +103 -26
  123. data/spec/helpers/admin/pages_helper_spec.rb +32 -1
  124. data/spec/helpers/base_helper_spec.rb +0 -45
  125. data/spec/helpers/pages_helper_spec.rb +18 -17
  126. data/spec/helpers/url_helper_spec.rb +8 -5
  127. data/spec/libraries/controller_actions_spec.rb +2 -2
  128. data/spec/libraries/on_page_layout_spec.rb +112 -0
  129. data/spec/libraries/page_layout_spec.rb +5 -1
  130. data/spec/libraries/permissions_spec.rb +13 -15
  131. data/spec/models/cell_spec.rb +4 -0
  132. data/spec/models/content_spec.rb +6 -0
  133. data/spec/models/dummy_model_spec.rb +11 -0
  134. data/spec/models/element_spec.rb +6 -1
  135. data/spec/models/element_to_page_spec.rb +14 -0
  136. data/spec/models/page_spec.rb +111 -19
  137. data/spec/routing/routing_spec.rb +120 -101
  138. data/spec/spec_helper.rb +3 -3
  139. metadata +36 -21
  140. data/app/views/alchemy/breadcrumb/_spacer.html.erb +0 -1
  141. data/lib/alchemy/capistrano.rb +0 -230
  142. data/lib/alchemy/test_support/auth_helpers.rb +0 -35
  143. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +0 -90
  144. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +0 -113
  145. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -63
  146. data/spec/dummy/app/controllers/errors_controller.rb +0 -5
@@ -17,49 +17,6 @@ module Alchemy
17
17
  end
18
18
  end
19
19
 
20
- describe "#configuration" do
21
- it "should return certain configuration options" do
22
- allow(Config).to receive(:show).and_return({"some_option" => true})
23
- expect(helper.configuration(:some_option)).to eq(true)
24
- end
25
- end
26
-
27
- describe "#multi_language?" do
28
- context "if more than one published language exists" do
29
- it "should return true" do
30
- allow(Alchemy::Language).to receive(:published).and_return double(count: 2)
31
- expect(helper.multi_language?).to eq(true)
32
- end
33
- end
34
-
35
- context "if less than two published languages exists" do
36
- it "should return false" do
37
- allow(Alchemy::Language).to receive(:published).and_return double(count: 1)
38
- expect(helper.multi_language?).to eq(false)
39
- end
40
- end
41
- end
42
-
43
- describe '#breadcrumb' do
44
- let(:lang_root) { Page.language_root_for(Language.default.id) }
45
- let(:parent) { FactoryGirl.create(:public_page) }
46
- let(:page) { FactoryGirl.create(:public_page, parent_id: parent.id) }
47
-
48
- it "returns an array of all parents including self" do
49
- expect(helper.breadcrumb(page)).to eq([lang_root, parent, page])
50
- end
51
-
52
- it "does not include the root page" do
53
- expect(helper.breadcrumb(page)).not_to include(Page.root)
54
- end
55
-
56
- context "with current page nil" do
57
- it "should return an empty array" do
58
- expect(helper.breadcrumb(nil)).to eq([])
59
- end
60
- end
61
- end
62
-
63
20
  describe '#page_or_find' do
64
21
  let(:page) { FactoryGirl.create(:public_page) }
65
22
 
@@ -83,8 +40,6 @@ module Alchemy
83
40
  expect(helper.page_or_find(page)).to eq(page)
84
41
  end
85
42
  end
86
-
87
43
  end
88
-
89
44
  end
90
45
  end
@@ -1,26 +1,25 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- include Alchemy::BaseHelper
5
-
6
4
  module Alchemy
7
5
  describe PagesHelper do
8
6
 
9
7
  # Fixtures
10
- let(:language) { mock_model('Language', :code => 'en') }
11
- let(:default_language) { Language.default }
12
- let(:language_root) { FactoryGirl.create(:language_root_page) }
13
- let(:public_page) { FactoryGirl.create(:public_page) }
14
- let(:visible_page) { FactoryGirl.create(:public_page, :visible => true) }
15
- let(:restricted_page) { FactoryGirl.create(:public_page, :visible => true, :restricted => true) }
16
- let(:level_2_page) { FactoryGirl.create(:public_page, :parent_id => visible_page.id, :visible => true, :name => 'Level 2') }
17
- let(:level_3_page) { FactoryGirl.create(:public_page, :parent_id => level_2_page.id, :visible => true, :name => 'Level 3') }
18
- let(:level_4_page) { FactoryGirl.create(:public_page, :parent_id => level_3_page.id, :visible => true, :name => 'Level 4') }
19
- let(:klingonian) { FactoryGirl.create(:klingonian) }
20
- let(:klingonian_language_root) { FactoryGirl.create(:language_root_page, :language => klingonian) }
21
- let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
8
+ let(:language) { mock_model('Language', :code => 'en') }
9
+ let(:default_language) { Language.default }
10
+ let(:language_root) { FactoryGirl.create(:language_root_page) }
11
+ let(:public_page) { FactoryGirl.create(:public_page) }
12
+ let(:visible_page) { FactoryGirl.create(:public_page, :visible => true) }
13
+ let(:restricted_page) { FactoryGirl.create(:public_page, :visible => true, :restricted => true) }
14
+ let(:level_2_page) { FactoryGirl.create(:public_page, :parent_id => visible_page.id, :visible => true, :name => 'Level 2') }
15
+ let(:level_3_page) { FactoryGirl.create(:public_page, :parent_id => level_2_page.id, :visible => true, :name => 'Level 3') }
16
+ let(:level_4_page) { FactoryGirl.create(:public_page, :parent_id => level_3_page.id, :visible => true, :name => 'Level 4') }
17
+ let(:klingonian) { FactoryGirl.create(:klingonian) }
18
+ let(:klingonian_language_root) { FactoryGirl.create(:language_root_page, :language => klingonian) }
19
+ let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
22
20
 
23
21
  before do
22
+ helper.controller.class_eval { include Alchemy::ConfigurationMethods }
24
23
  allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
25
24
  @root_page = language_root # We need this instance variable in the helpers
26
25
  end
@@ -83,7 +82,7 @@ module Alchemy
83
82
  end
84
83
 
85
84
  context "as member user" do
86
- let(:user) { member_user }
85
+ let(:user) { build(:alchemy_dummy_user) }
87
86
 
88
87
  before { restricted_page }
89
88
 
@@ -254,11 +253,13 @@ module Alchemy
254
253
  end
255
254
 
256
255
  context "with options[:restricted_only] set to true" do
257
- let(:user) { member_user }
256
+ let(:user) { build(:alchemy_dummy_user) }
258
257
 
259
258
  it "should render a breadcrumb of restricted pages only" do
260
259
  page.update_attributes!(restricted: true, urlname: 'a-restricted-public-page', name: 'A restricted Public Page', title: 'A restricted Public Page')
261
- expect(helper.render_breadcrumb(page: page, restricted_only: true).strip).to match(/^(<span(.[^>]+)>)A restricted Public Page/)
260
+ result = helper.render_breadcrumb(page: page, restricted_only: true).strip
261
+ expect(result).to have_selector("*[contains(\"#{page.name}\")]")
262
+ expect(result).to_not have_selector("*[contains(\"#{parent.name}\")]")
262
263
  end
263
264
  end
264
265
 
@@ -1,12 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Alchemy::BaseHelper
4
3
  include Alchemy::ElementsHelper
5
4
 
6
5
  module Alchemy
7
6
  describe UrlHelper do
8
7
  let(:page) { mock_model(Page, urlname: 'testpage', language_code: 'en') }
9
8
 
9
+ before do
10
+ helper.controller.class_eval { include Alchemy::ConfigurationMethods }
11
+ end
12
+
10
13
  context 'page path helpers' do
11
14
  describe "#show_page_path_params" do
12
15
  context "when multi_language" do
@@ -17,12 +20,12 @@ module Alchemy
17
20
 
18
21
  it "should return a Hash with urlname and language_id parameter" do
19
22
  allow(helper).to receive(:multi_language?).and_return(true)
20
- expect(helper.show_page_path_params(page)).to include(urlname: 'testpage', lang: 'en')
23
+ expect(helper.show_page_path_params(page)).to include(urlname: 'testpage', locale: 'en')
21
24
  end
22
25
 
23
26
  it "should return a Hash with urlname, language_id and query parameter" do
24
27
  allow(helper).to receive(:multi_language?).and_return(true)
25
- expect(helper.show_page_path_params(page, {query: 'test'})).to include(urlname: 'testpage', lang: 'en', query: 'test')
28
+ expect(helper.show_page_path_params(page, {query: 'test'})).to include(urlname: 'testpage', locale: 'en', query: 'test')
26
29
  end
27
30
  end
28
31
 
@@ -33,12 +36,12 @@ module Alchemy
33
36
 
34
37
  it "should return a Hash with the urlname but without language_id parameter" do
35
38
  expect(helper.show_page_path_params(page)).to include(urlname: 'testpage')
36
- expect(helper.show_page_path_params(page)).not_to include(lang: 'en')
39
+ expect(helper.show_page_path_params(page)).not_to include(locale: 'en')
37
40
  end
38
41
 
39
42
  it "should return a Hash with urlname and query parameter" do
40
43
  expect(helper.show_page_path_params(page, {query: 'test'})).to include(urlname: 'testpage', query: 'test')
41
- expect(helper.show_page_path_params(page)).not_to include(lang: 'en')
44
+ expect(helper.show_page_path_params(page)).not_to include(locale: 'en')
42
45
  end
43
46
  end
44
47
  end
@@ -109,7 +109,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
109
109
 
110
110
  context "with lang param" do
111
111
  it "should set the language" do
112
- allow(controller).to receive(:params).and_return(lang: klingonian.code)
112
+ allow(controller).to receive(:params).and_return(locale: klingonian.code)
113
113
  controller.send :set_alchemy_language
114
114
  expect(assigns(:language)).to eq(klingonian)
115
115
  expect(Alchemy::Language.current).to eq(klingonian)
@@ -118,7 +118,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
118
118
 
119
119
  context "for language that does not exist" do
120
120
  before do
121
- allow(controller).to receive(:params).and_return(lang: 'fo')
121
+ allow(controller).to receive(:params).and_return(locale: 'fo')
122
122
  controller.send :set_alchemy_language
123
123
  end
124
124
 
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Alchemy::PagesController, 'OnPageLayout mixin', type: :controller do
4
+ before(:all) do
5
+ ApplicationController.send(:extend, Alchemy::OnPageLayout)
6
+ end
7
+
8
+ let(:page) { create(:public_page, page_layout: 'standard') }
9
+
10
+ describe 'defines .on_page_layout class method' do
11
+ context 'with :all as parameter' do
12
+ context 'and block given' do
13
+ before do
14
+ ApplicationController.class_eval do
15
+ on_page_layout(:all) do
16
+ @successful_for_all = true
17
+ @the_page_instance = @page
18
+ end
19
+ end
20
+ end
21
+
22
+ it 'runs on all page layouts' do
23
+ alchemy_get :show, urlname: page.urlname
24
+ expect(assigns(:successful_for_all)).to be_truthy
25
+ end
26
+
27
+ it 'has @page instance' do
28
+ alchemy_get :show, urlname: page.urlname
29
+ expect(assigns(:the_page_instance)).to eq(page)
30
+ end
31
+ end
32
+
33
+ context 'and method name instead of block given' do
34
+ before do
35
+ ApplicationController.class_eval do
36
+ on_page_layout :all, :my_all_callback_method
37
+
38
+ def my_all_callback_method
39
+ @successful_for_all_callback_method = true
40
+ @the_all_page_instance = @page
41
+ end
42
+ end
43
+ end
44
+
45
+ it 'runs on all page layouts' do
46
+ alchemy_get :show, urlname: page.urlname
47
+ expect(assigns(:successful_for_all_callback_method)).to be_truthy
48
+ end
49
+
50
+ it 'has @page instance' do
51
+ alchemy_get :show, urlname: page.urlname
52
+ expect(assigns(:the_all_page_instance)).to eq(page)
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'with :standard as parameter' do
58
+ before do
59
+ ApplicationController.class_eval do
60
+ on_page_layout(:standard) do
61
+ @successful_for_standard = true
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'and page having standard layout' do
67
+ it 'runs callback' do
68
+ alchemy_get :show, urlname: page.urlname
69
+ expect(assigns(:successful_for_standard)).to be_truthy
70
+ end
71
+ end
72
+
73
+ context 'and page not having standard layout' do
74
+ let(:page) { create(:public_page, page_layout: 'news') }
75
+
76
+ it "doesn't run callback" do
77
+ alchemy_get :show, urlname: page.urlname
78
+ expect(assigns(:successful_for_standard)).to be_falsey
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ RSpec.describe ApplicationController, 'OnPageLayout mixin', type: :controller do
86
+ before(:all) do
87
+ ApplicationController.send(:extend, Alchemy::OnPageLayout)
88
+ end
89
+
90
+ controller do
91
+ def index
92
+ @another_controller = true
93
+ render nothing: true
94
+ end
95
+ end
96
+
97
+ context 'in another controller' do
98
+ before do
99
+ ApplicationController.class_eval do
100
+ on_page_layout(:standard) do
101
+ @successful_for_another_controller = true
102
+ end
103
+ end
104
+ end
105
+
106
+ it 'callback does not run' do
107
+ get :index
108
+ expect(assigns(:another_controller)).to be_truthy
109
+ expect(assigns(:successful_for_another_controller)).to be_falsey
110
+ end
111
+ end
112
+ end
@@ -14,8 +14,12 @@ module Alchemy
14
14
  expect(subject.collect { |l| l['name'] }).to include('standard')
15
15
  end
16
16
 
17
+ it "should allow erb generated layouts" do
18
+ expect(subject.collect { |l| l['name'] }).to include('erb_layout')
19
+ end
20
+
17
21
  context "with empty layouts file" do
18
- before { expect(YAML).to receive(:load_file).and_return(false) }
22
+ before { expect(YAML).to receive(:load).and_return(false) }
19
23
 
20
24
  it "returns empty array" do
21
25
  is_expected.to eq([])
@@ -33,14 +33,13 @@ describe Alchemy::Permissions do
33
33
  is_expected.not_to be_able_to(:show, restricted_attachment)
34
34
  end
35
35
 
36
- it "can only download not restricted pictures" do
37
- is_expected.to be_able_to(:download, picture)
38
- is_expected.not_to be_able_to(:download, restricted_picture)
39
- end
40
-
41
36
  it "can only see not restricted pictures" do
42
37
  is_expected.to be_able_to(:show, picture)
38
+ is_expected.to be_able_to(:thumbnail, picture)
39
+ is_expected.to be_able_to(:zoom, picture)
43
40
  is_expected.not_to be_able_to(:show, restricted_picture)
41
+ is_expected.not_to be_able_to(:thumbnail, restricted_picture)
42
+ is_expected.not_to be_able_to(:zoom, restricted_picture)
44
43
  end
45
44
 
46
45
  it "can only visit not restricted pages" do
@@ -71,7 +70,7 @@ describe Alchemy::Permissions do
71
70
  end
72
71
 
73
72
  context "A member" do
74
- let(:user) { member_user }
73
+ let(:user) { build(:alchemy_dummy_user) }
75
74
 
76
75
  it "can download all attachments" do
77
76
  is_expected.to be_able_to(:download, attachment)
@@ -83,14 +82,13 @@ describe Alchemy::Permissions do
83
82
  is_expected.to be_able_to(:show, restricted_attachment)
84
83
  end
85
84
 
86
- it "can download all pictures" do
87
- is_expected.to be_able_to(:download, picture)
88
- is_expected.to be_able_to(:download, restricted_picture)
89
- end
90
-
91
85
  it "can see all pictures" do
92
86
  is_expected.to be_able_to(:show, picture)
87
+ is_expected.to be_able_to(:thumbnail, picture)
88
+ is_expected.to be_able_to(:zoom, picture)
93
89
  is_expected.to be_able_to(:show, restricted_picture)
90
+ is_expected.to be_able_to(:thumbnail, restricted_picture)
91
+ is_expected.to be_able_to(:zoom, restricted_picture)
94
92
  end
95
93
 
96
94
  it "can visit restricted pages" do
@@ -125,7 +123,7 @@ describe Alchemy::Permissions do
125
123
  end
126
124
 
127
125
  context "An author" do
128
- let(:user) { author_user }
126
+ let(:user) { build(:alchemy_dummy_user, :as_author) }
129
127
 
130
128
  it "can leave the admin area" do
131
129
  is_expected.to be_able_to(:leave, :alchemy_admin)
@@ -198,7 +196,7 @@ describe Alchemy::Permissions do
198
196
  end
199
197
 
200
198
  context "An editor" do
201
- let(:user) { editor_user }
199
+ let(:user) { build(:alchemy_dummy_user, :as_editor) }
202
200
 
203
201
  it "can manage pages" do
204
202
  is_expected.to be_able_to(:copy, Alchemy::Page)
@@ -237,7 +235,7 @@ describe Alchemy::Permissions do
237
235
  end
238
236
 
239
237
  context "An admin" do
240
- let(:user) { admin_user }
238
+ let(:user) { build(:alchemy_dummy_user, :as_admin) }
241
239
 
242
240
  it "can check for alchemy updates" do
243
241
  is_expected.to be_able_to(:update_check, :alchemy_admin_dashboard)
@@ -253,7 +251,7 @@ describe Alchemy::Permissions do
253
251
  end
254
252
 
255
253
  context "A logged in user without a role" do
256
- let(:user) { mock_user([]) }
254
+ let(:user) { mock_model(Alchemy.user_class, alchemy_roles: []) }
257
255
 
258
256
  it "can only see visible not restricted pages (like the guest role)" do
259
257
  is_expected.to be_able_to(:see, visible_page)
@@ -10,6 +10,10 @@ module Alchemy
10
10
  it "should return an Array" do
11
11
  expect(Cell.definitions).to be_a(Array)
12
12
  end
13
+
14
+ it "should allow erb generated definitions" do
15
+ expect(Cell.definitions.collect { |d| d['name']} ).to include('erb_cell')
16
+ end
13
17
  end
14
18
 
15
19
  describe '.definition_for' do
@@ -22,6 +22,12 @@ module Alchemy
22
22
  expect(Content.normalize_essence_type('EssenceText')).to eq("Alchemy::EssenceText")
23
23
  end
24
24
  end
25
+
26
+ context "passing non-namespaced essence type for an existing non-namespaced essence" do
27
+ it "should not add alchemy namespace" do
28
+ expect(Content.normalize_essence_type('DummyModel')).to eq("DummyModel")
29
+ end
30
+ end
25
31
  end
26
32
 
27
33
  describe '#normalized_essence_type' do
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'A User-defined Essence' do
4
+
5
+ describe DummyModel do
6
+ it_behaves_like "an essence" do
7
+ let(:essence) { DummyModel.new }
8
+ let(:ingredient_value) { "Some String" }
9
+ end
10
+ end
11
+ end
@@ -33,6 +33,10 @@ module Alchemy
33
33
  end
34
34
 
35
35
  describe '.definitions' do
36
+ it "should allow erb generated elements" do
37
+ expect(Element.definitions.collect { |el| el['name']} ).to include('erb_element')
38
+ end
39
+
36
40
  context "without existing yml files" do
37
41
  before { allow(File).to receive(:exists?).and_return(false) }
38
42
 
@@ -42,7 +46,8 @@ module Alchemy
42
46
  end
43
47
 
44
48
  context "without any definitions in elements.yml" do
45
- before { allow(YAML).to receive(:load_file).and_return(false) } # Yes, YAML.load_file returns false if an empty file exists.
49
+ # Yes, YAML.load returns false if an empty file exists.
50
+ before { allow(YAML).to receive(:load).and_return(false) }
46
51
 
47
52
  it "should return an empty array" do
48
53
  expect(Element.definitions).to eq([])