comfortable_mexican_sofa 1.12.2 → 1.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/comfortable_mexican_sofa/admin/application.js +1 -1
  3. data/app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee +50 -57
  4. data/app/assets/javascripts/comfortable_mexican_sofa/cms/files.js.coffee +29 -0
  5. data/app/assets/javascripts/comfortable_mexican_sofa/cms/uploader.js.coffee +139 -0
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/admin/application.css +1 -1
  7. data/app/assets/stylesheets/comfortable_mexican_sofa/application.css.sass +1 -0
  8. data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +67 -84
  9. data/app/controllers/comfy/admin/cms/base_controller.rb +11 -8
  10. data/app/controllers/comfy/admin/cms/categories_controller.rb +10 -9
  11. data/app/controllers/comfy/admin/cms/files_controller.rb +38 -69
  12. data/app/controllers/comfy/admin/cms/layouts_controller.rb +4 -3
  13. data/app/controllers/comfy/admin/cms/pages_controller.rb +17 -11
  14. data/app/controllers/comfy/admin/cms/revisions_controller.rb +10 -9
  15. data/app/controllers/comfy/admin/cms/sites_controller.rb +2 -1
  16. data/app/controllers/comfy/admin/cms/snippets_controller.rb +3 -2
  17. data/app/controllers/comfy/cms/assets_controller.rb +17 -9
  18. data/app/controllers/comfy/cms/content_controller.rb +20 -14
  19. data/app/models/comfy/cms/file.rb +16 -15
  20. data/app/models/comfy/cms/page.rb +2 -1
  21. data/app/models/comfy/cms/site.rb +5 -0
  22. data/app/views/comfy/admin/cms/files/_file.html.haml +26 -13
  23. data/app/views/comfy/admin/cms/files/_form.html.haml +8 -5
  24. data/app/views/comfy/admin/cms/files/_modal.html.haml +4 -0
  25. data/app/views/comfy/admin/cms/files/create.js.erb +1 -0
  26. data/app/views/comfy/admin/cms/files/destroy.js.coffee +2 -2
  27. data/app/views/comfy/admin/cms/files/index.html.haml +33 -31
  28. data/app/views/comfy/admin/cms/layouts/_form.html.haml +2 -5
  29. data/app/views/comfy/admin/cms/pages/_form.html.haml +7 -8
  30. data/app/views/comfy/admin/cms/pages/_form_blocks.html.haml +3 -3
  31. data/app/views/comfy/admin/cms/sites/_form.html.haml +2 -2
  32. data/app/views/comfy/admin/cms/sites/index.html.haml +1 -2
  33. data/app/views/comfy/admin/cms/snippets/_form.html.haml +5 -8
  34. data/app/views/kaminari/comfy/_paginator.html.haml +10 -11
  35. data/app/views/layouts/comfy/admin/cms.html.haml +3 -2
  36. data/app/views/layouts/comfy/admin/cms/_body.html.haml +8 -7
  37. data/app/views/layouts/comfy/admin/cms/{_center.html.haml → _flash.html.haml} +0 -3
  38. data/app/views/layouts/comfy/admin/cms/_footer_js.html.haml +0 -4
  39. data/app/views/layouts/comfy/admin/cms/_left.html.haml +10 -5
  40. data/comfortable_mexican_sofa.gemspec +9 -8
  41. data/config/cms_routes.rb +2 -2
  42. data/config/initializers/comfortable_mexican_sofa.rb +31 -13
  43. data/config/initializers/plupload.rb +9 -0
  44. data/config/locales/en.yml +18 -16
  45. data/db/upgrade_migrations/08_upgrade_to_1_12_0.rb +3 -0
  46. data/lib/comfortable_mexican_sofa.rb +6 -5
  47. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +20 -0
  48. data/lib/comfortable_mexican_sofa/access_control/admin_authorization.rb +8 -0
  49. data/lib/comfortable_mexican_sofa/access_control/public_authentication.rb +8 -0
  50. data/lib/comfortable_mexican_sofa/configuration.rb +11 -3
  51. data/lib/comfortable_mexican_sofa/engine.rb +1 -0
  52. data/lib/comfortable_mexican_sofa/fixture.rb +7 -5
  53. data/lib/comfortable_mexican_sofa/fixture/category.rb +10 -3
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +1 -1
  55. data/lib/comfortable_mexican_sofa/routes/cms.rb +3 -0
  56. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  57. data/lib/generators/comfy/cms/assets_generator.rb +15 -0
  58. data/lib/generators/comfy/cms/cms_generator.rb +19 -12
  59. data/lib/generators/comfy/cms/controllers_generator.rb +13 -0
  60. data/lib/generators/comfy/cms/models_generator.rb +13 -0
  61. data/lib/generators/comfy/cms/views_generator.rb +13 -0
  62. data/test/controllers/comfy/admin/cms/files_controller_test.rb +22 -95
  63. data/test/controllers/comfy/admin/cms/layouts_controller_test.rb +9 -10
  64. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +26 -27
  65. data/test/controllers/comfy/admin/cms/snippets_controller_test.rb +7 -8
  66. data/test/controllers/comfy/cms/content_controller_test.rb +30 -4
  67. data/test/gemfiles/Gemfile.rails.4.0 +3 -2
  68. data/test/gemfiles/Gemfile.rails.4.1 +3 -2
  69. data/test/gemfiles/Gemfile.rails.master +3 -2
  70. data/test/generators/cms_assets_generator_test.rb +13 -0
  71. data/test/generators/cms_controllers_generator_test.rb +12 -0
  72. data/test/generators/cms_generator_test.rb +10 -8
  73. data/test/generators/cms_models_generator_test.rb +12 -0
  74. data/test/generators/cms_views_generator_test.rb +12 -0
  75. data/test/generators/scaffold_generator_test.rb +6 -7
  76. data/test/integration/access_control_test.rb +141 -0
  77. data/test/integration/routing_test.rb +19 -0
  78. data/test/lib/configuration_test.rb +8 -7
  79. data/test/lib/fixtures/categories_test.rb +1 -0
  80. data/test/lib/fixtures/files_test.rb +5 -0
  81. data/test/lib/fixtures/pages_test.rb +17 -1
  82. data/test/lib/fixtures/snippets_test.rb +5 -0
  83. data/test/models/page_test.rb +6 -0
  84. data/test/models/site_test.rb +9 -0
  85. data/test/test_helper.rb +28 -19
  86. metadata +82 -48
  87. data/app/views/comfy/admin/cms/files/_index.html.haml +0 -11
  88. data/lib/comfortable_mexican_sofa/authentication/dummy_auth.rb +0 -8
  89. data/lib/comfortable_mexican_sofa/authentication/http_auth.rb +0 -25
  90. data/test/integration/authentication_test.rb +0 -48
metadata CHANGED
@@ -1,225 +1,245 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfortable_mexican_sofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.2
4
+ version: 1.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-30 00:00:00.000000000 Z
11
+ date: 2014-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 4.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rails-i18n
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: 4.0.0
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 4.0.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bootstrap_form
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: 2.1.1
53
+ version: 2.2.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: 2.1.1
60
+ version: 2.2.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: active_link_to
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
67
  version: 1.0.0
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: 1.0.0
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: paperclip
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - '>='
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
81
  version: 4.0.0
76
82
  type: :runtime
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - '>='
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
88
  version: 4.0.0
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: kramdown
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - '>='
93
+ - - ">="
88
94
  - !ruby/object:Gem::Version
89
95
  version: 1.0.0
90
96
  type: :runtime
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - '>='
100
+ - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: 1.0.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: jquery-rails
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - '>='
107
+ - - ">="
102
108
  - !ruby/object:Gem::Version
103
109
  version: 3.0.0
104
110
  type: :runtime
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - '>='
114
+ - - ">="
109
115
  - !ruby/object:Gem::Version
110
116
  version: 3.0.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: jquery-ui-rails
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - '>='
121
+ - - ">="
116
122
  - !ruby/object:Gem::Version
117
123
  version: 5.0.0
118
124
  type: :runtime
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - '>='
128
+ - - ">="
123
129
  - !ruby/object:Gem::Version
124
130
  version: 5.0.0
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: haml-rails
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
- - - '>='
135
+ - - ">="
130
136
  - !ruby/object:Gem::Version
131
137
  version: 0.3.0
132
138
  type: :runtime
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
- - - '>='
142
+ - - ">="
137
143
  - !ruby/object:Gem::Version
138
144
  version: 0.3.0
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: sass-rails
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
- - - '>='
149
+ - - ">="
144
150
  - !ruby/object:Gem::Version
145
- version: 4.0.1
151
+ version: 4.0.3
146
152
  type: :runtime
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
- - - '>='
156
+ - - ">="
151
157
  - !ruby/object:Gem::Version
152
- version: 4.0.1
158
+ version: 4.0.3
153
159
  - !ruby/object:Gem::Dependency
154
160
  name: coffee-rails
155
161
  requirement: !ruby/object:Gem::Requirement
156
162
  requirements:
157
- - - '>='
163
+ - - ">="
158
164
  - !ruby/object:Gem::Version
159
165
  version: 3.1.0
160
166
  type: :runtime
161
167
  prerelease: false
162
168
  version_requirements: !ruby/object:Gem::Requirement
163
169
  requirements:
164
- - - '>='
170
+ - - ">="
165
171
  - !ruby/object:Gem::Version
166
172
  version: 3.1.0
167
173
  - !ruby/object:Gem::Dependency
168
174
  name: codemirror-rails
169
175
  requirement: !ruby/object:Gem::Requirement
170
176
  requirements:
171
- - - '>='
177
+ - - ">="
172
178
  - !ruby/object:Gem::Version
173
179
  version: 3.0.0
174
180
  type: :runtime
175
181
  prerelease: false
176
182
  version_requirements: !ruby/object:Gem::Requirement
177
183
  requirements:
178
- - - '>='
184
+ - - ">="
179
185
  - !ruby/object:Gem::Version
180
186
  version: 3.0.0
181
187
  - !ruby/object:Gem::Dependency
182
188
  name: kaminari
183
189
  requirement: !ruby/object:Gem::Requirement
184
190
  requirements:
185
- - - '>='
191
+ - - ">="
186
192
  - !ruby/object:Gem::Version
187
193
  version: 0.14.0
188
194
  type: :runtime
189
195
  prerelease: false
190
196
  version_requirements: !ruby/object:Gem::Requirement
191
197
  requirements:
192
- - - '>='
198
+ - - ">="
193
199
  - !ruby/object:Gem::Version
194
200
  version: 0.14.0
195
201
  - !ruby/object:Gem::Dependency
196
202
  name: tinymce-rails
197
203
  requirement: !ruby/object:Gem::Requirement
198
204
  requirements:
199
- - - '>='
205
+ - - ">="
200
206
  - !ruby/object:Gem::Version
201
207
  version: 4.0.0
202
208
  type: :runtime
203
209
  prerelease: false
204
210
  version_requirements: !ruby/object:Gem::Requirement
205
211
  requirements:
206
- - - '>='
212
+ - - ">="
207
213
  - !ruby/object:Gem::Version
208
214
  version: 4.0.0
209
215
  - !ruby/object:Gem::Dependency
210
216
  name: bootstrap-sass
211
217
  requirement: !ruby/object:Gem::Requirement
212
218
  requirements:
213
- - - ~>
219
+ - - ">="
214
220
  - !ruby/object:Gem::Version
215
- version: 3.1.0
221
+ version: 3.2.0
216
222
  type: :runtime
217
223
  prerelease: false
218
224
  version_requirements: !ruby/object:Gem::Requirement
219
225
  requirements:
220
- - - ~>
226
+ - - ">="
221
227
  - !ruby/object:Gem::Version
222
- version: 3.1.0
228
+ version: 3.2.0
229
+ - !ruby/object:Gem::Dependency
230
+ name: plupload-rails
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: 1.2.1
236
+ type: :runtime
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: 1.2.1
223
243
  description: ComfortableMexicanSofa is a powerful Rails 4 CMS Engine
224
244
  email:
225
245
  - oleg@khabarov.ca
@@ -227,8 +247,8 @@ executables: []
227
247
  extensions: []
228
248
  extra_rdoc_files: []
229
249
  files:
230
- - .gitignore
231
- - .travis.yml
250
+ - ".gitignore"
251
+ - ".travis.yml"
232
252
  - CONTRIBUTING.md
233
253
  - Gemfile
234
254
  - LICENSE
@@ -246,6 +266,8 @@ files:
246
266
  - app/assets/images/comfortable_mexican_sofa/icon_snippet.gif
247
267
  - app/assets/javascripts/comfortable_mexican_sofa/admin/application.js
248
268
  - app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee
269
+ - app/assets/javascripts/comfortable_mexican_sofa/cms/files.js.coffee
270
+ - app/assets/javascripts/comfortable_mexican_sofa/cms/uploader.js.coffee
249
271
  - app/assets/javascripts/comfortable_mexican_sofa/lib/bootstrap-datetimepicker.js
250
272
  - app/assets/javascripts/comfortable_mexican_sofa/lib/diff.js.coffee
251
273
  - app/assets/javascripts/comfortable_mexican_sofa/lib/diff/diff_match_patch.min.js
@@ -288,8 +310,9 @@ files:
288
310
  - app/views/comfy/admin/cms/categories/update.js.erb
289
311
  - app/views/comfy/admin/cms/files/_file.html.haml
290
312
  - app/views/comfy/admin/cms/files/_form.html.haml
291
- - app/views/comfy/admin/cms/files/_index.html.haml
313
+ - app/views/comfy/admin/cms/files/_modal.html.haml
292
314
  - app/views/comfy/admin/cms/files/_page_form.html.haml
315
+ - app/views/comfy/admin/cms/files/create.js.erb
293
316
  - app/views/comfy/admin/cms/files/destroy.js.coffee
294
317
  - app/views/comfy/admin/cms/files/edit.html.haml
295
318
  - app/views/comfy/admin/cms/files/index.html.haml
@@ -356,7 +379,7 @@ files:
356
379
  - app/views/kaminari/comfy/_prev_page.html.haml
357
380
  - app/views/layouts/comfy/admin/cms.html.haml
358
381
  - app/views/layouts/comfy/admin/cms/_body.html.haml
359
- - app/views/layouts/comfy/admin/cms/_center.html.haml
382
+ - app/views/layouts/comfy/admin/cms/_flash.html.haml
360
383
  - app/views/layouts/comfy/admin/cms/_footer.html.haml
361
384
  - app/views/layouts/comfy/admin/cms/_footer_js.html.haml
362
385
  - app/views/layouts/comfy/admin/cms/_head.html.haml
@@ -373,6 +396,7 @@ files:
373
396
  - config/environments/test.rb
374
397
  - config/initializers/comfortable_mexican_sofa.rb
375
398
  - config/initializers/paperclip.rb
399
+ - config/initializers/plupload.rb
376
400
  - config/initializers/secret_token.rb
377
401
  - config/locales/cs.yml
378
402
  - config/locales/da.yml
@@ -422,8 +446,9 @@ files:
422
446
  - db/upgrade_migrations/08_upgrade_to_1_12_0.rb
423
447
  - doc/preview.png
424
448
  - lib/comfortable_mexican_sofa.rb
425
- - lib/comfortable_mexican_sofa/authentication/dummy_auth.rb
426
- - lib/comfortable_mexican_sofa/authentication/http_auth.rb
449
+ - lib/comfortable_mexican_sofa/access_control/admin_authentication.rb
450
+ - lib/comfortable_mexican_sofa/access_control/admin_authorization.rb
451
+ - lib/comfortable_mexican_sofa/access_control/public_authentication.rb
427
452
  - lib/comfortable_mexican_sofa/configuration.rb
428
453
  - lib/comfortable_mexican_sofa/engine.rb
429
454
  - lib/comfortable_mexican_sofa/error.rb
@@ -470,7 +495,11 @@ files:
470
495
  - lib/comfortable_mexican_sofa/view_hooks.rb
471
496
  - lib/comfortable_mexican_sofa/view_methods.rb
472
497
  - lib/generators/comfy/cms/README
498
+ - lib/generators/comfy/cms/assets_generator.rb
473
499
  - lib/generators/comfy/cms/cms_generator.rb
500
+ - lib/generators/comfy/cms/controllers_generator.rb
501
+ - lib/generators/comfy/cms/models_generator.rb
502
+ - lib/generators/comfy/cms/views_generator.rb
474
503
  - lib/generators/comfy/scaffold/scaffold_generator.rb
475
504
  - lib/generators/comfy/scaffold/templates/controller.rb
476
505
  - lib/generators/comfy/scaffold/templates/migration.rb
@@ -529,12 +558,17 @@ files:
529
558
  - test/gemfiles/Gemfile.rails.4.0
530
559
  - test/gemfiles/Gemfile.rails.4.1
531
560
  - test/gemfiles/Gemfile.rails.master
561
+ - test/generators/cms_assets_generator_test.rb
562
+ - test/generators/cms_controllers_generator_test.rb
532
563
  - test/generators/cms_generator_test.rb
564
+ - test/generators/cms_models_generator_test.rb
565
+ - test/generators/cms_views_generator_test.rb
533
566
  - test/generators/scaffold_generator_test.rb
534
- - test/integration/authentication_test.rb
567
+ - test/integration/access_control_test.rb
535
568
  - test/integration/fixtures_test.rb
536
569
  - test/integration/mirrors_test.rb
537
570
  - test/integration/render_cms_test.rb
571
+ - test/integration/routing_test.rb
538
572
  - test/integration/sites_test.rb
539
573
  - test/integration/view_hooks_test.rb
540
574
  - test/lib/configuration_test.rb
@@ -588,17 +622,17 @@ require_paths:
588
622
  - lib
589
623
  required_ruby_version: !ruby/object:Gem::Requirement
590
624
  requirements:
591
- - - '>='
625
+ - - ">="
592
626
  - !ruby/object:Gem::Version
593
627
  version: 1.9.3
594
628
  required_rubygems_version: !ruby/object:Gem::Requirement
595
629
  requirements:
596
- - - '>='
630
+ - - ">="
597
631
  - !ruby/object:Gem::Version
598
632
  version: '0'
599
633
  requirements: []
600
634
  rubyforge_project:
601
- rubygems_version: 2.1.10
635
+ rubygems_version: 2.2.2
602
636
  signing_key:
603
637
  specification_version: 4
604
638
  summary: Rails 4 CMS Engine
@@ -1,11 +0,0 @@
1
- .box.file-uploader
2
- = form_for :file, :url => comfy_admin_cms_site_files_path(@site, :ajax => true), :html => {:multipart => true, :target => 'file-upload-frame'} do |form|
3
- %span.btn.btn-sm.btn-default.btn-file
4
- = t('.button')
5
- = form.file_field :file, :multiple => true, :id => nil
6
-
7
- .uploaded-files
8
- - @site.files.not_page_file.order(:label).each do |file|
9
- = render :partial => 'comfy/admin/cms/files/file', :object => file
10
-
11
- %iframe#file-upload-frame{:name => 'file-upload-frame', :src => ''}
@@ -1,8 +0,0 @@
1
- module ComfortableMexicanSofa::DummyAuth
2
-
3
- # Will always let you in
4
- def authenticate
5
- true
6
- end
7
-
8
- end
@@ -1,25 +0,0 @@
1
- module ComfortableMexicanSofa::HttpAuth
2
- # Set username and password in config/initializers/comfortable_mexican_sofa.rb
3
- # Like this:
4
- # ComfortableMexicanSofa::HttpAuth.username = 'myname'
5
- # ComfortableMexicanSofa::HttpAuth.password = 'mypassword'
6
- #
7
- # You can even use bcrypt (gem 'bcrypt-ruby'):
8
- # require 'bcrypt'
9
- # ComfortableMexicanSofa::HttpAuth.username = 'myname'
10
- # ComfortableMexicanSofa::HttpAuth.password = BCrypt::Password.new '... bcrypt hash ...'
11
- # Create the bcrypt hash with:
12
- # BCrypt::Password.create('password').to_s
13
- mattr_accessor :username,
14
- :password
15
-
16
- # Simple http_auth. When implementing some other form of authentication
17
- # this method should return +true+ if everything is great, or redirect user
18
- # to some other page, thus denying access to cms admin section.
19
- def authenticate
20
- authenticate_or_request_with_http_basic do |username, password|
21
- self.username == username && self.password == password
22
- end
23
- end
24
-
25
- end
@@ -1,48 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- class AuthenticationIntegrationTest < ActionDispatch::IntegrationTest
4
-
5
- module TestLockPublicAuth
6
- def authenticate
7
- return redirect_to('/lockout')
8
- end
9
- end
10
-
11
- module TestUnlockPublicAuth
12
- def authenticate
13
- true
14
- end
15
- end
16
-
17
- def test_get_with_unauthorized_access
18
- assert_equal 'ComfortableMexicanSofa::HttpAuth', ComfortableMexicanSofa.config.admin_auth
19
- get '/admin/sites'
20
- assert_response :unauthorized
21
- get '/'
22
- assert_response :success
23
- end
24
-
25
- def test_get_with_authorized_access
26
- http_auth :get, '/admin/sites'
27
- assert_response :success
28
- end
29
-
30
- def test_get_with_changed_default_config
31
- assert_equal 'ComfortableMexicanSofa::HttpAuth', ComfortableMexicanSofa.config.admin_auth
32
- ComfortableMexicanSofa::HttpAuth.username = 'newuser'
33
- ComfortableMexicanSofa::HttpAuth.password = 'newpass'
34
- http_auth :get, '/admin/sites'
35
- assert_response :unauthorized
36
- http_auth :get, '/admin/sites', {}, 'newuser', 'newpass'
37
- assert_response :success
38
- end
39
-
40
- def test_get_public_with_custom_auth
41
- Comfy::Cms::ContentController.send :include, TestLockPublicAuth
42
- get '/'
43
- assert_response :redirect
44
- assert_redirected_to '/lockout'
45
- # reset auth module
46
- Comfy::Cms::ContentController.send :include, TestUnlockPublicAuth
47
- end
48
- end