mokio 0.0.11 → 0.0.12

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