mokio 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/app/assets/stylesheets/backend/custom.css.scss +1 -1
- data/app/views/mokio/common/_meta.html.slim +20 -20
- data/app/views/mokio/menus/_form.html.haml +1 -1
- data/app/views/mokio/menus/_menu.html.slim +7 -1
- data/app/views/mokio/menus/index.html.slim +1 -0
- data/app/views/mokio/menus/new_menu_position.slim +21 -0
- data/config/locales/en.yml +4 -1
- data/config/locales/pl.yml +4 -1
- data/config/routes.rb +6 -3
- data/db/migrate/20140422135850_add_mokio_to_application.rb +15 -15
- data/lib/mokio/concerns/controllers/menus.rb +25 -2
- data/lib/mokio/concerns/models/contact.rb +1 -1
- data/lib/mokio/concerns/models/menu.rb +2 -1
- data/lib/mokio/concerns/models/recipient.rb +0 -9
- data/lib/mokio/engine.rb +8 -0
- data/lib/mokio/frontend_helpers/langs_helper.rb +16 -9
- data/lib/mokio/frontend_helpers/menu_helper.rb +21 -16
- data/lib/mokio/slugged.rb +5 -0
- data/lib/mokio/version.rb +1 -1
- data/spec/controllers/{backend → mokio}/contents_controller_spec.rb +34 -25
- data/spec/controllers/mokio/dashboard_controller_spec.rb +76 -0
- data/spec/controllers/{backend → mokio}/menus_controller_spec.rb +104 -99
- data/spec/controllers/mokio/mov_galleries_controller_spec.rb +125 -0
- data/spec/controllers/mokio/photos_controller_spec.rb +350 -0
- data/spec/controllers/mokio/pic_galleries_controller_spec.rb +125 -0
- data/spec/controllers/mokio/static_modules_controller_spec.rb +166 -0
- data/spec/factories/contact_templates.rb +1 -1
- data/spec/factories/content_links_factory.rb +1 -1
- data/spec/factories/contents_factory.rb +8 -8
- data/spec/factories/gmaps.rb +1 -1
- data/spec/factories/langs.rb +1 -1
- data/spec/factories/menus_factory.rb +1 -1
- data/spec/factories/meta.rb +1 -1
- data/spec/factories/recipients.rb +1 -1
- data/spec/factories/selected_modules.rb +1 -1
- data/spec/factories/static_modules_factory.rb +2 -2
- data/spec/factories/users.rb +1 -1
- data/spec/helpers/mokio/common_helper_spec.rb +141 -0
- data/spec/helpers/mokio/menus_helper_spec.rb +70 -0
- data/spec/models/available_module_spec.rb +13 -10
- data/spec/models/contact_template_spec.rb +5 -3
- data/spec/models/content_link_spec.rb +5 -4
- data/spec/models/content_spec.rb +71 -70
- data/spec/models/data_file_spec.rb +5 -4
- data/spec/models/gmap_spec.rb +5 -4
- data/spec/models/lang_spec.rb +5 -4
- data/spec/models/menu_spec.rb +10 -2
- data/spec/models/meta_spec.rb +5 -4
- data/spec/models/module_position_spec.rb +11 -10
- data/spec/models/mov_gallery_spec.rb +62 -59
- data/spec/models/pic_gallery_spec.rb +62 -59
- data/spec/models/recipient_spec.rb +5 -4
- data/spec/models/selected_module_spec.rb +72 -88
- data/spec/models/static_module_spec.rb +56 -55
- data/spec/models/user_spec.rb +7 -3
- data/spec/spec_helper.rb +4 -1
- metadata +21 -22
- data/spec/controllers/backend/dashboard_controller_spec.rb +0 -69
- data/spec/controllers/backend/mov_galleries_controller_spec.rb +0 -118
- data/spec/controllers/backend/photos_controller_spec.rb +0 -342
- data/spec/controllers/backend/pic_galleries_controller_spec.rb +0 -118
- data/spec/controllers/backend/static_modules_controller_spec.rb +0 -159
- data/spec/factories/tags.rb +0 -17
- data/spec/helpers/backend/common_helper_spec.rb +0 -137
- data/spec/helpers/backend/menus_helper_spec.rb +0 -64
@@ -1,342 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mokio::Backend::PhotosController do
|
4
|
-
# let(:valid_attributes) { { :data_file => fixture_file_upload('/files/sample_image.jpg', "image/jpg"), :active => true, :content_id => 1 } }
|
5
|
-
let(:valid_attributes) { { :data_file => Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, '/files/sample_image.jpg'), "image/jpg"), :active => true, :content_id => 1 } }
|
6
|
-
|
7
|
-
let(:with_seq) { { :data_file => Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path,'/files/sample_image.jpg'), "image/jpg"), :active => true, :seq => 1, :content_id => 1} }
|
8
|
-
let(:with_content_id2) { { :data_file => Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path,'/files/sample_image.jpg'), "image/jpg"), :active => true, :seq => 1, :content_id => 2} }
|
9
|
-
let(:with_thumb) { { :data_file => Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path,'/files/sample_image.jpg'), "image/jpg"), :active => true, :seq => 1, :content_id => 1,
|
10
|
-
:thumb => Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path,'/files/sample_image.jpg'), "image/jpg")} }
|
11
|
-
|
12
|
-
let(:valid_session) { {} }
|
13
|
-
|
14
|
-
before :all do
|
15
|
-
Content.delete_all
|
16
|
-
FactoryGirl.create(:content_id1)
|
17
|
-
FactoryGirl.create(:content_id2)
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# create
|
22
|
-
#
|
23
|
-
describe "POST create" do
|
24
|
-
after(:each) do
|
25
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
26
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
27
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "flash notices" do
|
31
|
-
before(:each) do
|
32
|
-
xhr :post, :create, {:photo => valid_attributes}
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'has flash notice' do
|
36
|
-
flash[:notice].should_not be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'has flash notice from i18n' do
|
40
|
-
flash[:notice].should eq(I18n.t("photos.created", title: assigns(:photo).name))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "creates a new Photo" do
|
45
|
-
expect {
|
46
|
-
xhr :post, :create, {:photo => valid_attributes}
|
47
|
-
}.to change(Photo, :count).by(1)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "assigns photo to @photo" do
|
51
|
-
xhr :post, :create, {:photo => valid_attributes}
|
52
|
-
assigns(:photo).should be_a(Photo)
|
53
|
-
assigns(:photo).should be_persisted
|
54
|
-
end
|
55
|
-
|
56
|
-
it "has name = filename" do
|
57
|
-
xhr :post, :create, {:photo => valid_attributes}
|
58
|
-
|
59
|
-
name_from_model_method = File.basename(assigns(:photo).data_file.filename, '.*').titleize
|
60
|
-
name_from_fixture_file = File.basename(Rails.root + '/files/sample_image.jpg', '.*').titleize
|
61
|
-
|
62
|
-
assigns(:photo).name.should eq(name_from_model_method)
|
63
|
-
assigns(:photo).name.should eq(name_from_fixture_file)
|
64
|
-
end
|
65
|
-
|
66
|
-
context "sequence" do
|
67
|
-
it "has seq 1" do
|
68
|
-
xhr :post, :create, {:photo => valid_attributes}
|
69
|
-
assigns(:photo).seq.should be(1)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "has seq 2" do
|
73
|
-
Photo.create(with_seq)
|
74
|
-
|
75
|
-
xhr :post, :create, {:photo => valid_attributes}
|
76
|
-
assigns(:photo).seq.should be(2)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should change seq to specific content id" do
|
80
|
-
Photo.create(with_content_id2)
|
81
|
-
|
82
|
-
xhr :post, :create, {:photo => valid_attributes}
|
83
|
-
assigns(:photo).seq.should be(1)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# update
|
90
|
-
#
|
91
|
-
describe "PUT update" do
|
92
|
-
after(:each) do
|
93
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
94
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
95
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
96
|
-
end
|
97
|
-
|
98
|
-
context "flash notices" do
|
99
|
-
before(:each) do
|
100
|
-
photo = Photo.create! valid_attributes
|
101
|
-
xhr :put, :update, {:id => photo.to_param, :photo => valid_attributes}
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'has flash notice' do
|
105
|
-
flash[:notice].should_not be_nil
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'has flash notice from i18n' do
|
109
|
-
flash[:notice].should eq(I18n.t("photos.updated", title: assigns(:photo).name))
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "update method" do
|
114
|
-
before(:each) do
|
115
|
-
photo = Photo.create! valid_attributes
|
116
|
-
xhr :put, :update, {:id => photo.to_param, :photo => valid_attributes}
|
117
|
-
end
|
118
|
-
|
119
|
-
it "assigns photo to @photo" do
|
120
|
-
assigns(:photo).should be_a(Photo)
|
121
|
-
assigns(:photo).should be_persisted
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should render nothing" do
|
125
|
-
response.body.should be_blank
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# destroy
|
132
|
-
#
|
133
|
-
describe "DELETE destroy" do
|
134
|
-
it "destroys the requested photo" do
|
135
|
-
photo = Photo.create! valid_attributes
|
136
|
-
expect {
|
137
|
-
xhr :delete, :destroy, {:id => photo.to_param}, valid_session
|
138
|
-
}.to change(Photo, :count).by(-1)
|
139
|
-
end
|
140
|
-
|
141
|
-
context "assigns" do
|
142
|
-
before(:each) do
|
143
|
-
@photo = Photo.create! valid_attributes
|
144
|
-
xhr :delete, :destroy, {:id => @photo.to_param}, valid_session
|
145
|
-
end
|
146
|
-
|
147
|
-
it "assigns photo to @photo" do
|
148
|
-
assigns(:photo).should be_a(Photo)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "assigns photo id to @id" do
|
152
|
-
assigns(:id).should eq(@photo.id.to_s)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context "flash notices" do
|
157
|
-
before(:each) do
|
158
|
-
photo = Photo.create! valid_attributes
|
159
|
-
xhr :delete, :destroy, {:id => photo.to_param}, valid_session
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'has flash notice' do
|
163
|
-
flash[:notice].should_not be_nil
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'has flash notice from i18n' do
|
167
|
-
flash[:notice].should eq(I18n.t("photos.deleted", title: assigns(:photo).name))
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
#
|
173
|
-
# get_thumb
|
174
|
-
#
|
175
|
-
describe "GET get_thumb" do
|
176
|
-
it "assigns photo to @edited_photo" do
|
177
|
-
photo = Photo.create! valid_attributes
|
178
|
-
xhr :get, :get_thumb, {:id => photo.to_param}
|
179
|
-
assigns(:edited_photo).should be_a(Photo)
|
180
|
-
assigns(:edited_photo).should be_persisted
|
181
|
-
end
|
182
|
-
|
183
|
-
it "has no flash notice" do
|
184
|
-
photo = Photo.create! valid_attributes
|
185
|
-
xhr :get, :get_thumb, {:id => photo.to_param}
|
186
|
-
flash[:notice].should be_nil
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
#
|
191
|
-
# get_photo
|
192
|
-
#
|
193
|
-
describe "GET get_photo" do
|
194
|
-
it "assigns photo to @edited_photo" do
|
195
|
-
photo = Photo.create! valid_attributes
|
196
|
-
xhr :get, :get_photo, {:id => photo.to_param}
|
197
|
-
assigns(:edited_photo).should be_a(Photo)
|
198
|
-
assigns(:edited_photo).should be_persisted
|
199
|
-
end
|
200
|
-
|
201
|
-
it "has no flash notice" do
|
202
|
-
photo = Photo.create! valid_attributes
|
203
|
-
xhr :get, :get_photo, {:id => photo.to_param}
|
204
|
-
flash[:notice].should be_nil
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
#
|
209
|
-
# update_thumb
|
210
|
-
#
|
211
|
-
describe "PATCH update_thumb" do
|
212
|
-
after(:each) do
|
213
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
214
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
215
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
216
|
-
end
|
217
|
-
|
218
|
-
it "assigns photo to @edited_photo" do
|
219
|
-
photo = Photo.create! with_thumb
|
220
|
-
xhr :patch, :update_thumb, {:id => photo.to_param, :photo => with_thumb}
|
221
|
-
assigns(:edited_photo).should be_a(Photo)
|
222
|
-
assigns(:edited_photo).should be_persisted
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'has thumb' do
|
226
|
-
photo = Photo.create! with_thumb
|
227
|
-
xhr :patch, :update_thumb, {:id => photo.to_param, :photo => with_thumb}
|
228
|
-
assigns(:edited_photo).thumb.blank?.should eq(false)
|
229
|
-
end
|
230
|
-
|
231
|
-
context "flash notices" do
|
232
|
-
before(:each) do
|
233
|
-
photo = Photo.create! with_thumb
|
234
|
-
xhr :patch, :update_thumb, {:id => photo.to_param, :photo => with_thumb}
|
235
|
-
end
|
236
|
-
|
237
|
-
it 'has flash notice' do
|
238
|
-
flash[:notice].should_not be_nil
|
239
|
-
end
|
240
|
-
|
241
|
-
it 'has flash notice from i18n' do
|
242
|
-
flash[:notice].should eq(I18n.t("photos.thumb_updated"))
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
#
|
248
|
-
# remove_thumb
|
249
|
-
#
|
250
|
-
describe "DELETE remove_thumb" do
|
251
|
-
after(:each) do
|
252
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
253
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
254
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
255
|
-
end
|
256
|
-
|
257
|
-
context "flash notices" do
|
258
|
-
before(:each) do
|
259
|
-
photo = Photo.create! valid_attributes
|
260
|
-
xhr :delete, :remove_thumb, {:id => photo.to_param, :photo => valid_attributes}
|
261
|
-
end
|
262
|
-
|
263
|
-
it 'has flash notice' do
|
264
|
-
flash[:notice].should_not be_nil
|
265
|
-
end
|
266
|
-
|
267
|
-
it 'has flash notice from i18n' do
|
268
|
-
flash[:notice].should eq(I18n.t("photos.thumb_deleted", name: assigns[:edited_photo].name))
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
it "assigns photo to @edited_photo" do
|
273
|
-
photo = Photo.create! valid_attributes
|
274
|
-
xhr :delete, :remove_thumb, {:id => photo.to_param, :photo => valid_attributes}
|
275
|
-
assigns(:edited_photo).should be_a(Photo)
|
276
|
-
assigns(:edited_photo).should be_persisted
|
277
|
-
end
|
278
|
-
|
279
|
-
it "removes thumb" do
|
280
|
-
photo = Photo.create! valid_attributes
|
281
|
-
xhr :delete, :remove_thumb, {:id => photo.to_param, :photo => valid_attributes}
|
282
|
-
assigns(:edited_photo).thumb.should be_blank
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
#
|
287
|
-
# crop_thumb
|
288
|
-
#
|
289
|
-
describe "POST crop_thumb" do
|
290
|
-
after(:each) do
|
291
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
292
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
293
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
294
|
-
end
|
295
|
-
|
296
|
-
it "assigns photo to @edited_photo" do
|
297
|
-
photo = Photo.create! with_thumb
|
298
|
-
controller.stub(:thumb_path).and_return( photo.thumb.url )
|
299
|
-
xhr :post, :crop_thumb, {:id => photo.to_param, :w => 100, :h => 100, :x => 100, :y => 100}
|
300
|
-
assigns(:edited_photo).should be_a(Photo)
|
301
|
-
assigns(:edited_photo).should be_persisted
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
#
|
306
|
-
# rotate_thumb
|
307
|
-
#
|
308
|
-
describe "GET rotate_thumb" do
|
309
|
-
after(:each) do
|
310
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
311
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
312
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
313
|
-
end
|
314
|
-
|
315
|
-
it "assigns photo to @edited_photo" do
|
316
|
-
photo = Photo.create! with_thumb
|
317
|
-
controller.stub(:thumb_path).and_return( photo.thumb.url )
|
318
|
-
xhr :get, :rotate_thumb, {:id => photo.to_param}
|
319
|
-
assigns(:edited_photo).should be_a(Photo)
|
320
|
-
assigns(:edited_photo).should be_persisted
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
# #
|
325
|
-
# # crop_photo
|
326
|
-
# #
|
327
|
-
describe "POST crop_photo" do
|
328
|
-
after(:each) do
|
329
|
-
msg = { notice: CGI::escape(flash[:notice].to_str) } if flash[:notice]
|
330
|
-
msg = { error: CGI::escape(flash[:error].to_str) } if flash[:error]
|
331
|
-
response.headers['X-Flash-Messages'].should eq(msg.to_json)
|
332
|
-
end
|
333
|
-
|
334
|
-
it "assigns photo to @edited_photo" do
|
335
|
-
photo = Photo.create! valid_attributes
|
336
|
-
controller.stub(:edited_photo_path).and_return( photo.data_file.url(:normal) )
|
337
|
-
xhr :post, :crop_photo, {:id => photo.to_param, :w => 100, :h => 100, :x => 100, :y => 100}
|
338
|
-
assigns(:edited_photo).should be_a(Photo)
|
339
|
-
assigns(:edited_photo).should be_persisted
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mokio::Backend::PicGalleriesController do
|
4
|
-
|
5
|
-
# This should return the minimal set of attributes required to create a valid
|
6
|
-
# Article. As you add validations to Article, be sure to
|
7
|
-
# adjust the attributes here as well.
|
8
|
-
let(:valid_attributes) { { :title => "MyString"} }
|
9
|
-
|
10
|
-
# This should return the minimal set of values that should be in the session
|
11
|
-
# in order to pass any filters (e.g. authentication) defined in
|
12
|
-
# ArticlesController. Be sure to keep this updated too.
|
13
|
-
let(:valid_session) { { } }
|
14
|
-
|
15
|
-
# describe "GET index" do
|
16
|
-
# it "assigns all articles as @article" do
|
17
|
-
# article = Article.all
|
18
|
-
# get :index, {}, valid_session
|
19
|
-
# assigns(:pic_gallery).should eq(article)
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
|
23
|
-
describe 'GET new' do
|
24
|
-
before(:each) do
|
25
|
-
get :new
|
26
|
-
end
|
27
|
-
|
28
|
-
it "assigns a new pic_gallery as @pic_gallery" do
|
29
|
-
assigns(:pic_gallery).should be_a_new(PicGallery)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'POST create' do
|
34
|
-
describe "with valid params" do
|
35
|
-
it "creates a new PicGallery" do
|
36
|
-
expect {
|
37
|
-
post :create, {:pic_gallery => valid_attributes, :save_and_new => 1}, valid_session
|
38
|
-
}.to change(PicGallery, :count).by(1)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "assigns a newly created pic_gallery as @pic_gallery" do
|
42
|
-
post :create, {:pic_gallery => valid_attributes, :save_and_new => 1}, valid_session
|
43
|
-
assigns(:pic_gallery).should be_a(PicGallery)
|
44
|
-
assigns(:pic_gallery).should be_persisted
|
45
|
-
end
|
46
|
-
|
47
|
-
it "redirects to the index" do
|
48
|
-
post :create, {:pic_gallery => valid_attributes}, valid_session
|
49
|
-
response.should redirect_to(edit_backend_content_path(assigns(:pic_gallery).id))
|
50
|
-
end
|
51
|
-
|
52
|
-
it "has type param = 'PicGallery'" do
|
53
|
-
post :create, {:pic_gallery => valid_attributes, :save_and_new => 1 }, valid_session
|
54
|
-
assigns(:pic_gallery).type.should == "PicGallery"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "with invalid params" do
|
59
|
-
it "assigns a newly created but unsaved article as @pic_gallery" do
|
60
|
-
# Trigger the behavior that occurs when invalid params are submitted
|
61
|
-
Article.any_instance.stub(:save).and_return(false)
|
62
|
-
post :create, {:pic_gallery => { "title" => "" }, :save_and_new => 1}, valid_session
|
63
|
-
assigns(:pic_gallery).should be_a_new(PicGallery)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "re-renders the 'new' template" do
|
67
|
-
# Trigger the behavior that occurs when invalid params are submitted
|
68
|
-
Article.any_instance.stub(:save).and_return(false)
|
69
|
-
post :create, {:pic_gallery => { "title" => "" }, :save_and_new => 1}, valid_session
|
70
|
-
response.should render_template("new")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "PUT update" do
|
76
|
-
describe "with valid params" do
|
77
|
-
it "updates the requested article" do
|
78
|
-
gallery = PicGallery.create! valid_attributes
|
79
|
-
# Assuming there are no other articles in the database, this
|
80
|
-
# specifies that the Article created on the previous line
|
81
|
-
# receives the :update_attributes message with whatever params are
|
82
|
-
# submitted in the request.
|
83
|
-
PicGallery.any_instance.should_receive(:update).with({ "title" => "MyString" })
|
84
|
-
put :update, {:id => gallery.to_param, :pic_gallery => { "title" => "MyString" }, :save_and_new => 1}, valid_session
|
85
|
-
end
|
86
|
-
|
87
|
-
it "assigns the requested article as @article" do
|
88
|
-
gallery = PicGallery.create! valid_attributes
|
89
|
-
put :update, {:id => gallery.to_param, :pic_gallery => valid_attributes, :save_and_new => 1}, valid_session
|
90
|
-
assigns(:pic_gallery).should eq(gallery)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "redirects to the index" do
|
94
|
-
gallery = PicGallery.create! valid_attributes
|
95
|
-
put :update, {:id => gallery.to_param, :pic_gallery => valid_attributes}, valid_session
|
96
|
-
response.should redirect_to(backend_pic_galleries_path)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "with invalid params" do
|
101
|
-
it "assigns the article as @article" do
|
102
|
-
gallery = PicGallery.create! valid_attributes
|
103
|
-
# Trigger the behavior that occurs when invalid params are submitted
|
104
|
-
PicGallery.any_instance.stub(:save).and_return(false)
|
105
|
-
put :update, {:id => gallery.to_param, :pic_gallery => { "title" => "" }, :save_and_new => 1}, valid_session
|
106
|
-
assigns(:pic_gallery).should eq(gallery)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "re-renders the 'edit' template" do
|
110
|
-
gallery = PicGallery.create! valid_attributes
|
111
|
-
# Trigger the behavior that occurs when invalid params are submitted
|
112
|
-
PicGallery.any_instance.stub(:save).and_return(false)
|
113
|
-
put :update, {:id => gallery.to_param, :pic_gallery => { "title" => "" }, :save_and_new => 1}, valid_session
|
114
|
-
response.should render_template("edit")
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|