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
@@ -9,20 +9,20 @@ module Alchemy
9
9
 
10
10
  describe "#index" do
11
11
  it "should always paginate the records" do
12
- Picture.should_receive(:find_paginated)
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.should_receive(:filtered_by).with('recent').and_return(Picture.all)
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.should_receive(:tagged_with).and_return(Picture.all)
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.stub(:find).with('1', {:select => 'id'}).and_return(mock_model(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.stub_chain(:select, :find_by).and_return(content)
68
- Element.stub_chain(:select, :find_by).and_return(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).should eq({})
74
- assigns(:while_assigning).should be_true
75
- assigns(:content).should eq(content)
76
- assigns(:element).should eq(element)
77
- assigns(:page).should eq(1)
78
- assigns(:per_page).should eq(9)
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).should eq('200x200') }
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).should eq('medium') }
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.should_receive(:new).and_return(picture)
104
- picture.should_receive(:name=).and_return('Cute kittens')
105
- picture.should_receive(:name).and_return('Cute kittens')
106
- picture.should_receive(:save).and_return(true)
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.stub_chain(:select, :find_by).and_return(content)
116
- Element.stub_chain(:select, :find_by).and_return(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).should eq({})
122
- assigns(:while_assigning).should be_true
123
- assigns(:content).should eq(content)
124
- assigns(:element).should eq(element)
125
- assigns(:page).should eq(1)
126
- assigns(:per_page).should eq(9)
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).should eq('200x200') }
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).should eq('medium') }
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.should eq('application/json')
145
- response.status.should eq(201)
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.should have_key('growl_message')
148
- json.should have_key('files')
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.should eq('application/json')
156
- response.status.should eq(422)
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.should have_key('growl_message')
159
- json.should have_key('files')
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.should_receive(:where).and_return(pictures) }
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).should eq(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).should include('kitten')
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.should_receive(:find).and_return(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.should_receive(:update_attributes).and_return(true)
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].should_not be_blank
195
+ expect(flash[:notice]).not_to be_blank
196
196
  end
197
197
 
198
198
  it "redirects to index path" do
199
- should redirect_to admin_pictures_path
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.should_receive(:update_attributes).and_return(false)
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].should_not be_blank
210
+ expect(flash[:error]).not_to be_blank
211
211
  end
212
212
 
213
213
  it "redirects to index path" do
214
- should redirect_to admin_pictures_path
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.should_receive(:find).and_return(pictures)
225
- picture.stub(save: true)
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).should eq(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.stub(:find).and_return([deletable_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.stub(:find).and_return([deletable_picture, not_deletable_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.should_receive(:destroy)
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.should_receive(:find).and_raise('yada')
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].should_not be_blank
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.should redirect_to admin_pictures_path
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.should_receive(:find).and_return(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.should_receive(:destroy)
305
+ expect(picture).to receive(:destroy)
311
306
  delete :destroy
312
- assigns(:picture).should eq(picture)
313
- flash[:notice].should_not be_blank
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.should_receive(:destroy).and_raise('yada')
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].should_not be_blank
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.should redirect_to admin_pictures_path
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.should_receive(:rm_rf).with(Rails.root.join('public', '', 'pictures'))
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 { controller.stub(in_overlay?: true) }
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 { should eq(9) }
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 { should eq(25) }
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 { should eq(4) }
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).should be_true
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).should include(peter)
24
- assigns(:events).should include(lustig)
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).should include(peter)
33
- assigns(:events).should_not include(lustig)
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.should have_selector("#element_#{element.id}.element_editor")
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.should_not have_selector("#element_#{element.id}.element_editor")
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.stub(:trashed).and_return([trashed]) }
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 { alchemy_page.stub_chain(:elements, :not_trashed, :pluck).and_return([]) }
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.should have_selector("#element_#{trashed.id}.element_editor.draggable")
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
- before {
44
- Page.stub(:find).and_return(page)
45
- page.stub_chain(:elements, :not_trashed, :pluck).and_return([unique.name])
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.should have_selector("#element_#{trashed.id}.element_editor.not-draggable")
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.should_not be_empty
60
+ expect(Element.trashed).not_to be_empty
58
61
  xhr :post, :clear, page_id: alchemy_page.id
59
- Element.trashed.should be_empty
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.should have_content("can't be blank")
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.should redirect_to admin_tags_path
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).should include(another_tag)
37
- assigns(:tags).should_not include(tag)
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.should redirect_to(admin_tags_path)
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.should_receive(:replace)
55
- ActsAsTaggableOn::Tag.any_instance.should_receive(:destroy)
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.should redirect_to(admin_tags_path)
57
+ expect(response).to redirect_to(admin_tags_path)
58
58
  end
59
59
  end
60
60
  end