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.
- 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
@@ -9,20 +9,20 @@ module Alchemy
|
|
9
9
|
|
10
10
|
describe "#index" do
|
11
11
|
it "should always paginate the records" do
|
12
|
-
Picture.
|
12
|
+
expect(Picture).to receive(:find_paginated)
|
13
13
|
get :index
|
14
14
|
end
|
15
15
|
|
16
16
|
context "when params[:filter] is set" do
|
17
17
|
it "should filter the pictures collection by the given filter string." do
|
18
|
-
Picture.
|
18
|
+
expect(Picture).to receive(:filtered_by).with('recent').and_return(Picture.all)
|
19
19
|
get :index, filter: 'recent'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
context "when params[:tagged_with] is set" do
|
24
24
|
it "should filter the records by tags" do
|
25
|
-
Picture.
|
25
|
+
expect(Picture).to receive(:tagged_with).and_return(Picture.all)
|
26
26
|
get :index, tagged_with: "red"
|
27
27
|
end
|
28
28
|
end
|
@@ -30,7 +30,7 @@ module Alchemy
|
|
30
30
|
context "when params[:content_id]" do
|
31
31
|
context "is set" do
|
32
32
|
before do
|
33
|
-
Element.
|
33
|
+
allow(Element).to receive(:find).with('1', {:select => 'id'}).and_return(mock_model(Element))
|
34
34
|
end
|
35
35
|
|
36
36
|
it "for html requests it renders the archive_overlay partial" do
|
@@ -64,31 +64,31 @@ module Alchemy
|
|
64
64
|
let(:content) { mock_model('Content') }
|
65
65
|
|
66
66
|
before do
|
67
|
-
Content.
|
68
|
-
Element.
|
67
|
+
expect(Content).to receive(:select).and_return(double(find_by: content))
|
68
|
+
expect(Element).to receive(:select).and_return(double(find_by: element))
|
69
69
|
end
|
70
70
|
|
71
71
|
it "assigns lots of instance variables" do
|
72
72
|
subject
|
73
|
-
assigns(:options).
|
74
|
-
assigns(:while_assigning).
|
75
|
-
assigns(:content).
|
76
|
-
assigns(:element).
|
77
|
-
assigns(:page).
|
78
|
-
assigns(:per_page).
|
73
|
+
expect(assigns(:options)).to eq({})
|
74
|
+
expect(assigns(:while_assigning)).to be_truthy
|
75
|
+
expect(assigns(:content)).to eq(content)
|
76
|
+
expect(assigns(:element)).to eq(element)
|
77
|
+
expect(assigns(:page)).to eq(1)
|
78
|
+
expect(assigns(:per_page)).to eq(9)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'with size param given' do
|
83
83
|
let(:params) { {size: '200x200'} }
|
84
84
|
before { subject }
|
85
|
-
it { assigns(:size).
|
85
|
+
it { expect(assigns(:size)).to eq('200x200') }
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'without size param given' do
|
89
89
|
let(:params) { {size: nil} }
|
90
90
|
before { subject }
|
91
|
-
it { assigns(:size).
|
91
|
+
it { expect(assigns(:size)).to eq('medium') }
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -100,10 +100,10 @@ module Alchemy
|
|
100
100
|
|
101
101
|
context 'with passing validations' do
|
102
102
|
before do
|
103
|
-
Picture.
|
104
|
-
picture.
|
105
|
-
picture.
|
106
|
-
picture.
|
103
|
+
expect(Picture).to receive(:new).and_return(picture)
|
104
|
+
expect(picture).to receive(:name=).and_return('Cute kittens')
|
105
|
+
expect(picture).to receive(:name).and_return('Cute kittens')
|
106
|
+
expect(picture).to receive(:save).and_return(true)
|
107
107
|
end
|
108
108
|
|
109
109
|
context 'if inside of archive overlay' do
|
@@ -112,67 +112,67 @@ module Alchemy
|
|
112
112
|
let(:content) { mock_model('Content') }
|
113
113
|
|
114
114
|
before do
|
115
|
-
Content.
|
116
|
-
Element.
|
115
|
+
expect(Content).to receive(:select).and_return(double(find_by: content))
|
116
|
+
expect(Element).to receive(:select).and_return(double(find_by: element))
|
117
117
|
end
|
118
118
|
|
119
119
|
it "assigns lots of instance variables" do
|
120
120
|
subject
|
121
|
-
assigns(:options).
|
122
|
-
assigns(:while_assigning).
|
123
|
-
assigns(:content).
|
124
|
-
assigns(:element).
|
125
|
-
assigns(:page).
|
126
|
-
assigns(:per_page).
|
121
|
+
expect(assigns(:options)).to eq({})
|
122
|
+
expect(assigns(:while_assigning)).to be_truthy
|
123
|
+
expect(assigns(:content)).to eq(content)
|
124
|
+
expect(assigns(:element)).to eq(element)
|
125
|
+
expect(assigns(:page)).to eq(1)
|
126
|
+
expect(assigns(:per_page)).to eq(9)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'with size param given' do
|
131
131
|
let(:params) { {picture: {name: ''}, size: '200x200'} }
|
132
132
|
before { subject }
|
133
|
-
it { assigns(:size).
|
133
|
+
it { expect(assigns(:size)).to eq('200x200') }
|
134
134
|
end
|
135
135
|
|
136
136
|
context 'without size param given' do
|
137
137
|
let(:params) { {picture: {name: ''}, size: nil} }
|
138
138
|
before { subject }
|
139
|
-
it { assigns(:size).
|
139
|
+
it { expect(assigns(:size)).to eq('medium') }
|
140
140
|
end
|
141
141
|
|
142
142
|
it "renders json response with success message" do
|
143
143
|
subject
|
144
|
-
response.content_type.
|
145
|
-
response.status.
|
144
|
+
expect(response.content_type).to eq('application/json')
|
145
|
+
expect(response.status).to eq(201)
|
146
146
|
json = JSON.parse(response.body)
|
147
|
-
json.
|
148
|
-
json.
|
147
|
+
expect(json).to have_key('growl_message')
|
148
|
+
expect(json).to have_key('files')
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
context 'without passing validations' do
|
153
153
|
it "renders json response with error message" do
|
154
154
|
subject
|
155
|
-
response.content_type.
|
156
|
-
response.status.
|
155
|
+
expect(response.content_type).to eq('application/json')
|
156
|
+
expect(response.status).to eq(422)
|
157
157
|
json = JSON.parse(response.body)
|
158
|
-
json.
|
159
|
-
json.
|
158
|
+
expect(json).to have_key('growl_message')
|
159
|
+
expect(json).to have_key('files')
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
164
|
describe '#edit_multiple' do
|
165
165
|
let(:pictures) { [mock_model('Picture', tag_list: 'kitten')] }
|
166
|
-
before { Picture.
|
166
|
+
before { expect(Picture).to receive(:where).and_return(pictures) }
|
167
167
|
|
168
168
|
it 'assigns pictures instance variable' do
|
169
169
|
get :edit_multiple
|
170
|
-
assigns(:pictures).
|
170
|
+
expect(assigns(:pictures)).to eq(pictures)
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'assigns tags instance variable' do
|
174
174
|
get :edit_multiple
|
175
|
-
assigns(:tags).
|
175
|
+
expect(assigns(:tags)).to include('kitten')
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -182,36 +182,36 @@ module Alchemy
|
|
182
182
|
let(:picture) { mock_model('Picture', name: 'Cute kitten') }
|
183
183
|
|
184
184
|
before do
|
185
|
-
Picture.
|
185
|
+
expect(Picture).to receive(:find).and_return(picture)
|
186
186
|
end
|
187
187
|
|
188
188
|
context 'with passing validations' do
|
189
189
|
before do
|
190
|
-
picture.
|
190
|
+
expect(picture).to receive(:update_attributes).and_return(true)
|
191
191
|
end
|
192
192
|
|
193
193
|
it "sets success notice" do
|
194
194
|
subject
|
195
|
-
flash[:notice].
|
195
|
+
expect(flash[:notice]).not_to be_blank
|
196
196
|
end
|
197
197
|
|
198
198
|
it "redirects to index path" do
|
199
|
-
|
199
|
+
is_expected.to redirect_to admin_pictures_path
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
203
|
context 'with failing validations' do
|
204
204
|
before do
|
205
|
-
picture.
|
205
|
+
expect(picture).to receive(:update_attributes).and_return(false)
|
206
206
|
end
|
207
207
|
|
208
208
|
it "sets error notice and redirects to index path" do
|
209
209
|
subject
|
210
|
-
flash[:error].
|
210
|
+
expect(flash[:error]).not_to be_blank
|
211
211
|
end
|
212
212
|
|
213
213
|
it "redirects to index path" do
|
214
|
-
|
214
|
+
is_expected.to redirect_to admin_pictures_path
|
215
215
|
end
|
216
216
|
end
|
217
217
|
end
|
@@ -221,18 +221,13 @@ module Alchemy
|
|
221
221
|
let(:pictures) { [picture] }
|
222
222
|
|
223
223
|
before do
|
224
|
-
Picture.
|
225
|
-
picture.
|
224
|
+
expect(Picture).to receive(:find).and_return(pictures)
|
225
|
+
expect(picture).to receive(:save!).and_return(true)
|
226
226
|
end
|
227
227
|
|
228
228
|
it "loads and assigns pictures" do
|
229
229
|
post :update_multiple
|
230
|
-
assigns(:pictures).
|
231
|
-
end
|
232
|
-
|
233
|
-
it "updates each picture" do
|
234
|
-
picture.should_receive(:update_name_and_tag_list!)
|
235
|
-
post :update_multiple
|
230
|
+
expect(assigns(:pictures)).to eq(pictures)
|
236
231
|
end
|
237
232
|
end
|
238
233
|
|
@@ -256,7 +251,7 @@ module Alchemy
|
|
256
251
|
let(:picture_ids) { "#{deletable_picture.id}" }
|
257
252
|
|
258
253
|
before do
|
259
|
-
Picture.
|
254
|
+
allow(Picture).to receive(:find).and_return([deletable_picture])
|
260
255
|
end
|
261
256
|
|
262
257
|
it "should delete the pictures give a notice about deleting them" do
|
@@ -269,11 +264,11 @@ module Alchemy
|
|
269
264
|
let(:picture_ids) { "#{deletable_picture.id},#{not_deletable_picture.id}" }
|
270
265
|
|
271
266
|
before do
|
272
|
-
Picture.
|
267
|
+
allow(Picture).to receive(:find).and_return([deletable_picture, not_deletable_picture])
|
273
268
|
end
|
274
269
|
|
275
270
|
it "should give a warning for the non deletable pictures and delete the others" do
|
276
|
-
deletable_picture.
|
271
|
+
expect(deletable_picture).to receive(:destroy)
|
277
272
|
subject
|
278
273
|
expect(flash[:warn]).to match('could not be deleted')
|
279
274
|
end
|
@@ -283,17 +278,17 @@ module Alchemy
|
|
283
278
|
let(:picture_ids) { "#{deletable_picture.id}" }
|
284
279
|
|
285
280
|
before do
|
286
|
-
Picture.
|
281
|
+
expect(Picture).to receive(:find).and_raise('yada')
|
287
282
|
end
|
288
283
|
|
289
284
|
it "sets error message" do
|
290
285
|
subject
|
291
|
-
flash[:error].
|
286
|
+
expect(flash[:error]).not_to be_blank
|
292
287
|
end
|
293
288
|
|
294
289
|
it "redirects to index" do
|
295
290
|
subject
|
296
|
-
response.
|
291
|
+
expect(response).to redirect_to admin_pictures_path
|
297
292
|
end
|
298
293
|
end
|
299
294
|
end
|
@@ -303,36 +298,36 @@ module Alchemy
|
|
303
298
|
let(:picture) { mock_model('Picture', name: 'Cute kitten') }
|
304
299
|
|
305
300
|
before do
|
306
|
-
Picture.
|
301
|
+
expect(Picture).to receive(:find).and_return(picture)
|
307
302
|
end
|
308
303
|
|
309
304
|
it "destroys the picture and sets and success message" do
|
310
|
-
picture.
|
305
|
+
expect(picture).to receive(:destroy)
|
311
306
|
delete :destroy
|
312
|
-
assigns(:picture).
|
313
|
-
flash[:notice].
|
307
|
+
expect(assigns(:picture)).to eq(picture)
|
308
|
+
expect(flash[:notice]).not_to be_blank
|
314
309
|
end
|
315
310
|
|
316
311
|
context 'if an error happens' do
|
317
312
|
before do
|
318
|
-
picture.
|
313
|
+
expect(picture).to receive(:destroy).and_raise('yada')
|
319
314
|
end
|
320
315
|
|
321
316
|
it "shows error notice" do
|
322
317
|
delete :destroy
|
323
|
-
flash[:error].
|
318
|
+
expect(flash[:error]).not_to be_blank
|
324
319
|
end
|
325
320
|
|
326
321
|
it "redirects to index" do
|
327
322
|
delete :destroy
|
328
|
-
response.
|
323
|
+
expect(response).to redirect_to admin_pictures_path
|
329
324
|
end
|
330
325
|
end
|
331
326
|
end
|
332
327
|
|
333
328
|
describe '#flush' do
|
334
329
|
it "removes the complete pictures cache" do
|
335
|
-
FileUtils.
|
330
|
+
expect(FileUtils).to receive(:rm_rf).with(Rails.root.join('public', '', 'pictures'))
|
336
331
|
xhr :post, :flush
|
337
332
|
end
|
338
333
|
end
|
@@ -340,21 +335,23 @@ module Alchemy
|
|
340
335
|
describe '#pictures_per_page_for_size' do
|
341
336
|
subject { controller.send(:pictures_per_page_for_size, size) }
|
342
337
|
|
343
|
-
before
|
338
|
+
before do
|
339
|
+
expect(controller).to receive(:in_overlay?).and_return(true)
|
340
|
+
end
|
344
341
|
|
345
342
|
context 'with params[:size] set to medium' do
|
346
343
|
let(:size) { 'medium' }
|
347
|
-
it {
|
344
|
+
it { is_expected.to eq(9) }
|
348
345
|
end
|
349
346
|
|
350
347
|
context 'with params[:size] set to small' do
|
351
348
|
let(:size) { 'small' }
|
352
|
-
it {
|
349
|
+
it { is_expected.to eq(25) }
|
353
350
|
end
|
354
351
|
|
355
352
|
context 'with params[:size] set to large' do
|
356
353
|
let(:size) { 'large' }
|
357
|
-
it {
|
354
|
+
it { is_expected.to eq(4) }
|
358
355
|
end
|
359
356
|
end
|
360
357
|
end
|
@@ -5,7 +5,7 @@ end
|
|
5
5
|
|
6
6
|
describe EventsController do
|
7
7
|
it "should include ResourcesHelper" do
|
8
|
-
controller.respond_to?(:resource_window_size).
|
8
|
+
expect(controller.respond_to?(:resource_window_size)).to be_truthy
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#index' do
|
@@ -20,8 +20,8 @@ describe EventsController do
|
|
20
20
|
|
21
21
|
it "returns all records" do
|
22
22
|
get :index, params
|
23
|
-
assigns(:events).
|
24
|
-
assigns(:events).
|
23
|
+
expect(assigns(:events)).to include(peter)
|
24
|
+
expect(assigns(:events)).to include(lustig)
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'with search query given' do
|
@@ -29,8 +29,8 @@ describe EventsController do
|
|
29
29
|
|
30
30
|
it "returns only matching records" do
|
31
31
|
get :index, params
|
32
|
-
assigns(:events).
|
33
|
-
assigns(:events).
|
32
|
+
expect(assigns(:events)).to include(peter)
|
33
|
+
expect(assigns(:events)).not_to include(lustig)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -15,48 +15,51 @@ module Alchemy
|
|
15
15
|
|
16
16
|
it "should hold trashed elements" do
|
17
17
|
get :index, :page_id => alchemy_page.id
|
18
|
-
response.body.
|
18
|
+
expect(response.body).to have_selector("#element_#{element.id}.element_editor")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should not hold elements that are not trashed" do
|
22
22
|
element = FactoryGirl.create(:element, :page => alchemy_page, :public => false)
|
23
23
|
get :index, :page_id => alchemy_page.id
|
24
|
-
response.body.
|
24
|
+
expect(response.body).not_to have_selector("#element_#{element.id}.element_editor")
|
25
25
|
end
|
26
26
|
|
27
27
|
context "with unique elements inside the trash" do
|
28
28
|
let(:trashed) { FactoryGirl.build_stubbed(:unique_element, position: nil, public: false, folded: true, page: alchemy_page) }
|
29
|
-
before { Element.
|
29
|
+
before { allow(Element).to receive(:trashed).and_return([trashed]) }
|
30
30
|
|
31
31
|
context "and no unique elements on the page" do
|
32
|
-
before
|
32
|
+
before do
|
33
|
+
allow(alchemy_page).to receive(:elements).and_return double(not_trashed: double(pluck: []))
|
34
|
+
end
|
33
35
|
|
34
36
|
it "unique elements should be draggable" do
|
35
37
|
get :index, page_id: alchemy_page.id
|
36
|
-
response.body.
|
38
|
+
expect(response.body).to have_selector("#element_#{trashed.id}.element_editor.draggable")
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
context "and with an unique element on the page" do
|
41
43
|
let(:unique) { FactoryGirl.build_stubbed(:unique_element) }
|
42
44
|
let(:page) { FactoryGirl.build_stubbed(:public_page) }
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
before do
|
47
|
+
allow(Page).to receive(:find).and_return(page)
|
48
|
+
allow(page).to receive(:elements).and_return double(not_trashed: double(pluck: [unique.name]))
|
49
|
+
end
|
47
50
|
|
48
51
|
it "unique elements should not be draggable" do
|
49
52
|
get :index, page_id: page.id
|
50
|
-
response.body.
|
53
|
+
expect(response.body).to have_selector("#element_#{trashed.id}.element_editor.not-draggable")
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
58
|
describe "#clear" do
|
56
59
|
it "should destroy all containing elements" do
|
57
|
-
Element.trashed.
|
60
|
+
expect(Element.trashed).not_to be_empty
|
58
61
|
xhr :post, :clear, page_id: alchemy_page.id
|
59
|
-
Element.trashed.
|
62
|
+
expect(Element.trashed).to be_empty
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
@@ -11,7 +11,7 @@ module Alchemy
|
|
11
11
|
|
12
12
|
it "does not create tag" do
|
13
13
|
post :create, tag: {name: ''}
|
14
|
-
response.body.
|
14
|
+
expect(response.body).to have_content("can't be blank")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ module Alchemy
|
|
20
20
|
expect {
|
21
21
|
post :create, tag: {name: 'Foo'}
|
22
22
|
}.to change { ActsAsTaggableOn::Tag.count }.by(1)
|
23
|
-
response.
|
23
|
+
expect(response).to redirect_to admin_tags_path
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -33,8 +33,8 @@ module Alchemy
|
|
33
33
|
|
34
34
|
it "loads alls tags but not the one editing" do
|
35
35
|
get :edit, id: tag.id
|
36
|
-
assigns(:tags).
|
37
|
-
assigns(:tags).
|
36
|
+
expect(assigns(:tags)).to include(another_tag)
|
37
|
+
expect(assigns(:tags)).not_to include(tag)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ module Alchemy
|
|
43
43
|
|
44
44
|
it "changes tags name" do
|
45
45
|
put :update, id: tag.id, tag: {name: 'Foo'}
|
46
|
-
response.
|
46
|
+
expect(response).to redirect_to(admin_tags_path)
|
47
47
|
expect(tag.reload.name).to eq('Foo')
|
48
48
|
end
|
49
49
|
|
@@ -51,10 +51,10 @@ module Alchemy
|
|
51
51
|
let(:another_tag) { ActsAsTaggableOn::Tag.create(name: 'Hutzl') }
|
52
52
|
|
53
53
|
it "replaces tag with other tag" do
|
54
|
-
Alchemy::Tag.
|
55
|
-
ActsAsTaggableOn::Tag.
|
54
|
+
expect(Alchemy::Tag).to receive(:replace)
|
55
|
+
expect_any_instance_of(ActsAsTaggableOn::Tag).to receive(:destroy)
|
56
56
|
put :update, id: tag.id, tag: {merge_to: another_tag.id}
|
57
|
-
response.
|
57
|
+
expect(response).to redirect_to(admin_tags_path)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|