push_type_core 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/push_type/pushtype-logo.png +0 -0
  3. data/app/controllers/front_end_controller.rb +1 -1
  4. data/app/fields/push_type/markdown_field.rb +47 -0
  5. data/app/models/concerns/push_type/nestable.rb +4 -0
  6. data/app/models/concerns/push_type/presentable.rb +28 -0
  7. data/app/models/push_type/asset.rb +18 -4
  8. data/app/models/push_type/node.rb +1 -0
  9. data/lib/generators/push_type/field/USAGE +1 -1
  10. data/lib/generators/push_type/install/templates/push_type.rb +3 -0
  11. data/lib/generators/push_type/presenter/USAGE +8 -0
  12. data/lib/generators/push_type/presenter/presenter_generator.rb +9 -0
  13. data/lib/generators/push_type/presenter/templates/presenter.rb +12 -0
  14. data/lib/push_type/config.rb +2 -0
  15. data/lib/push_type/core/engine.rb +1 -0
  16. data/lib/push_type/core.rb +1 -0
  17. data/lib/push_type/presenter.rb +19 -0
  18. data/lib/push_type/version.rb +1 -1
  19. data/test/controllers/front_end_controller_test.rb +1 -0
  20. data/test/dummy/config/initializers/push_type.rb +4 -1
  21. data/test/dummy/config/secrets.yml +2 -2
  22. data/test/dummy/db/migrate/{20150222152443_create_push_type_users.push_type.rb → 20150310192149_create_push_type_users.push_type.rb} +0 -0
  23. data/test/dummy/db/migrate/{20150222152444_create_push_type_nodes.push_type.rb → 20150310192150_create_push_type_nodes.push_type.rb} +0 -0
  24. data/test/dummy/db/migrate/{20150222152445_create_push_type_node_hierarchies.push_type.rb → 20150310192151_create_push_type_node_hierarchies.push_type.rb} +0 -0
  25. data/test/dummy/db/migrate/{20150222152446_create_push_type_assets.push_type.rb → 20150310192152_create_push_type_assets.push_type.rb} +0 -0
  26. data/test/dummy/db/schema.rb +1 -1
  27. data/test/dummy/log/test.log +2033 -1719
  28. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  29. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  30. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  31. data/test/dummy/tmp/generators/config/initializers/push_type.rb +36 -0
  32. data/test/dummy/tmp/generators/config/routes.rb +59 -0
  33. data/test/lib/generators/push_type/presenter_generator_test.rb +16 -0
  34. data/test/lib/push_type/field_type_test.rb +17 -0
  35. data/test/lib/push_type/presenter_test.rb +24 -0
  36. data/test/models/concerns/push_type/nestable_test.rb +4 -0
  37. data/test/models/concerns/push_type/presentable_test.rb +19 -0
  38. data/test/models/push_type/asset_test.rb +61 -1
  39. metadata +41 -14
  40. data/test/dummy/tmp/generators/app/models/home_page.rb +0 -12
  41. data/test/dummy/tmp/generators/app/views/nodes/home_page.html.erb +0 -13
@@ -0,0 +1,36 @@
1
+ PushType.setup do |config|
2
+
3
+ config.root_nodes = :all
4
+
5
+ config.unexposed_nodes = []
6
+
7
+ config.home_slug = 'home'
8
+
9
+ config.media_styles = {
10
+ large: '1024x1024>',
11
+ medium: '512x512>',
12
+ small: '256x256>'
13
+ }
14
+
15
+ # Configure the default mailer "from" address
16
+ config.mailer_sender = 'pushtype@example.com'
17
+
18
+ # Dragonfly datastore configuration
19
+ config.dragonfly_datastore = :file
20
+ config.dragonfly_datastore_options = {
21
+ root_path: Rails.root.join('public/system/dragonfly', Rails.env),
22
+ server_root: Rails.root.join('public')
23
+ }
24
+
25
+ # For S3 storage, remember to add to Gemfile:
26
+ # gem 'dragonfly-s3_data_store'
27
+ # config.dragonfly_datastore = :s3
28
+ # config.dragonfly_datastore_options = {
29
+ # bucket_name: ENV['S3_BUCKET'],
30
+ # access_key_id: ENV['S3_ACCESS_KEY_ID'],
31
+ # secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
32
+ # }
33
+
34
+ # config.dragonfly_secret = '3764b84c0b63ebfbca0285d9f74cde7a89cdd9efe70ddf64256f004eb2d81af8'
35
+
36
+ end
@@ -0,0 +1,59 @@
1
+ Rails.application.routes.draw do
2
+
3
+ mount_push_type
4
+
5
+ # The priority is based upon order of creation: first created -> highest priority.
6
+ # See how all your routes lay out with "rake routes".
7
+
8
+ # You can have the root of your site routed with "root"
9
+ # root 'welcome#index'
10
+
11
+ # Example of regular route:
12
+ # get 'products/:id' => 'catalog#view'
13
+
14
+ # Example of named route that can be invoked with purchase_url(id: product.id)
15
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
16
+
17
+ # Example resource route (maps HTTP verbs to controller actions automatically):
18
+ # resources :products
19
+
20
+ # Example resource route with options:
21
+ # resources :products do
22
+ # member do
23
+ # get 'short'
24
+ # post 'toggle'
25
+ # end
26
+ #
27
+ # collection do
28
+ # get 'sold'
29
+ # end
30
+ # end
31
+
32
+ # Example resource route with sub-resources:
33
+ # resources :products do
34
+ # resources :comments, :sales
35
+ # resource :seller
36
+ # end
37
+
38
+ # Example resource route with more complex sub-resources:
39
+ # resources :products do
40
+ # resources :comments
41
+ # resources :sales do
42
+ # get 'recent', on: :collection
43
+ # end
44
+ # end
45
+
46
+ # Example resource route with concerns:
47
+ # concern :toggleable do
48
+ # post 'toggle'
49
+ # end
50
+ # resources :posts, concerns: :toggleable
51
+ # resources :photos, concerns: :toggleable
52
+
53
+ # Example resource route within a namespace:
54
+ # namespace :admin do
55
+ # # Directs /admin/products/* to Admin::ProductsController
56
+ # # (app/controllers/admin/products_controller.rb)
57
+ # resources :products
58
+ # end
59
+ end
@@ -0,0 +1,16 @@
1
+ require "test_helper"
2
+ require "generators/push_type/presenter/presenter_generator"
3
+
4
+ module PushType
5
+ describe PresenterGenerator do
6
+ tests PresenterGenerator
7
+ destination Rails.root.join('tmp/generators')
8
+
9
+ before :all do
10
+ prepare_destination
11
+ run_generator ['page']
12
+ end
13
+
14
+ it { assert_file 'app/presenters/page_presenter.rb', %r{class PagePresenter < PushType::Presenter} }
15
+ end
16
+ end
@@ -52,6 +52,23 @@ module PushType
52
52
  it { field.form_helper.must_equal :text_area }
53
53
  end
54
54
 
55
+ describe MarkdownField do
56
+ let(:field) { PushType::MarkdownField.new :foo }
57
+ it { field.form_helper.must_equal :text_area }
58
+ it { field.markdown.must_be_instance_of Redcarpet::Markdown }
59
+
60
+ describe 'dynamic methods' do
61
+ before do
62
+ DatabaseCleaner.clean_with :truncation
63
+ Page.instance_variable_set '@fields', ActiveSupport::OrderedHash.new
64
+ Page.field :body, :markdown
65
+ end
66
+ after { Page.instance_variable_set '@fields', ActiveSupport::OrderedHash.new }
67
+ let(:page) { Page.create FactoryGirl.attributes_for(:node, body: '**foo** *bar*') }
68
+ it { page.present!.body.strip.must_equal '<p><strong>foo</strong> <em>bar</em></p>' }
69
+ end
70
+ end
71
+
55
72
  describe ArrayField do
56
73
  let(:field) { PushType::ArrayField.new :foo }
57
74
  it { field.param.must_equal foo: [] }
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe Presenter do
5
+
6
+ let(:page) { Page.create FactoryGirl.attributes_for(:node) }
7
+
8
+ describe 'without view context' do
9
+ let(:presenter) { PushType::Presenter.new page }
10
+ it { presenter.must_be_instance_of Page }
11
+ it { presenter.class.ancestors.must_include PushType::Presenter }
12
+ it { presenter.model.must_equal page }
13
+ it { presenter.title.must_equal page.title }
14
+ it { proc { presenter.helpers }.must_raise RuntimeError }
15
+ end
16
+
17
+ describe 'with view context' do
18
+ let(:view_context) { ApplicationController.new.view_context }
19
+ let(:presenter) { PushType::Presenter.new page, view_context }
20
+ it { presenter.helpers.must_respond_to :content_tag }
21
+ end
22
+
23
+ end
24
+ end
@@ -26,24 +26,28 @@ module PushType
26
26
  before { TestPage.has_child_nodes false }
27
27
  it { TestPage.child_nodes.must_equal [] }
28
28
  it { page.child_nodes.must_equal [] }
29
+ it { page.wont_be :descendable? }
29
30
  end
30
31
 
31
32
  describe 'when all' do
32
33
  before { TestPage.has_child_nodes :all }
33
34
  it { TestPage.child_nodes.must_equal roots }
34
35
  it { page.child_nodes.must_equal roots }
36
+ it { page.must_be :descendable? }
35
37
  end
36
38
 
37
39
  describe 'when specific' do
38
40
  before { TestPage.has_child_nodes :page }
39
41
  it { TestPage.child_nodes.must_equal ['page'] }
40
42
  it { page.child_nodes.must_equal ['page'] }
43
+ it { page.must_be :descendable? }
41
44
  end
42
45
 
43
46
  describe 'when nonsense' do
44
47
  before { TestPage.has_child_nodes :foo, :bar }
45
48
  it { TestPage.child_nodes.must_equal [] }
46
49
  it { page.child_nodes.must_equal [] }
50
+ it { page.wont_be :descendable? }
47
51
  end
48
52
 
49
53
  describe 'without options' do
@@ -0,0 +1,19 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe Presentable do
5
+
6
+ describe 'class methods' do
7
+ it { Page.presenter_class_name.must_equal 'PagePresenter' }
8
+ it { Page.presenter_class.must_be_instance_of Class }
9
+ end
10
+
11
+ describe 'instance methods' do
12
+ let(:page) { Page.new FactoryGirl.attributes_for(:node) }
13
+ it { page.presenter_class.must_be_instance_of Class }
14
+ it { page.present!.must_be_instance_of Page }
15
+ it { page.present!.class.ancestors.must_include PushType::Presenter }
16
+ end
17
+
18
+ end
19
+ end
@@ -31,10 +31,70 @@ module PushType
31
31
  it { video.wont_be :image? }
32
32
  it { video.wont_be :audio? }
33
33
  it { video.must_be :video? }
34
- it { doc.kind.must_equal :document }
34
+ it { doc.kind.must_equal :pdf }
35
35
  it { doc.wont_be :image? }
36
36
  it { doc.wont_be :audio? }
37
37
  it { doc.wont_be :video? }
38
+
39
+ describe 'documents' do
40
+ let(:asset) { PushType::Asset.new }
41
+ it 'should detect modern word docs' do
42
+ asset.mime_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
43
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :doc }
44
+ end
45
+ it 'should detect modern legacy word docs' do
46
+ asset.mime_type = 'application/vnd.msword'
47
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :doc }
48
+ end
49
+ it 'should detect plain text files' do
50
+ asset.mime_type = 'text/plain'
51
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :doc }
52
+ end
53
+ it 'should detect rich text files' do
54
+ asset.mime_type = 'text/rtf'
55
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :doc }
56
+ end
57
+ end
58
+
59
+ describe 'spreadsheets' do
60
+ let(:asset) { PushType::Asset.new }
61
+ it 'should detect modern excel docs' do
62
+ asset.mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
63
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :sheet }
64
+ end
65
+ it 'should detect modern legacy excel docs' do
66
+ asset.mime_type = 'application/vnd.ms-excel'
67
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :sheet }
68
+ end
69
+ end
70
+
71
+ describe 'presentations' do
72
+ let(:asset) { PushType::Asset.new }
73
+ it 'should detect modern excel docs' do
74
+ asset.mime_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
75
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :slides }
76
+ end
77
+ it 'should detect modern legacy excel docs' do
78
+ asset.mime_type = 'application/vnd.ms-powerpoint'
79
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :slides }
80
+ end
81
+ end
82
+
83
+ describe 'code' do
84
+ let(:asset) { PushType::Asset.new }
85
+ it 'should detect html' do
86
+ asset.mime_type = 'text/html'
87
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :code }
88
+ end
89
+ it 'should detect javascript' do
90
+ asset.mime_type = 'text/javascript'
91
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :code }
92
+ end
93
+ it 'should detect xml' do
94
+ asset.mime_type = 'application/xml'
95
+ asset.stub(:file_stored?, true) { asset.kind.must_equal :code }
96
+ end
97
+ end
38
98
  end
39
99
 
40
100
  describe '#description_or_file_name' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: push_type_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Russell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-23 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.0.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: redcarpet
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.2.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.2.2
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: minitest-rails
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -119,11 +133,13 @@ files:
119
133
  - LICENSE.md
120
134
  - README.md
121
135
  - app/assets/images/push_type/pushtype-favicon.png
136
+ - app/assets/images/push_type/pushtype-logo.png
122
137
  - app/assets/images/push_type/pushtype-logo.svg
123
138
  - app/controllers/concerns/push_type/application_controller_methods.rb
124
139
  - app/controllers/front_end_controller.rb
125
140
  - app/fields/push_type/array_field.rb
126
141
  - app/fields/push_type/date_field.rb
142
+ - app/fields/push_type/markdown_field.rb
127
143
  - app/fields/push_type/number_field.rb
128
144
  - app/fields/push_type/string_field.rb
129
145
  - app/fields/push_type/tag_list_field.rb
@@ -131,6 +147,7 @@ files:
131
147
  - app/helpers/push_type/application_helper.rb
132
148
  - app/models/concerns/push_type/customizable.rb
133
149
  - app/models/concerns/push_type/nestable.rb
150
+ - app/models/concerns/push_type/presentable.rb
134
151
  - app/models/concerns/push_type/publishable.rb
135
152
  - app/models/concerns/push_type/templatable.rb
136
153
  - app/models/concerns/push_type/trashable.rb
@@ -160,6 +177,9 @@ files:
160
177
  - lib/generators/push_type/node/node_generator.rb
161
178
  - lib/generators/push_type/node/templates/node.rb
162
179
  - lib/generators/push_type/node/templates/template.html.erb
180
+ - lib/generators/push_type/presenter/USAGE
181
+ - lib/generators/push_type/presenter/presenter_generator.rb
182
+ - lib/generators/push_type/presenter/templates/presenter.rb
163
183
  - lib/push_type/config.rb
164
184
  - lib/push_type/core.rb
165
185
  - lib/push_type/core/engine.rb
@@ -171,6 +191,7 @@ files:
171
191
  - lib/push_type/menu_builder/menu.rb
172
192
  - lib/push_type/menu_builder/menu_item.rb
173
193
  - lib/push_type/menu_builder/menu_renderer.rb
194
+ - lib/push_type/presenter.rb
174
195
  - lib/push_type/rails/routes.rb
175
196
  - lib/push_type/tag_list_query.rb
176
197
  - lib/push_type/testing/common_rake.rb
@@ -214,10 +235,10 @@ files:
214
235
  - test/dummy/config/locales/en.yml
215
236
  - test/dummy/config/routes.rb
216
237
  - test/dummy/config/secrets.yml
217
- - test/dummy/db/migrate/20150222152443_create_push_type_users.push_type.rb
218
- - test/dummy/db/migrate/20150222152444_create_push_type_nodes.push_type.rb
219
- - test/dummy/db/migrate/20150222152445_create_push_type_node_hierarchies.push_type.rb
220
- - test/dummy/db/migrate/20150222152446_create_push_type_assets.push_type.rb
238
+ - test/dummy/db/migrate/20150310192149_create_push_type_users.push_type.rb
239
+ - test/dummy/db/migrate/20150310192150_create_push_type_nodes.push_type.rb
240
+ - test/dummy/db/migrate/20150310192151_create_push_type_node_hierarchies.push_type.rb
241
+ - test/dummy/db/migrate/20150310192152_create_push_type_assets.push_type.rb
221
242
  - test/dummy/db/schema.rb
222
243
  - test/dummy/db/seeds.rb
223
244
  - test/dummy/log/test.log
@@ -229,8 +250,8 @@ files:
229
250
  - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
230
251
  - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
231
252
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
232
- - test/dummy/tmp/generators/app/models/home_page.rb
233
- - test/dummy/tmp/generators/app/views/nodes/home_page.html.erb
253
+ - test/dummy/tmp/generators/config/initializers/push_type.rb
254
+ - test/dummy/tmp/generators/config/routes.rb
234
255
  - test/files/audio.m3u
235
256
  - test/files/document.pdf
236
257
  - test/files/image.png
@@ -238,6 +259,7 @@ files:
238
259
  - test/lib/generators/push_type/field_generator_test.rb
239
260
  - test/lib/generators/push_type/install_generator_test.rb
240
261
  - test/lib/generators/push_type/node_generator_test.rb
262
+ - test/lib/generators/push_type/presenter_generator_test.rb
241
263
  - test/lib/push_type/core_test.rb
242
264
  - test/lib/push_type/field_type_test.rb
243
265
  - test/lib/push_type/menu_builder/menu_dsl_test.rb
@@ -246,9 +268,11 @@ files:
246
268
  - test/lib/push_type/menu_builder/menu_renderer_test.rb
247
269
  - test/lib/push_type/menu_builder/menu_test.rb
248
270
  - test/lib/push_type/menu_builder_test.rb
271
+ - test/lib/push_type/presenter_test.rb
249
272
  - test/lib/push_type/tag_list_query_test.rb
250
273
  - test/models/concerns/push_type/customizable_test.rb
251
274
  - test/models/concerns/push_type/nestable_test.rb
275
+ - test/models/concerns/push_type/presentable_test.rb
252
276
  - test/models/concerns/push_type/publishable_test.rb
253
277
  - test/models/concerns/push_type/templatable_test.rb
254
278
  - test/models/concerns/push_type/trashable_test.rb
@@ -313,10 +337,10 @@ test_files:
313
337
  - test/dummy/config/routes.rb
314
338
  - test/dummy/config/secrets.yml
315
339
  - test/dummy/config.ru
316
- - test/dummy/db/migrate/20150222152443_create_push_type_users.push_type.rb
317
- - test/dummy/db/migrate/20150222152444_create_push_type_nodes.push_type.rb
318
- - test/dummy/db/migrate/20150222152445_create_push_type_node_hierarchies.push_type.rb
319
- - test/dummy/db/migrate/20150222152446_create_push_type_assets.push_type.rb
340
+ - test/dummy/db/migrate/20150310192149_create_push_type_users.push_type.rb
341
+ - test/dummy/db/migrate/20150310192150_create_push_type_nodes.push_type.rb
342
+ - test/dummy/db/migrate/20150310192151_create_push_type_node_hierarchies.push_type.rb
343
+ - test/dummy/db/migrate/20150310192152_create_push_type_assets.push_type.rb
320
344
  - test/dummy/db/schema.rb
321
345
  - test/dummy/db/seeds.rb
322
346
  - test/dummy/log/test.log
@@ -330,8 +354,8 @@ test_files:
330
354
  - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
331
355
  - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
332
356
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
333
- - test/dummy/tmp/generators/app/models/home_page.rb
334
- - test/dummy/tmp/generators/app/views/nodes/home_page.html.erb
357
+ - test/dummy/tmp/generators/config/initializers/push_type.rb
358
+ - test/dummy/tmp/generators/config/routes.rb
335
359
  - test/files/audio.m3u
336
360
  - test/files/document.pdf
337
361
  - test/files/image.png
@@ -339,6 +363,7 @@ test_files:
339
363
  - test/lib/generators/push_type/field_generator_test.rb
340
364
  - test/lib/generators/push_type/install_generator_test.rb
341
365
  - test/lib/generators/push_type/node_generator_test.rb
366
+ - test/lib/generators/push_type/presenter_generator_test.rb
342
367
  - test/lib/push_type/core_test.rb
343
368
  - test/lib/push_type/field_type_test.rb
344
369
  - test/lib/push_type/menu_builder/menu_dsl_test.rb
@@ -347,9 +372,11 @@ test_files:
347
372
  - test/lib/push_type/menu_builder/menu_renderer_test.rb
348
373
  - test/lib/push_type/menu_builder/menu_test.rb
349
374
  - test/lib/push_type/menu_builder_test.rb
375
+ - test/lib/push_type/presenter_test.rb
350
376
  - test/lib/push_type/tag_list_query_test.rb
351
377
  - test/models/concerns/push_type/customizable_test.rb
352
378
  - test/models/concerns/push_type/nestable_test.rb
379
+ - test/models/concerns/push_type/presentable_test.rb
353
380
  - test/models/concerns/push_type/publishable_test.rb
354
381
  - test/models/concerns/push_type/templatable_test.rb
355
382
  - test/models/concerns/push_type/trashable_test.rb