push_type_core 0.1.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +22 -0
  3. data/README.md +3 -0
  4. data/app/controllers/push_type/application_controller.rb +4 -0
  5. data/app/controllers/push_type/front_end_controller.rb +21 -0
  6. data/app/fields/push_type/date_field.rb +11 -0
  7. data/app/fields/push_type/number_field.rb +15 -0
  8. data/app/fields/push_type/rich_text_field.rb +10 -0
  9. data/app/fields/push_type/string_field.rb +4 -0
  10. data/app/fields/push_type/text_field.rb +7 -0
  11. data/app/helpers/push_type/application_helper.rb +4 -0
  12. data/app/models/concerns/push_type/field_store.rb +56 -0
  13. data/app/models/concerns/push_type/nestable.rb +23 -0
  14. data/app/models/concerns/push_type/templatable.rb +33 -0
  15. data/app/models/concerns/push_type/trashable.rb +23 -0
  16. data/app/models/push_type/asset.rb +61 -0
  17. data/app/models/push_type/node.rb +57 -0
  18. data/app/models/push_type/user.rb +18 -0
  19. data/app/views/layouts/push_type/application.html.erb +14 -0
  20. data/config/initializers/dragonfly.rb +24 -0
  21. data/config/routes.rb +2 -0
  22. data/db/migrate/20141117170533_create_push_type_users.rb +12 -0
  23. data/db/migrate/20141117204630_create_push_type_nodes.rb +24 -0
  24. data/db/migrate/20141117210644_create_push_type_node_hierarchies.rb +16 -0
  25. data/db/migrate/20141127151930_create_push_type_assets.rb +18 -0
  26. data/lib/generators/push_type/dummy/dummy_generator.rb +56 -0
  27. data/lib/generators/push_type/dummy/templates/application.rb +14 -0
  28. data/lib/generators/push_type/dummy/templates/boot.rb +4 -0
  29. data/lib/generators/push_type/dummy/templates/page.rb +6 -0
  30. data/lib/generators/push_type/install/install_generator.rb +28 -0
  31. data/lib/generators/push_type/install/templates/push_type.rb +5 -0
  32. data/lib/generators/push_type/node/USAGE +8 -0
  33. data/lib/generators/push_type/node/node_generator.rb +12 -0
  34. data/lib/generators/push_type/node/templates/node.rb +10 -0
  35. data/lib/generators/push_type/node/templates/template.html.erb +3 -0
  36. data/lib/push_type/core/engine.rb +24 -0
  37. data/lib/push_type/core.rb +45 -0
  38. data/lib/push_type/field_type.rb +40 -0
  39. data/lib/push_type/rails/routes.rb +19 -0
  40. data/lib/push_type/testing/common_rake.rb +19 -0
  41. data/lib/push_type/testing/factories.rb +41 -0
  42. data/lib/push_type/testing/setup.rb +26 -0
  43. data/lib/push_type/testing/support/expectations.rb +10 -0
  44. data/lib/push_type_core.rb +1 -0
  45. data/lib/tasks/push_type_tasks.rake +4 -0
  46. data/test/controllers/push_type/front_end_controller_test.rb +31 -0
  47. data/test/dummy/README.rdoc +28 -0
  48. data/test/dummy/Rakefile +6 -0
  49. data/test/dummy/app/assets/javascripts/application.js +16 -0
  50. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  51. data/test/dummy/app/controllers/application_controller.rb +5 -0
  52. data/test/dummy/app/helpers/application_helper.rb +2 -0
  53. data/test/dummy/app/models/page.rb +10 -0
  54. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  55. data/test/dummy/app/views/nodes/page.html.erb +3 -0
  56. data/test/dummy/bin/bundle +3 -0
  57. data/test/dummy/bin/rails +4 -0
  58. data/test/dummy/bin/rake +4 -0
  59. data/test/dummy/config/application.rb +14 -0
  60. data/test/dummy/config/boot.rb +4 -0
  61. data/test/dummy/config/database.yml +85 -0
  62. data/test/dummy/config/environment.rb +5 -0
  63. data/test/dummy/config/environments/development.rb +37 -0
  64. data/test/dummy/config/environments/production.rb +78 -0
  65. data/test/dummy/config/environments/test.rb +39 -0
  66. data/test/dummy/config/initializers/assets.rb +8 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  69. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  70. data/test/dummy/config/initializers/inflections.rb +16 -0
  71. data/test/dummy/config/initializers/mime_types.rb +4 -0
  72. data/test/dummy/config/initializers/push_type.rb +5 -0
  73. data/test/dummy/config/initializers/session_store.rb +3 -0
  74. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  75. data/test/dummy/config/locales/en.yml +23 -0
  76. data/test/dummy/config/routes.rb +59 -0
  77. data/test/dummy/config/secrets.yml +22 -0
  78. data/test/dummy/config.ru +4 -0
  79. data/test/dummy/db/migrate/20141205213452_create_push_type_users.push_type.rb +13 -0
  80. data/test/dummy/db/migrate/20141205213453_create_push_type_nodes.push_type.rb +25 -0
  81. data/test/dummy/db/migrate/20141205213454_create_push_type_node_hierarchies.push_type.rb +17 -0
  82. data/test/dummy/db/migrate/20141205213455_create_push_type_assets.push_type.rb +19 -0
  83. data/test/dummy/db/schema.rb +67 -0
  84. data/test/dummy/db/seeds.rb +7 -0
  85. data/test/dummy/log/test.log +1234 -0
  86. data/test/dummy/public/404.html +67 -0
  87. data/test/dummy/public/422.html +67 -0
  88. data/test/dummy/public/500.html +66 -0
  89. data/test/dummy/public/favicon.ico +0 -0
  90. data/test/dummy/public/robots.txt +5 -0
  91. data/test/files/audio.m3u +1 -0
  92. data/test/files/document.pdf +0 -0
  93. data/test/files/image.png +0 -0
  94. data/test/files/video.mp4 +0 -0
  95. data/test/models/push_type/asset_test.rb +63 -0
  96. data/test/models/push_type/node_test.rb +87 -0
  97. data/test/models/push_type/user_test.rb +24 -0
  98. data/test/test_helper.rb +19 -0
  99. metadata +293 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1 @@
1
+ http://www.archive.org/download/testmp3testfile/mpthreetest.mp3
Binary file
Binary file
Binary file
@@ -0,0 +1,63 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe Asset do
5
+ let(:asset) { Asset.new }
6
+
7
+ it { asset.wont_be :valid? }
8
+ it { asset.kind.must_equal nil }
9
+ it { asset.description_or_file_name.must_equal nil }
10
+ it { asset.preview_thumb_url.must_equal nil }
11
+
12
+ it 'should be valid with required attributes' do
13
+ asset.attributes = FactoryGirl.attributes_for :asset
14
+ asset.must_be :valid?
15
+ end
16
+
17
+ describe '#kind' do
18
+ let(:image) { FactoryGirl.create :image_asset }
19
+ let(:audio) { FactoryGirl.create :audio_asset }
20
+ let(:video) { FactoryGirl.create :video_asset }
21
+ let(:doc) { FactoryGirl.create :document_asset }
22
+ it { image.kind.must_equal :image }
23
+ it { image.must_be :image? }
24
+ it { image.wont_be :audio? }
25
+ it { image.wont_be :video? }
26
+ it { audio.kind.must_equal :audio }
27
+ it { audio.wont_be :image? }
28
+ it { audio.must_be :audio? }
29
+ it { audio.wont_be :video? }
30
+ it { video.kind.must_equal :video }
31
+ it { video.wont_be :image? }
32
+ it { video.wont_be :audio? }
33
+ it { video.must_be :video? }
34
+ it { doc.kind.must_equal :document }
35
+ it { doc.wont_be :image? }
36
+ it { doc.wont_be :audio? }
37
+ it { doc.wont_be :video? }
38
+ end
39
+
40
+ describe '#description_or_file_name' do
41
+ let(:asset) { FactoryGirl.create :asset }
42
+ it { asset.description_or_file_name.must_equal 'image.png' }
43
+ it 'should return description when present' do
44
+ asset.description = 'Foo bar'
45
+ asset.description_or_file_name.must_equal 'Foo bar'
46
+ end
47
+ end
48
+
49
+ describe '#preview_thumb_url' do
50
+ let(:image) { FactoryGirl.create :image_asset }
51
+ let(:doc) { FactoryGirl.create :document_asset }
52
+ it { image.preview_thumb_url.must_match %r{^/media/.*/image.png} }
53
+ it { doc.preview_thumb_url.must_equal 'push_type/icon-file-document.png' }
54
+ end
55
+
56
+ describe '#set_mime_type' do
57
+ let(:asset) { FactoryGirl.create :asset }
58
+ it { asset.file_ext.must_equal 'png' }
59
+ it { asset.mime_type.must_equal 'image/png' }
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,87 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe Node do
5
+ let(:node) { Node.new }
6
+
7
+ it { node.wont_be :valid? }
8
+
9
+ it 'should be valid with required attributes' do
10
+ node.attributes = FactoryGirl.attributes_for :node
11
+ node.must_be :valid?
12
+ end
13
+
14
+ describe '.published' do
15
+ let(:nodes) { PushType::Node.published }
16
+ let(:new_node!) { FactoryGirl.create :published_node, attributes }
17
+ before { @count = nodes.count }
18
+ describe 'without published status' do
19
+ it { proc { FactoryGirl.create :node }.wont_change 'nodes.count' }
20
+ end
21
+ describe 'with published_at dates in the future' do
22
+ let(:attributes) { { published_at: 1.day.from_now } }
23
+ it { proc { new_node! }.wont_change 'nodes.count' }
24
+ end
25
+ describe 'with published_at dates in the past' do
26
+ let(:attributes) { { published_at: 2.days.ago } }
27
+ it { proc { new_node! }.must_change 'nodes.count', 1 }
28
+ end
29
+ describe 'with published_to dates in the future' do
30
+ let(:attributes) { { published_at: 2.days.ago, published_to: 1.day.from_now } }
31
+ it { proc { new_node! }.must_change 'nodes.count', 1 }
32
+ end
33
+ describe 'with published_to dates in the past' do
34
+ let(:attributes) { { published_at: 2.days.ago, published_to: 1.day.ago } }
35
+ it { proc { new_node! }.wont_change 'nodes.count' }
36
+ end
37
+ end
38
+
39
+ describe '#status' do
40
+ let(:draft) { FactoryGirl.create :node }
41
+ let(:published) { FactoryGirl.create :published_node }
42
+ let(:scheduled) { FactoryGirl.create :published_node, published_at: 1.day.from_now }
43
+ let(:expired) { FactoryGirl.create :published_node, published_at: 2.days.ago, published_to: 1.day.ago }
44
+ it { draft.must_be :draft? }
45
+ it { draft.wont_be :published? }
46
+ it { draft.wont_be :scheduled? }
47
+ it { draft.wont_be :expired? }
48
+ it { published.wont_be :draft? }
49
+ it { published.must_be :published? }
50
+ it { published.wont_be :scheduled? }
51
+ it { published.wont_be :expired? }
52
+ it { scheduled.wont_be :draft? }
53
+ it { scheduled.wont_be :published? }
54
+ it { scheduled.must_be :scheduled? }
55
+ it { scheduled.wont_be :expired? }
56
+ it { expired.wont_be :draft? }
57
+ it { expired.wont_be :published? }
58
+ it { expired.wont_be :scheduled? }
59
+ it { expired.must_be :expired? }
60
+ end
61
+
62
+ describe '#permalink' do
63
+ before do
64
+ %w(one two three).each { |slug| @node = FactoryGirl.create :node, slug: slug, parent: @node }
65
+ end
66
+ it { @node.permalink.must_equal 'one/two/three' }
67
+ end
68
+
69
+ describe '#default_values' do
70
+ it { node.status.must_equal 'draft' }
71
+ end
72
+
73
+ describe '#set_published_at' do
74
+ describe 'when publishing' do
75
+ let(:node) { FactoryGirl.create :node }
76
+ before { node.update_attribute :status, Node.statuses[:published] }
77
+ it { node.published_at.wont_be_nil }
78
+ end
79
+ describe 'when publishing' do
80
+ let(:node) { FactoryGirl.create :published_node }
81
+ before { node.update_attribute :status, Node.statuses[:draft] }
82
+ it { node.published_at.must_be_nil }
83
+ end
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ module PushType
4
+ describe User do
5
+ let(:user) { User.new }
6
+
7
+ it { user.wont_be :valid? }
8
+
9
+ it 'should be valid with required attributes' do
10
+ user.attributes = FactoryGirl.attributes_for :user
11
+ user.must_be :valid?
12
+ end
13
+
14
+ describe '#initials' do
15
+ let(:user_one) { User.new name: 'Joe' }
16
+ let(:user_two) { User.new name: 'Joe Bloggs' }
17
+ let(:user_three) { User.new name: 'Joe Smithe Henley-Bloggs' }
18
+ it { user_one.initials.must_equal 'J' }
19
+ it { user_two.initials.must_equal 'JB' }
20
+ it { user_three.initials.must_equal 'JH' }
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
3
+ require "rails/test_help"
4
+ require "minitest/rails"
5
+
6
+ # To add Capybara feature tests add `gem "minitest-rails-capybara"`
7
+ # to the test group in the Gemfile and uncomment the following:
8
+ # require "minitest/rails/capybara"
9
+
10
+ # Uncomment for awesome colorful output
11
+ require 'minitest/pride'
12
+
13
+ # Require PushType testing setup
14
+ require 'push_type/testing/setup'
15
+ require 'push_type/testing/factories'
16
+
17
+ # Load support files
18
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
19
+