facebook_canvas 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c278e17a6a9b0caaf1a539d49cc76a2418c1ca9f
4
- data.tar.gz: afbe9ad9c14de80050adde0d20d3ea13080f7218
3
+ metadata.gz: 47c574bf93fbef64c7b67edaec3d3ba9cb89d479
4
+ data.tar.gz: bc29c32d280ef4fb2161460e6b6bc364f30ad61a
5
5
  SHA512:
6
- metadata.gz: 0dd7f08012de7e5a0c826c42e9097f41fe049c50f4e020e36163a3808ac3dcce4f658b99752a086b8313794c5593ce686d15ad7c86d49cd7833290cc21e4cb37
7
- data.tar.gz: 39c8b286dfa204078209dbfbf0a14e96c4520b3871333f88fbc2fd4dabede4026dba9cae0a8bfe912b779d7b8d1906b1d7e5b35878c4d68d9a2da972e4d5ce42
6
+ metadata.gz: 499515ff1f83003d1fed1e2b477729f3eb8dfba217b86a9f7054646b0f4e3b0b779188fc093ea93d513f399c619bf098986dc0322ac0ec09adf3162fe321bbe9
7
+ data.tar.gz: 0b0100d50c70431695695fa33e2b33e0d73c5fbd81e740029d8c06a63b652705758bd60c01a339a0e9c5bfb310c244fb44ba1a26a6e3b5aab673b8a50e249e0f
@@ -1,7 +1,7 @@
1
1
  module FacebookCanvas
2
2
  class Engine < ::Rails::Engine
3
3
  initializer "FacebookCanvas.middleware" do |app|
4
- server_name = FacebookCanvas.server_name || /\.fb\./
4
+ server_name = FacebookCanvas.server_name || /.*/
5
5
  app.config.middleware.use FacebookCanvas::Middleware, server_name
6
6
 
7
7
  ApplicationController.prepend FacebookCanvas::Helpers
@@ -1,17 +1,12 @@
1
- # This Middleware should be inserted after Rack::MethodOverride
2
- #
3
- # config/application.rb
4
- #
5
- # module FacebookCanvas
6
- # class Engine < ::Rails::Engine
7
- # ...
8
- # initializer "FacebookCanvas.middleware" do |app|
9
- # app.config.middleware.use FacebookCanvas::Middleware, /\.fb\./
10
- # end
11
- # ...
12
- # end
13
- # end
1
+ # This middleware modifies the `REQUEST_METHOD` if needed and should be inserted
2
+ # after the middleware `Rack::MethodOverride`
14
3
  #
4
+ # All requests coming from Facebook to our canvas are POST requests.
5
+ # We need to check whether the request was originally a GET request.
6
+ # We assume that Rails inserts a hidden parameter called `utf8` for all non
7
+ # GET requests.
8
+ # So if this parameter is missing, the request is a `GET` request and therefor
9
+ # we force the `REQUEST_METHOD` to GET.
15
10
  module FacebookCanvas
16
11
  class Middleware
17
12
  def initialize(app, request_host)
@@ -19,12 +14,7 @@ module FacebookCanvas
19
14
  @request_host = request_host
20
15
  end
21
16
 
22
- # All requests coming from facebook to our canvas are POST requests.
23
- # We need to check wether the request was originally a GET request.
24
- # We assume that rails inserts a hidden parameter with UTF8 for all non
25
- # GET requests.
26
- # So if this parameter is missing, the request is a GET request and there for
27
- # we set the REQUEST_METHOD to GET.
17
+ # Forces REQUEST_METHOD to GET if required.
28
18
  def call(env)
29
19
  if matches_server_name?(env) && was_get_request?(env)
30
20
  env["REQUEST_METHOD"] = "GET"
@@ -1,3 +1,3 @@
1
1
  module FacebookCanvas
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -10,7 +10,7 @@ require "facebook_canvas"
10
10
 
11
11
  module Dummy
12
12
  class Application < Rails::Application
13
- FacebookCanvas.server_name = /./
13
+ FacebookCanvas.server_name = /.*/
14
14
  end
15
15
  end
16
16
 
@@ -0,0 +1,132 @@
1
+ ------------------------------
2
+ FacebookCanvasTest: test_truth
3
+ ------------------------------
4
+ ----------------------------------------------------------------------
5
+ FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
6
+ ----------------------------------------------------------------------
7
+ ----------------------------------------------------------------------------
8
+ FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
9
+ ----------------------------------------------------------------------------
10
+ -----------------------------------------------------------------------
11
+ FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
12
+ -----------------------------------------------------------------------
13
+ --------------------------------------------------
14
+ FacebookCanvas::SignedRequestTest: test_initialize
15
+ --------------------------------------------------
16
+ ---------------------------------------------------------------------------
17
+ FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
18
+ ---------------------------------------------------------------------------
19
+ --------------------------------------------------------
20
+ FacebookCanvas::MiddlewareTest: test_do_not_convert_post
21
+ --------------------------------------------------------
22
+ Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:27:12 +0100
23
+ Processing by FooController#create as HTML
24
+ Parameters: {"utf8"=>"utf"}
25
+ Rendered text template (0.0ms)
26
+ Completed 200 OK in 3ms (Views: 2.8ms)
27
+ ----------------------------------------------------------------
28
+ FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
29
+ ----------------------------------------------------------------
30
+ Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:27:12 +0100
31
+ Processing by FooController#index as HTML
32
+ Rendered text template (0.0ms)
33
+ Completed 200 OK in 0ms (Views: 0.2ms)
34
+ ------------------------------
35
+ FacebookCanvasTest: test_truth
36
+ ------------------------------
37
+ -----------------------------------------------------------------------
38
+ FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
39
+ -----------------------------------------------------------------------
40
+ ----------------------------------------------------------------------
41
+ FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
42
+ ----------------------------------------------------------------------
43
+ --------------------------------------------------
44
+ FacebookCanvas::SignedRequestTest: test_initialize
45
+ --------------------------------------------------
46
+ ---------------------------------------------------------------------------
47
+ FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
48
+ ---------------------------------------------------------------------------
49
+ ----------------------------------------------------------------------------
50
+ FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
51
+ ----------------------------------------------------------------------------
52
+ --------------------------------------------------------
53
+ FacebookCanvas::MiddlewareTest: test_do_not_convert_post
54
+ --------------------------------------------------------
55
+ Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:27:16 +0100
56
+ Processing by FooController#create as HTML
57
+ Parameters: {"utf8"=>"utf"}
58
+ Rendered text template (0.0ms)
59
+ Completed 200 OK in 2ms (Views: 2.2ms)
60
+ ----------------------------------------------------------------
61
+ FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
62
+ ----------------------------------------------------------------
63
+ Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:27:16 +0100
64
+ Processing by FooController#index as HTML
65
+ Rendered text template (0.0ms)
66
+ Completed 200 OK in 0ms (Views: 0.1ms)
67
+ ------------------------------
68
+ FacebookCanvasTest: test_truth
69
+ ------------------------------
70
+ ----------------------------------------------------------------
71
+ FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
72
+ ----------------------------------------------------------------
73
+ Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:47:21 +0100
74
+ Processing by FooController#index as HTML
75
+ Rendered text template (0.0ms)
76
+ Completed 200 OK in 2ms (Views: 2.2ms)
77
+ --------------------------------------------------------
78
+ FacebookCanvas::MiddlewareTest: test_do_not_convert_post
79
+ --------------------------------------------------------
80
+ Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:47:21 +0100
81
+ Processing by FooController#create as HTML
82
+ Parameters: {"utf8"=>"utf"}
83
+ Rendered text template (0.0ms)
84
+ Completed 200 OK in 0ms (Views: 0.1ms)
85
+ --------------------------------------------------
86
+ FacebookCanvas::SignedRequestTest: test_initialize
87
+ --------------------------------------------------
88
+ ----------------------------------------------------------------------------
89
+ FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
90
+ ----------------------------------------------------------------------------
91
+ ---------------------------------------------------------------------------
92
+ FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
93
+ ---------------------------------------------------------------------------
94
+ -----------------------------------------------------------------------
95
+ FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
96
+ -----------------------------------------------------------------------
97
+ ----------------------------------------------------------------------
98
+ FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
99
+ ----------------------------------------------------------------------
100
+ ------------------------------
101
+ FacebookCanvasTest: test_truth
102
+ ------------------------------
103
+ --------------------------------------------------
104
+ FacebookCanvas::SignedRequestTest: test_initialize
105
+ --------------------------------------------------
106
+ -----------------------------------------------------------------------
107
+ FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
108
+ -----------------------------------------------------------------------
109
+ ----------------------------------------------------------------------
110
+ FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
111
+ ----------------------------------------------------------------------
112
+ ----------------------------------------------------------------------------
113
+ FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
114
+ ----------------------------------------------------------------------------
115
+ ---------------------------------------------------------------------------
116
+ FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
117
+ ---------------------------------------------------------------------------
118
+ ----------------------------------------------------------------
119
+ FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
120
+ ----------------------------------------------------------------
121
+ Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:48:01 +0100
122
+ Processing by FooController#index as HTML
123
+ Rendered text template (0.0ms)
124
+ Completed 200 OK in 2ms (Views: 2.1ms)
125
+ --------------------------------------------------------
126
+ FacebookCanvas::MiddlewareTest: test_do_not_convert_post
127
+ --------------------------------------------------------
128
+ Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:48:01 +0100
129
+ Processing by FooController#create as HTML
130
+ Parameters: {"utf8"=>"utf"}
131
+ Rendered text template (0.0ms)
132
+ Completed 200 OK in 0ms (Views: 0.1ms)
data/test/test_helper.rb CHANGED
@@ -1,3 +1,8 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
1
6
  # Configure Rails Environment
2
7
  ENV["RAILS_ENV"] = "test"
3
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Stuhrmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - test/dummy/config/locales/en.yml
88
88
  - test/dummy/config/routes.rb
89
89
  - test/dummy/config/secrets.yml
90
+ - test/dummy/log/test.log
90
91
  - test/dummy/public/404.html
91
92
  - test/dummy/public/422.html
92
93
  - test/dummy/public/500.html
@@ -96,7 +97,6 @@ files:
96
97
  - test/fixtures/signed_request.txt
97
98
  - test/fixtures/signed_request_with_user_id.txt
98
99
  - test/integration/middleware_test.rb
99
- - test/integration/navigation_test.rb
100
100
  - test/test_helper.rb
101
101
  homepage:
102
102
  licenses:
@@ -118,51 +118,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.4.6
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Rails engine for Facebook's canvas integration.
125
125
  test_files:
126
126
  - test/facebook_canvas/signed_request_test.rb
127
- - test/integration/navigation_test.rb
128
- - test/integration/middleware_test.rb
127
+ - test/facebook_canvas_test.rb
128
+ - test/dummy/README.rdoc
129
+ - test/dummy/app/assets/stylesheets/application.css
130
+ - test/dummy/app/assets/javascripts/application.js
131
+ - test/dummy/app/controllers/foo_controller.rb
132
+ - test/dummy/app/controllers/application_controller.rb
133
+ - test/dummy/app/views/foo/create.haml
134
+ - test/dummy/app/views/layouts/application.html.erb
135
+ - test/dummy/app/helpers/application_helper.rb
129
136
  - test/dummy/config/application.rb
130
- - test/dummy/config/routes.rb
131
- - test/dummy/config/database.yml
137
+ - test/dummy/config/initializers/session_store.rb
138
+ - test/dummy/config/initializers/wrap_parameters.rb
139
+ - test/dummy/config/initializers/assets.rb
140
+ - test/dummy/config/initializers/filter_parameter_logging.rb
132
141
  - test/dummy/config/initializers/cookies_serializer.rb
142
+ - test/dummy/config/initializers/inflections.rb
133
143
  - test/dummy/config/initializers/backtrace_silencers.rb
134
144
  - test/dummy/config/initializers/mime_types.rb
135
- - test/dummy/config/initializers/assets.rb
136
- - test/dummy/config/initializers/wrap_parameters.rb
137
- - test/dummy/config/initializers/session_store.rb
138
- - test/dummy/config/initializers/inflections.rb
139
- - test/dummy/config/initializers/filter_parameter_logging.rb
140
- - test/dummy/config/environments/production.rb
141
- - test/dummy/config/environments/test.rb
142
- - test/dummy/config/environments/development.rb
143
145
  - test/dummy/config/locales/en.yml
146
+ - test/dummy/config/routes.rb
147
+ - test/dummy/config/environments/development.rb
148
+ - test/dummy/config/environments/test.rb
149
+ - test/dummy/config/environments/production.rb
144
150
  - test/dummy/config/environment.rb
151
+ - test/dummy/config/database.yml
145
152
  - test/dummy/config/boot.rb
146
153
  - test/dummy/config/secrets.yml
147
- - test/dummy/config.ru
148
- - test/dummy/bin/bundle
149
- - test/dummy/bin/rake
150
- - test/dummy/bin/rails
151
- - test/dummy/bin/setup
152
154
  - test/dummy/Rakefile
153
- - test/dummy/README.rdoc
154
- - test/dummy/app/assets/stylesheets/application.css
155
- - test/dummy/app/assets/javascripts/application.js
156
- - test/dummy/app/helpers/application_helper.rb
157
- - test/dummy/app/controllers/foo_controller.rb
158
- - test/dummy/app/controllers/application_controller.rb
159
- - test/dummy/app/views/foo/create.haml
160
- - test/dummy/app/views/layouts/application.html.erb
161
155
  - test/dummy/public/favicon.ico
156
+ - test/dummy/public/422.html
162
157
  - test/dummy/public/404.html
163
158
  - test/dummy/public/500.html
164
- - test/dummy/public/422.html
165
- - test/test_helper.rb
166
- - test/facebook_canvas_test.rb
167
- - test/fixtures/signed_request_with_user_id.txt
159
+ - test/dummy/log/test.log
160
+ - test/dummy/bin/setup
161
+ - test/dummy/bin/rake
162
+ - test/dummy/bin/rails
163
+ - test/dummy/bin/bundle
164
+ - test/dummy/config.ru
168
165
  - test/fixtures/signed_request.txt
166
+ - test/fixtures/signed_request_with_user_id.txt
167
+ - test/test_helper.rb
168
+ - test/integration/middleware_test.rb
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigationTest < ActionDispatch::IntegrationTest
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
8
-