pushcart 0.0.1.proto1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +7 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/javascripts/pushcart/application.js +13 -0
  6. data/app/assets/stylesheets/pushcart/application.css +15 -0
  7. data/app/controllers/concerns/pushcart/getable.rb +127 -0
  8. data/app/controllers/concerns/pushcart/postable.rb +113 -0
  9. data/app/controllers/pushcart/application_controller.rb +4 -0
  10. data/app/controllers/pushcart/pub_sub/base_controller.rb +4 -0
  11. data/app/controllers/pushcart/pub_sub/subscriptions_controller.rb +8 -0
  12. data/app/helpers/pushcart/application_helper.rb +4 -0
  13. data/app/jobs/pushcart/subscription_renewal_job.rb +9 -0
  14. data/app/views/layouts/pushcart/application.html.erb +14 -0
  15. data/config/routes.rb +6 -0
  16. data/lib/pushcart.rb +16 -0
  17. data/lib/pushcart/composable.rb +10 -0
  18. data/lib/pushcart/connectable.rb +34 -0
  19. data/lib/pushcart/deliverable.rb +5 -0
  20. data/lib/pushcart/engine.rb +5 -0
  21. data/lib/pushcart/errors.rb +4 -0
  22. data/lib/pushcart/requestable.rb +68 -0
  23. data/lib/pushcart/stateable.rb +166 -0
  24. data/lib/pushcart/subscribable.rb +25 -0
  25. data/lib/pushcart/version.rb +3 -0
  26. data/lib/tasks/pushcart_tasks.rake +4 -0
  27. data/test/connectable_test.rb +24 -0
  28. data/test/dummy/README.rdoc +28 -0
  29. data/test/dummy/Rakefile +6 -0
  30. data/test/dummy/app/assets/javascripts/application.js +13 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  32. data/test/dummy/app/controllers/application_controller.rb +5 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/models/subscription.rb +9 -0
  35. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  36. data/test/dummy/bin/bundle +3 -0
  37. data/test/dummy/bin/rails +4 -0
  38. data/test/dummy/bin/rake +4 -0
  39. data/test/dummy/bin/setup +29 -0
  40. data/test/dummy/config.ru +4 -0
  41. data/test/dummy/config/application.rb +26 -0
  42. data/test/dummy/config/boot.rb +5 -0
  43. data/test/dummy/config/database.yml +25 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +41 -0
  46. data/test/dummy/config/environments/production.rb +79 -0
  47. data/test/dummy/config/environments/test.rb +42 -0
  48. data/test/dummy/config/initializers/assets.rb +11 -0
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  51. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/test/dummy/config/initializers/inflections.rb +16 -0
  53. data/test/dummy/config/initializers/mime_types.rb +4 -0
  54. data/test/dummy/config/initializers/session_store.rb +3 -0
  55. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/test/dummy/config/locales/en.yml +23 -0
  57. data/test/dummy/config/routes.rb +4 -0
  58. data/test/dummy/config/secrets.yml +22 -0
  59. data/test/dummy/db/migrate/20151016222203_create_subscriptions.rb +59 -0
  60. data/test/dummy/db/schema.rb +51 -0
  61. data/test/dummy/db/test.sqlite3 +0 -0
  62. data/test/dummy/log/development.log +0 -0
  63. data/test/dummy/log/test.log +5270 -0
  64. data/test/dummy/public/404.html +67 -0
  65. data/test/dummy/public/422.html +67 -0
  66. data/test/dummy/public/500.html +66 -0
  67. data/test/dummy/public/favicon.ico +0 -0
  68. data/test/fixtures/subscriptions.yml +6 -0
  69. data/test/integration/content_delivery_test.rb +58 -0
  70. data/test/integration/hub_request_test.rb +127 -0
  71. data/test/pushcart_test.rb +7 -0
  72. data/test/requestable_test.rb +7 -0
  73. data/test/routes_test.rb +9 -0
  74. data/test/state_test.rb +13 -0
  75. data/test/test_helper.rb +27 -0
  76. metadata +349 -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,6 @@
1
+ example:
2
+ id: 1
3
+ hub: http://hub.example.com
4
+ topic: http://www.example.com/rss.xml
5
+ topic_content_type: application/rss
6
+ hmac_secret_key: secret
@@ -0,0 +1,58 @@
1
+ # require "test_helper"
2
+ #
3
+ # class ContentDeliveryTest < ActionDispatch::IntegrationTest
4
+ # fixtures :subscriptions
5
+ #
6
+ # test "expects 404 when subscription doesn't exist" do
7
+ # headers = {}
8
+ # post "/pushcart/subscriptions/1/callback", {}, headers
9
+ # assert_response 404
10
+ # end
11
+ #
12
+ # test "expects 400 with unexpected delivery" do
13
+ # example = subscriptions(:example)
14
+ #
15
+ # headers = {}
16
+ # post "/pushcart/subscriptions/1/callback", {}, headers
17
+ # assert_response 400
18
+ # end
19
+ #
20
+ # test "expects 400 with incorrect Content-Type" do
21
+ # headers = {}
22
+ # post "/pushcart/subscriptions/1/callback", {}, headers
23
+ # assert_response 400
24
+ # end
25
+ #
26
+ # test "expects 400 when missing Link header" do
27
+ # headers = {}
28
+ # post "/pushcart/subscriptions/1/callback", {}, headers
29
+ # assert_response 400
30
+ # end
31
+ #
32
+ # test "expects 403 when missing X-Hub-Signature" do
33
+ # headers = {}
34
+ # post "/pushcart/subscriptions/1/callback", {}, headers
35
+ # assert_response 403
36
+ # end
37
+ #
38
+ # test "expects 202 when X-Hub-Signature is invalid" do
39
+ # headers = {}
40
+ # post "/pushcart/subscriptions/1/callback", {}, headers
41
+ # assert_response 202
42
+ # end
43
+ #
44
+ # test "expects 200 when delivery is successful" do
45
+ # headers = {
46
+ # "X-Hub-Signature" => "secret",
47
+ # "Link" => '<http://hub.example.com>; rel="hub", <http://www.example.com/rss.xml>; rel="self"',
48
+ # "Content-Type" => "application/rss"
49
+ # }
50
+ # post "/pushcart/subscriptions/1/callback", "<rss></rss>", headers
51
+ # assert_response 200
52
+ # end
53
+ #
54
+ # test "delivered content gets processed" do
55
+ # post "/pushcart/subscriptions/1/callback", "<rss></rss>", headers
56
+ # assert_response 200
57
+ # end
58
+ # end
@@ -0,0 +1,127 @@
1
+ # require "test_helper"
2
+ #
3
+ # class HubRequestTest < ActionDispatch::IntegrationTest
4
+ # test "expects 404 when subscription doesn't exist" do
5
+ # headers = {}
6
+ # get "/pushcart/subscriptions/1/callback", {}, headers
7
+ # assert_response 404
8
+ # end
9
+ #
10
+ # test "expects 404 with unexpected subscribe callback" do
11
+ # headers = {}
12
+ # get "/pushcart/subscriptions/1/callback", {}, headers
13
+ # assert_response 404
14
+ # end
15
+ #
16
+ # test "expects 404 with unexpected unsubscribe callback" do
17
+ # headers = {}
18
+ # get "/pushcart/subscriptions/1/callback", {}, headers
19
+ # assert_response 404
20
+ # end
21
+ #
22
+ # test "expects 404 when subscription has been terminated" do
23
+ # headers = {}
24
+ # get "/pushcart/subscriptions/1/callback", {}, headers
25
+ # assert_response 404
26
+ # end
27
+ #
28
+ # test "expects 404 when missing hub.topic" do
29
+ # headers = {}
30
+ # get "/pushcart/subscriptions/1/callback", {}, headers
31
+ # assert_response 404
32
+ # end
33
+ #
34
+ # test "expects 404 when hub.topic doesn't match" do
35
+ # headers = {}
36
+ # get "/pushcart/subscriptions/1/callback", {}, headers
37
+ # assert_response 404
38
+ # end
39
+ #
40
+ # test "expects 404 when subscribe is missing challenge" do
41
+ # headers = {}
42
+ # get "/pushcart/subscriptions/1/callback", {}, headers
43
+ # assert_response 404
44
+ # end
45
+ #
46
+ # test "expects 404 when subscribe is missing lease" do
47
+ # headers = {}
48
+ # get "/pushcart/subscriptions/1/callback", {}, headers
49
+ # assert_response 404
50
+ # end
51
+ #
52
+ # test "expects 404 when unsubscribe is missing challenge" do
53
+ # headers = {}
54
+ # get "/pushcart/subscriptions/1/callback", {}, headers
55
+ # assert_response 404
56
+ # end
57
+ #
58
+ # test "expects 200 when rejected during request" do
59
+ # headers = {}
60
+ # get "/pushcart/subscriptions/1/callback", {}, headers
61
+ # assert_response 200
62
+ # end
63
+ #
64
+ # test "subscription transitions to rejected when rejected during request" do
65
+ # assert false
66
+ # end
67
+ #
68
+ # test "expects 200 when denied during request" do
69
+ # headers = {}
70
+ # get "/pushcart/subscriptions/1/callback", {}, headers
71
+ # assert_response 200
72
+ # end
73
+ #
74
+ # test "subscription transitions to denied when denied during request" do
75
+ # assert false
76
+ # end
77
+ #
78
+ # test "expects 200 when denied after verification" do
79
+ # headers = {}
80
+ # get "/pushcart/subscriptions/1/callback", {}, headers
81
+ # assert_response 200
82
+ # end
83
+ #
84
+ # test "subscription transitions to denied when denied after verification" do
85
+ # assert false
86
+ # end
87
+ #
88
+ # test "expects 200 when verifying subscription after request" do
89
+ # headers = {}
90
+ # get "/pushcart/subscriptions/1/callback", {}, headers
91
+ # assert_response 200
92
+ # end
93
+ #
94
+ # test "subscription transitions to verified when verified after request" do
95
+ # assert false
96
+ # end
97
+ #
98
+ # test "expects 200 when verifying subscription after received" do
99
+ # headers = {}
100
+ # get "/pushcart/subscriptions/1/callback", {}, headers
101
+ # assert_response 200
102
+ # end
103
+ #
104
+ # test "subscription transitions to verified when verified after received" do
105
+ # assert false
106
+ # end
107
+ #
108
+ # test "expects 200 when verifying unsubscription after request" do
109
+ # headers = {}
110
+ # get "/pushcart/subscriptions/1/callback", {}, headers
111
+ # assert_response 200
112
+ # end
113
+ #
114
+ # test "subscription transitions to unsubscribed when verified after request" do
115
+ # assert false
116
+ # end
117
+ #
118
+ # test "expects 200 when verifying unsubscription after received" do
119
+ # headers = {}
120
+ # get "/pushcart/subscriptions/1/callback", {}, headers
121
+ # assert_response 200
122
+ # end
123
+ #
124
+ # test "subscription transitions to unsubscribed when verified after received" do
125
+ # assert false
126
+ # end
127
+ # end
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class PushcartTest < ActiveSupport::TestCase
4
+ # test "truth" do
5
+ # assert_kind_of Module, Pushcart
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class RequestableTest < ActiveSupport::TestCase
4
+ test "" do
5
+
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # class RoutesTest < ActionController::TestCase
2
+ # test "should route to callback" do
3
+ # assert_routing({ method: "get", path: "/pushcart/subscriptions/1/callback" }, { controller: "subscriptions", action: "get" })
4
+ # end
5
+ #
6
+ # test "should route to content delivery endpoint" do
7
+ # assert_routing({ method: "post", path: "/pushcart/subscriptions/1/callback" }, { controller: "subscriptions", action: "post" })
8
+ # end
9
+ # end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class StateTest < ActiveSupport::TestCase
4
+ fixtures :subscriptions
5
+
6
+ def setup
7
+ @subscription = subscriptions(:example)
8
+ end
9
+
10
+ test "undiscovered by default" do
11
+ assert @subscription.undiscovered?
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require "coveralls"
2
+ Coveralls.wear!
3
+
4
+ require "dotenv"
5
+ Dotenv.load
6
+
7
+ # Configure Rails Environment
8
+ ENV["RAILS_ENV"] = "test"
9
+
10
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
11
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
12
+ ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
13
+ require "rails/test_help"
14
+
15
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
16
+ # to be shown.
17
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
18
+
19
+ # Load support files
20
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
+
22
+ # Load fixtures from the engine
23
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
24
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
25
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
26
+ ActiveSupport::TestCase.fixtures :all
27
+ end