alchemy_cms 3.0.4 → 3.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -6
- data/Gemfile +4 -7
- data/README.md +207 -115
- data/alchemy_cms.gemspec +10 -9
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
- data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +2 -2
- data/app/assets/javascripts/alchemy/alchemy.js +6 -7
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -43
- data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +1 -1
- data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
- data/app/assets/stylesheets/alchemy/buttons.scss +0 -5
- data/app/assets/stylesheets/alchemy/dialogs.scss +1 -0
- data/app/assets/stylesheets/alchemy/frame.scss +9 -12
- data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +11 -2
- data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +9 -1
- data/app/controllers/alchemy/admin/attachments_controller.rb +2 -4
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +34 -38
- data/app/controllers/alchemy/api/base_controller.rb +19 -0
- data/app/controllers/alchemy/api/contents_controller.rb +35 -0
- data/app/controllers/alchemy/api/elements_controller.rb +29 -0
- data/app/controllers/alchemy/api/pages_controller.rb +32 -0
- data/app/controllers/alchemy/contents_controller.rb +1 -0
- data/app/controllers/alchemy/elements_controller.rb +5 -2
- data/app/controllers/alchemy/pages_controller.rb +4 -1
- data/app/controllers/alchemy/pictures_controller.rb +4 -36
- data/app/helpers/alchemy/admin/essences_helper.rb +5 -2
- data/app/helpers/alchemy/essences_helper.rb +14 -1
- data/app/models/alchemy/content.rb +32 -4
- data/app/models/alchemy/element.rb +2 -16
- data/app/models/alchemy/element/presenters.rb +2 -2
- data/app/models/alchemy/essence_file.rb +5 -0
- data/app/models/alchemy/essence_picture.rb +12 -8
- data/app/models/alchemy/picture.rb +1 -74
- data/app/models/alchemy/picture/transformations.rb +249 -0
- data/app/serializers/alchemy/content_serializer.rb +3 -10
- data/app/serializers/alchemy/element_serializer.rb +6 -3
- data/app/serializers/alchemy/legacy_element_serializer.rb +17 -0
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +14 -4
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +8 -5
- data/app/views/alchemy/admin/pages/edit.html.erb +9 -9
- data/app/views/alchemy/admin/pictures/info.html.erb +2 -3
- data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +8 -7
- data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -3
- data/app/views/alchemy/essences/_essence_date_editor.html.erb +8 -2
- data/app/views/alchemy/essences/_essence_date_view.html.erb +10 -8
- data/app/views/alchemy/essences/_essence_file_editor.html.erb +48 -53
- data/app/views/alchemy/essences/_essence_file_view.html.erb +5 -5
- data/app/views/alchemy/essences/_essence_html_editor.html.erb +5 -4
- data/app/views/alchemy/essences/_essence_link_editor.html.erb +17 -15
- data/app/views/alchemy/essences/_essence_link_view.html.erb +11 -7
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -2
- data/app/views/alchemy/essences/_essence_picture_view.html.erb +4 -2
- data/app/views/alchemy/essences/_essence_richtext_view.html.erb +5 -4
- data/app/views/alchemy/essences/_essence_select_editor.html.erb +22 -32
- data/app/views/alchemy/essences/_essence_text_view.html.erb +7 -6
- data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +1 -1
- data/app/views/layouts/alchemy/admin.html.erb +5 -3
- data/config/initializers/inflections.rb +3 -0
- data/config/initializers/simple_form.rb +1 -1
- data/config/locales/alchemy.en.yml +0 -1
- data/config/routes.rb +14 -0
- data/lib/alchemy/capistrano.rb +71 -0
- data/lib/alchemy/engine.rb +0 -3
- data/lib/alchemy/essence.rb +1 -1
- data/lib/alchemy/permissions.rb +19 -5
- data/lib/alchemy/picture_attributes.rb +1 -1
- data/lib/alchemy/test_support/auth_helpers.rb +1 -1
- data/lib/alchemy/test_support/essence_shared_examples.rb +37 -22
- data/lib/alchemy/test_support/integration_helpers.rb +1 -1
- data/lib/alchemy/tinymce.rb +21 -4
- data/lib/alchemy/upgrader/three_point_one.rb +43 -0
- data/lib/alchemy/upgrader/three_point_zero.rb +13 -0
- data/lib/alchemy/version.rb +2 -1
- data/lib/rails/generators/alchemy/module/module_generator.rb +30 -0
- data/lib/rails/generators/alchemy/module/templates/ability.rb.tt +11 -0
- data/lib/rails/generators/alchemy/module/templates/controller.rb.tt +2 -0
- data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +15 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -1
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +7 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +38 -38
- data/spec/controllers/admin/base_controller_spec.rb +18 -18
- data/spec/controllers/admin/clipboard_controller_spec.rb +23 -18
- data/spec/controllers/admin/contents_controller_spec.rb +33 -27
- data/spec/controllers/admin/dashboard_controller_spec.rb +14 -14
- data/spec/controllers/admin/elements_controller_spec.rb +125 -105
- data/spec/controllers/admin/essence_files_controller_spec.rb +6 -7
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +52 -42
- data/spec/controllers/admin/languages_controller_spec.rb +3 -3
- data/spec/controllers/admin/pages_controller_spec.rb +81 -71
- data/spec/controllers/admin/pictures_controller_spec.rb +69 -72
- data/spec/controllers/admin/resources_controller_spec.rb +5 -5
- data/spec/controllers/admin/trash_controller_spec.rb +15 -12
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +8 -8
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +73 -0
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +69 -0
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +86 -0
- data/spec/controllers/attachments_controller_spec.rb +8 -8
- data/spec/controllers/contents_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +10 -4
- data/spec/controllers/messages_controller_spec.rb +35 -34
- data/spec/controllers/pages_controller_spec.rb +37 -28
- data/spec/controllers/pictures_controller_spec.rb +90 -23
- data/spec/dummy/app/models/dummy_user.rb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +11 -0
- data/spec/dummy/config/alchemy/elements.yml +22 -1
- data/spec/dummy/config/alchemy/page_layouts.yml +4 -0
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/environments/test.rb +3 -1
- data/spec/features/admin/dashboard_spec.rb +41 -6
- data/spec/features/admin/language_tree_feature_spec.rb +3 -3
- data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
- data/spec/features/admin/link_overlay_spec.rb +7 -7
- data/spec/features/admin/locale_select_feature_spec.rb +5 -2
- data/spec/features/admin/modules_integration_spec.rb +1 -1
- data/spec/features/admin/page_creation_feature_spec.rb +3 -2
- data/spec/features/admin/page_editing_feature_spec.rb +66 -79
- data/spec/features/admin/picture_library_integration_spec.rb +8 -8
- data/spec/features/admin/resources_integration_spec.rb +21 -21
- data/spec/features/admin/tinymce_feature_spec.rb +36 -0
- data/spec/features/navigation_spec.rb +1 -1
- data/spec/features/page_feature_spec.rb +34 -34
- data/spec/features/picture_security_spec.rb +4 -4
- data/spec/features/security_spec.rb +1 -1
- data/spec/features/translation_integration_spec.rb +7 -7
- data/spec/helpers/admin/base_helper_spec.rb +51 -49
- data/spec/helpers/admin/contents_helper_spec.rb +11 -11
- data/spec/helpers/admin/elements_helper_spec.rb +20 -17
- data/spec/helpers/admin/essences_helper_spec.rb +42 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +64 -54
- data/spec/helpers/admin/pages_helper_spec.rb +10 -10
- data/spec/helpers/admin/tags_helper_spec.rb +16 -16
- data/spec/helpers/base_helper_spec.rb +11 -11
- data/spec/helpers/elements_block_helper_spec.rb +24 -24
- data/spec/helpers/elements_helper_spec.rb +46 -46
- data/spec/helpers/essences_helper_spec.rb +90 -17
- data/spec/helpers/pages_helper_spec.rb +53 -53
- data/spec/helpers/picture_url_helpers_spec.rb +6 -6
- data/spec/helpers/url_helper_spec.rb +32 -32
- data/spec/libraries/config_spec.rb +9 -9
- data/spec/libraries/controller_actions_spec.rb +14 -14
- data/spec/libraries/i18n_spec.rb +6 -6
- data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +4 -4
- data/spec/libraries/modules_spec.rb +4 -4
- data/spec/libraries/mount_point_spec.rb +13 -13
- data/spec/libraries/page_layout_spec.rb +24 -24
- data/spec/libraries/permissions_spec.rb +97 -80
- data/spec/libraries/resource_spec.rb +37 -37
- data/spec/libraries/resources_helper_spec.rb +19 -19
- data/spec/libraries/shell_spec.rb +17 -17
- data/spec/libraries/template_tracker_spec.rb +14 -14
- data/spec/libraries/tinymce_spec.rb +8 -8
- data/spec/libraries/userstamp_spec.rb +2 -2
- data/spec/mailers/messages_spec.rb +4 -4
- data/spec/models/attachment_spec.rb +86 -30
- data/spec/models/cell_spec.rb +10 -10
- data/spec/models/content_spec.rb +106 -46
- data/spec/models/element_spec.rb +94 -115
- data/spec/models/essence_date_spec.rb +1 -1
- data/spec/models/essence_file_spec.rb +4 -4
- data/spec/models/essence_picture_spec.rb +56 -25
- data/spec/models/essence_richtext_spec.rb +1 -1
- data/spec/models/essence_text_spec.rb +7 -7
- data/spec/models/language_spec.rb +12 -12
- data/spec/models/legacy_page_url_spec.rb +2 -2
- data/spec/models/message_spec.rb +12 -5
- data/spec/models/page_spec.rb +259 -235
- data/spec/models/picture_spec.rb +72 -166
- data/spec/models/site_spec.rb +41 -41
- data/spec/models/tag_spec.rb +7 -7
- data/spec/routing/api_routing_spec.rb +150 -0
- data/spec/routing/routing_spec.rb +28 -28
- data/spec/spec_helper.rb +6 -5
- data/spec/support/hint_examples.rb +5 -5
- data/spec/support/transformation_examples.rb +173 -0
- data/spec/tasks/helpers_spec.rb +29 -29
- data/spec/views/essences/essence_boolean_editor_spec.rb +32 -0
- data/spec/views/essences/essence_boolean_view_spec.rb +2 -2
- data/spec/views/essences/essence_date_view_spec.rb +1 -1
- data/spec/views/essences/essence_link_view_spec.rb +11 -0
- data/spec/views/essences/essence_picture_view_spec.rb +56 -11
- data/spec/views/essences/essence_richtext_view_spec.rb +12 -0
- data/spec/views/essences/essence_text_view_spec.rb +12 -0
- data/vendor/assets/javascripts/tinymce/langs/de.js +20 -2
- data/vendor/assets/javascripts/tinymce/langs/fr.js +14 -1
- data/vendor/assets/javascripts/tinymce/langs/nl.js +22 -4
- data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/tinymce.min.js +11 -10
- metadata +72 -42
- data/app/views/alchemy/messages/contact_form_mail.es.text.erb +0 -12
- data/config/locales/alchemy.es.yml +0 -958
- data/config/locales/alchemy.ru.yml +0 -837
- data/config/locales/simple_form.es.yml +0 -6
- data/config/locales/simple_form.ru.yml +0 -25
- data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +0 -31
- data/vendor/assets/javascripts/tinymce/langs/es.js +0 -197
- data/vendor/assets/javascripts/tinymce/langs/ru.js +0 -197
|
@@ -49,95 +49,98 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
49
49
|
|
|
50
50
|
describe '#alchemy_main_navigation_entry' do
|
|
51
51
|
before do
|
|
52
|
-
helper.
|
|
53
|
-
helper.
|
|
52
|
+
allow(helper).to receive(:url_for_module).and_return('')
|
|
53
|
+
allow(helper).to receive(:_t).and_return(alchemy_module['name'])
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
context "with permission" do
|
|
57
57
|
before do
|
|
58
|
-
helper.
|
|
58
|
+
expect(helper).to receive(:can?).and_return(true)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "renders the main navigation entry partial" do
|
|
62
|
-
helper.alchemy_main_navigation_entry(alchemy_module).
|
|
62
|
+
expect(helper.alchemy_main_navigation_entry(alchemy_module)).to match /<a.+class="main_navi_entry/
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
context "without permission" do
|
|
67
67
|
before do
|
|
68
|
-
helper.
|
|
68
|
+
allow(helper).to receive(:can?).and_return(false)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "returns empty string" do
|
|
72
|
-
helper.alchemy_main_navigation_entry(alchemy_module).
|
|
72
|
+
expect(helper.alchemy_main_navigation_entry(alchemy_module)).to be_empty
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
describe '#admin_subnavigation' do
|
|
78
78
|
before do
|
|
79
|
-
helper.
|
|
80
|
-
helper.
|
|
81
|
-
helper.
|
|
79
|
+
allow(helper).to receive(:current_alchemy_module).and_return(alchemy_module)
|
|
80
|
+
allow(helper).to receive(:url_for_module_sub_navigation).and_return('')
|
|
81
|
+
allow(helper).to receive(:_t).and_return(alchemy_module['name'])
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
context "with permission" do
|
|
85
85
|
before do
|
|
86
|
-
helper.
|
|
86
|
+
expect(helper).to receive(:can?).and_return(true)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "renders the sub navigation for current module" do
|
|
90
|
-
helper.admin_subnavigation.
|
|
90
|
+
expect(helper.admin_subnavigation).to match /<div.+class="subnavi_tab/
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
context "without permission" do
|
|
95
95
|
before do
|
|
96
|
-
helper.
|
|
96
|
+
expect(helper).to receive(:can?).and_return(false)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "renders the sub navigation for current module" do
|
|
100
|
-
helper.admin_subnavigation.
|
|
100
|
+
expect(helper.admin_subnavigation).to be_empty
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
context "without a module present" do
|
|
105
105
|
before do
|
|
106
|
-
helper.
|
|
106
|
+
expect(helper).to receive(:current_alchemy_module).and_return(nil)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it "returns nil" do
|
|
110
|
-
helper.admin_subnavigation.
|
|
110
|
+
expect(helper.admin_subnavigation).to be_nil
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
describe '#navigate_module' do
|
|
116
116
|
it "returns array with symbolized action and controller name" do
|
|
117
|
-
helper.navigate_module(navigation).
|
|
117
|
+
expect(helper.navigate_module(navigation)).to eq([:index, :alchemy_admin_dashboard])
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
it "stringifies keys" do
|
|
121
|
-
helper.navigate_module({action: 'index', controller: 'alchemy/admin/pictures'}).
|
|
121
|
+
expect(helper.navigate_module({action: 'index', controller: 'alchemy/admin/pictures'})).to eq([:index, :alchemy_admin_pictures])
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
it "removes leading slash" do
|
|
125
|
-
helper.navigate_module({action: 'index', controller: '/admin/pictures'}).
|
|
125
|
+
expect(helper.navigate_module({action: 'index', controller: '/admin/pictures'})).to eq([:index, :admin_pictures])
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
describe '#main_navigation_css_classes' do
|
|
130
130
|
it "returns string with css classes for main navigation entry" do
|
|
131
|
-
helper.main_navigation_css_classes(navigation).
|
|
131
|
+
expect(helper.main_navigation_css_classes(navigation)).to eq("main_navi_entry")
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
context "with active entry" do
|
|
135
135
|
before do
|
|
136
|
-
helper.
|
|
136
|
+
allow(helper).to receive(:params).and_return({
|
|
137
|
+
controller: 'alchemy/admin/dashboard',
|
|
138
|
+
action: 'index'
|
|
139
|
+
})
|
|
137
140
|
end
|
|
138
141
|
|
|
139
142
|
it "includes active class" do
|
|
140
|
-
helper.main_navigation_css_classes(navigation).
|
|
143
|
+
expect(helper.main_navigation_css_classes(navigation)).to eq("main_navi_entry active")
|
|
141
144
|
end
|
|
142
145
|
end
|
|
143
146
|
end
|
|
@@ -149,18 +152,21 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
149
152
|
|
|
150
153
|
context "with active entry" do
|
|
151
154
|
before do
|
|
152
|
-
helper.
|
|
155
|
+
allow(helper).to receive(:params).and_return({
|
|
156
|
+
controller: 'alchemy/admin/dashboard',
|
|
157
|
+
action: 'index'
|
|
158
|
+
})
|
|
153
159
|
end
|
|
154
160
|
|
|
155
161
|
it "returns true" do
|
|
156
|
-
helper.entry_active?(entry).
|
|
162
|
+
expect(helper.entry_active?(entry)).to be_truthy
|
|
157
163
|
end
|
|
158
164
|
|
|
159
165
|
context "and with leading slash in controller name" do
|
|
160
166
|
before { entry['controller'] = '/alchemy/admin/dashboard' }
|
|
161
167
|
|
|
162
168
|
it "returns true" do
|
|
163
|
-
helper.entry_active?(entry).
|
|
169
|
+
expect(helper.entry_active?(entry)).to be_truthy
|
|
164
170
|
end
|
|
165
171
|
end
|
|
166
172
|
|
|
@@ -171,18 +177,21 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
171
177
|
end
|
|
172
178
|
|
|
173
179
|
it "returns true" do
|
|
174
|
-
helper.entry_active?(entry).
|
|
180
|
+
expect(helper.entry_active?(entry)).to be_truthy
|
|
175
181
|
end
|
|
176
182
|
end
|
|
177
183
|
end
|
|
178
184
|
|
|
179
185
|
context "with inactive entry" do
|
|
180
186
|
before do
|
|
181
|
-
helper.
|
|
187
|
+
expect(helper).to receive(:params).and_return({
|
|
188
|
+
controller: 'alchemy/admin/users',
|
|
189
|
+
action: 'index'
|
|
190
|
+
})
|
|
182
191
|
end
|
|
183
192
|
|
|
184
193
|
it "returns false" do
|
|
185
|
-
helper.entry_active?(entry).
|
|
194
|
+
expect(helper.entry_active?(entry)).to be_falsey
|
|
186
195
|
end
|
|
187
196
|
end
|
|
188
197
|
end
|
|
@@ -190,17 +199,17 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
190
199
|
describe '#url_for_module' do
|
|
191
200
|
context "with module within an engine" do
|
|
192
201
|
it "returns correct url string" do
|
|
193
|
-
helper.url_for_module(alchemy_module).
|
|
202
|
+
expect(helper.url_for_module(alchemy_module)).to eq('/admin/dashboard')
|
|
194
203
|
end
|
|
195
204
|
end
|
|
196
205
|
|
|
197
206
|
context "with module within host app" do
|
|
198
207
|
it "returns correct url string" do
|
|
199
|
-
helper.url_for_module(event_module).
|
|
208
|
+
expect(helper.url_for_module(event_module)).to eq('/admin/events')
|
|
200
209
|
end
|
|
201
210
|
|
|
202
211
|
it "returns correct url string with params" do
|
|
203
|
-
helper.url_for_module(event_module_with_params).
|
|
212
|
+
expect(helper.url_for_module(event_module_with_params)).to eq('/admin/events?key=value')
|
|
204
213
|
end
|
|
205
214
|
end
|
|
206
215
|
end
|
|
@@ -211,40 +220,42 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
211
220
|
let(:current_module) { alchemy_module }
|
|
212
221
|
let(:navigation) { current_module['navigation']['sub_navigation'].first }
|
|
213
222
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
context 'with module found' do
|
|
224
|
+
before do
|
|
225
|
+
expect(helper).to receive(:module_definition_for).and_return current_module
|
|
226
|
+
end
|
|
217
227
|
|
|
218
|
-
|
|
219
|
-
|
|
228
|
+
context "with module within an engine" do
|
|
229
|
+
let(:current_module) { alchemy_module }
|
|
220
230
|
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
it "returns correct url string" do
|
|
232
|
+
is_expected.to eq('/admin/layoutpages')
|
|
233
|
+
end
|
|
223
234
|
end
|
|
224
|
-
end
|
|
225
235
|
|
|
226
|
-
|
|
227
|
-
|
|
236
|
+
context "with module within host app" do
|
|
237
|
+
let(:current_module) { event_module }
|
|
228
238
|
|
|
229
|
-
|
|
230
|
-
|
|
239
|
+
it "returns correct url string" do
|
|
240
|
+
is_expected.to eq('/admin/events')
|
|
241
|
+
end
|
|
231
242
|
end
|
|
232
|
-
end
|
|
233
243
|
|
|
234
|
-
|
|
235
|
-
|
|
244
|
+
context "with module within host app with params" do
|
|
245
|
+
let(:current_module) { event_module_with_params }
|
|
236
246
|
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
it "returns correct url string with params" do
|
|
248
|
+
is_expected.to eq('/admin/events?key2=value2&key=value')
|
|
249
|
+
end
|
|
239
250
|
end
|
|
240
251
|
end
|
|
241
252
|
|
|
242
253
|
context 'without module found' do
|
|
243
254
|
before do
|
|
244
|
-
helper.
|
|
255
|
+
expect(helper).to receive(:module_definition_for).and_return nil
|
|
245
256
|
end
|
|
246
257
|
|
|
247
|
-
it {
|
|
258
|
+
it { is_expected.to be_nil }
|
|
248
259
|
end
|
|
249
260
|
end
|
|
250
261
|
|
|
@@ -255,24 +266,23 @@ describe Alchemy::Admin::NavigationHelper do
|
|
|
255
266
|
before do
|
|
256
267
|
alchemy_module['position'] = 1
|
|
257
268
|
event_module['position'] = 2
|
|
258
|
-
helper.
|
|
269
|
+
expect(helper).to receive(:alchemy_modules).and_return [event_module, alchemy_module]
|
|
259
270
|
end
|
|
260
271
|
|
|
261
272
|
it "returns sorted alchemy modules" do
|
|
262
|
-
|
|
273
|
+
is_expected.to eq([alchemy_module, event_module])
|
|
263
274
|
end
|
|
264
275
|
end
|
|
265
276
|
|
|
266
277
|
context 'with no position attribute on one module' do
|
|
267
278
|
before do
|
|
268
279
|
event_module['position'] = 2
|
|
269
|
-
helper.
|
|
280
|
+
expect(helper).to receive(:alchemy_modules).and_return [alchemy_module, event_module]
|
|
270
281
|
end
|
|
271
282
|
|
|
272
283
|
it "appends this module at the end" do
|
|
273
|
-
|
|
284
|
+
is_expected.to eq([event_module, alchemy_module])
|
|
274
285
|
end
|
|
275
286
|
end
|
|
276
287
|
end
|
|
277
|
-
|
|
278
288
|
end
|
|
@@ -5,7 +5,7 @@ describe Alchemy::Admin::PagesHelper do
|
|
|
5
5
|
describe '#sitemap_folder_link' do
|
|
6
6
|
let(:user) { admin_user }
|
|
7
7
|
|
|
8
|
-
before { helper.
|
|
8
|
+
before { allow(helper).to receive(:current_alchemy_user).and_return(user) }
|
|
9
9
|
|
|
10
10
|
subject { helper.sitemap_folder_link(page) }
|
|
11
11
|
|
|
@@ -13,11 +13,11 @@ describe Alchemy::Admin::PagesHelper do
|
|
|
13
13
|
let(:page) { mock_model(Alchemy::Page, folded?: true) }
|
|
14
14
|
|
|
15
15
|
it "renders a link with folded class" do
|
|
16
|
-
|
|
16
|
+
is_expected.to match /class="page_folder folded spinner"/
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "renders a link with hide title" do
|
|
20
|
-
|
|
20
|
+
is_expected.to match /title="Show childpages"/
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -25,18 +25,18 @@ describe Alchemy::Admin::PagesHelper do
|
|
|
25
25
|
let(:page) { mock_model(Alchemy::Page, folded?: false) }
|
|
26
26
|
|
|
27
27
|
it "renders a link with collapsed class" do
|
|
28
|
-
|
|
28
|
+
is_expected.to match /class="page_folder collapsed spinner"/
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "renders a link with hide title" do
|
|
32
|
-
|
|
32
|
+
is_expected.to match /title="Hide childpages"/
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
describe '#preview_sizes_for_select' do
|
|
38
38
|
it "returns a options string of preview screen sizes for select tag" do
|
|
39
|
-
helper.preview_sizes_for_select.
|
|
39
|
+
expect(helper.preview_sizes_for_select).to include('option', 'auto', '240', '320', '480', '768', '1024', '1280')
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -45,19 +45,19 @@ describe Alchemy::Admin::PagesHelper do
|
|
|
45
45
|
subject { helper.combined_page_status(page) }
|
|
46
46
|
|
|
47
47
|
context 'when page is locked' do
|
|
48
|
-
it {
|
|
48
|
+
it { is_expected.not_to match(/locked/) } # We don't want the locked status in the return string
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
context 'when page is restricted' do
|
|
52
|
-
it {
|
|
52
|
+
it { is_expected.to match(/is restricted/) }
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
context 'when page is visible in navigation' do
|
|
56
|
-
it {
|
|
56
|
+
it { is_expected.to match(/is visible/) }
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
context 'when page is published' do
|
|
60
|
-
it {
|
|
60
|
+
it { is_expected.to match(/is published/) }
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -9,40 +9,40 @@ module Alchemy
|
|
|
9
9
|
|
|
10
10
|
describe '#render_tag_list' do
|
|
11
11
|
context "with tagged objects" do
|
|
12
|
-
before { Attachment.
|
|
12
|
+
before { allow(Attachment).to receive(:tag_counts).and_return([tag, tag2]) }
|
|
13
13
|
|
|
14
14
|
it "returns a tag list as <li> tags" do
|
|
15
|
-
helper.render_tag_list('Alchemy::Attachment', params).
|
|
15
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params)).to match(/li/)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "has the tags name in the li's name attribute" do
|
|
19
|
-
helper.render_tag_list('Alchemy::Attachment', params).
|
|
19
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params)).to match(/li.+name="#{tag.name}"/)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "has active class if tag is present in params" do
|
|
23
|
-
helper.render_tag_list('Alchemy::Attachment', params).
|
|
23
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params)).to match(/li.+class="active"/)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "tags are sorted alphabetically" do
|
|
27
|
-
helper.render_tag_list('Alchemy::Attachment', params).
|
|
27
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params)).to match(/li.+name="#{tag2.name}.+li.+name="#{tag.name}/)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
context "with lowercase and uppercase tag names mixed" do
|
|
31
31
|
let(:tag) { mock_model(ActsAsTaggableOn::Tag, name: 'Foo', count: 1) }
|
|
32
32
|
|
|
33
33
|
it "tags are sorted alphabetically correctly" do
|
|
34
|
-
helper.render_tag_list('Alchemy::Attachment', params).
|
|
34
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params)).to match(/li.+name="#{tag2.name}.+li.+name="#{tag.name}/)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "output is html_safe" do
|
|
39
|
-
helper.render_tag_list('Alchemy::Attachment', params).html_safe
|
|
39
|
+
expect(helper.render_tag_list('Alchemy::Attachment', params).html_safe?).to be_truthy
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
context "without any tagged objects" do
|
|
44
44
|
it "returns empty string" do
|
|
45
|
-
render_tag_list('Alchemy::Attachment', params).
|
|
45
|
+
expect(render_tag_list('Alchemy::Attachment', params)).to be_empty
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -56,13 +56,13 @@ module Alchemy
|
|
|
56
56
|
describe '#tag_list_tag_active?' do
|
|
57
57
|
context "the tag is in params" do
|
|
58
58
|
it "returns true" do
|
|
59
|
-
tag_list_tag_active?(tag, params).
|
|
59
|
+
expect(tag_list_tag_active?(tag, params)).to be_truthy
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
context "params[:tagged_with] is not present" do
|
|
64
64
|
it "returns false" do
|
|
65
|
-
tag_list_tag_active?(tag, {}).
|
|
65
|
+
expect(tag_list_tag_active?(tag, {})).to be_falsey
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -70,26 +70,26 @@ module Alchemy
|
|
|
70
70
|
describe "#filtered_by_tag?" do
|
|
71
71
|
it "should return true if the filterlist contains the given tag" do
|
|
72
72
|
controller.params[:tagged_with] = "foo,bar,baz"
|
|
73
|
-
helper.filtered_by_tag?(tag).
|
|
73
|
+
expect(helper.filtered_by_tag?(tag)).to eq(true)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should return false if the filterlist does not contain the given tag" do
|
|
77
77
|
controller.params[:tagged_with] = "bar,baz"
|
|
78
|
-
helper.filtered_by_tag?(tag).
|
|
78
|
+
expect(helper.filtered_by_tag?(tag)).to eq(false)
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
describe "#add_to_tag_filter" do
|
|
83
83
|
context "if params[:tagged_with] is not present" do
|
|
84
84
|
it "should return an Array with the given tag name" do
|
|
85
|
-
helper.add_to_tag_filter(tag).
|
|
85
|
+
expect(helper.add_to_tag_filter(tag)).to eq(["foo"])
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
context "if params[:tagged_with] contains some tag names" do
|
|
90
90
|
it "should return an Array of tag names including the given one" do
|
|
91
91
|
controller.params[:tagged_with] = "bar,baz"
|
|
92
|
-
helper.add_to_tag_filter(tag).
|
|
92
|
+
expect(helper.add_to_tag_filter(tag)).to eq(["bar", "baz", "foo"])
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -97,14 +97,14 @@ module Alchemy
|
|
|
97
97
|
describe "#remove_from_tag_filter" do
|
|
98
98
|
context "if params[:tagged_with] is not present" do
|
|
99
99
|
it "should return an empty Array" do
|
|
100
|
-
helper.remove_from_tag_filter(tag).
|
|
100
|
+
expect(helper.remove_from_tag_filter(tag)).to be_empty
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
context "if params[:tagged_with] contains some tag names" do
|
|
105
105
|
it "should return an Array of tag names without the given one" do
|
|
106
106
|
controller.params[:tagged_with] = "bar,baz,foo"
|
|
107
|
-
helper.remove_from_tag_filter(tag).
|
|
107
|
+
expect(helper.remove_from_tag_filter(tag)).to eq(["bar", "baz"])
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
end
|