problem_child 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: 06265cd34450ea0ffaf3f55043eb05838eba1830
4
- data.tar.gz: 93a4d479de486acff65c59087f2e0b844a838aef
3
+ metadata.gz: 9e83ecc3d971edca9afa09d88616214477ad6674
4
+ data.tar.gz: 2a7a552a65d5457ec6d2008e647226e18f7a050f
5
5
  SHA512:
6
- metadata.gz: afdc991714c0ff6d157132bdf7897915262dd983c648ea2dc51a69124dc22a4a6ada7b24e87ef0650f28f8153a0fd797da8cd770ca2b6fd8a9207e7c339ba72c
7
- data.tar.gz: b2d169245f679c9c529c7e4306a524af8cdc8a16d719c3a02181ccc7ea498abf4caa8de9c6bb6a76fd65e822bd67f5676197816dc983a2a7cb6372ca5408035d
6
+ metadata.gz: 17b494db5c8b46d04004377e62845dc8ba1cfffbeb004331acb9d1cf119a061d1bd4c8330bc798d5b4b4f122ebbd7bb053c691e94ed25ee6766936d4628abdbe
7
+ data.tar.gz: ebd5fecb4ed6e22c5522d678fdafc6ba5fd332849f8abdf7121ccc333d4364a9499aec40069c74ba5fbdf75f4e2906db7fb9775e9bcec9951765d12b92660187
data/.travis.yml CHANGED
@@ -6,7 +6,9 @@ rvm:
6
6
 
7
7
  sudo: false
8
8
  cache: bundler
9
-
9
+ services:
10
+ - memcached
11
+
10
12
  env:
11
13
  global:
12
14
  GITHUB_CLIENT_ID: "1234"
data/README.md CHANGED
@@ -20,6 +20,14 @@ Allows authenticated or anonymous users to fill out a standard web form to creat
20
20
  ```
21
21
  3. Follow the configuration options below
22
22
 
23
+ ## Requirements
24
+
25
+ You'll need to have [Memcache](http://memcached.org/) running.
26
+
27
+ On OS X, run `brew install memcached` to install, followed by `memcached` to run the memcache server.
28
+
29
+ On Heroku you'll want to run `heroku addons:add memcachier:dev` to add a free Memecache instance to your app.
30
+
23
31
  ## Configuring
24
32
 
25
33
  You must set the following as environmental variables:
@@ -0,0 +1,22 @@
1
+ module ProblemChild
2
+ class Memcache
3
+
4
+ def self.client
5
+ Dalli::Client.new(server, options)
6
+ end
7
+
8
+ def self.options
9
+ {
10
+ :username => ENV["MEMCACHIER_USERNAME"],
11
+ :password => ENV["MEMCACHIER_PASSWORD"],
12
+ :failover => true,
13
+ :socket_timeout => 1.5,
14
+ :socket_failure_delay => 0.2
15
+ }
16
+ end
17
+
18
+ def self.server
19
+ ENV["MEMCACHIER_SERVERS"].split(",") unless ENV["MEMCACHIER_SERVERS"].to_s.blank?
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module ProblemChild
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/problem_child.rb CHANGED
@@ -3,10 +3,13 @@ require 'sinatra'
3
3
  require 'sinatra_auth_github'
4
4
  require 'dotenv'
5
5
  require 'json'
6
+ require 'dalli'
7
+ require 'rack/session/dalli'
6
8
  require 'active_support'
7
9
  require 'active_support/core_ext/string'
8
10
  require "problem_child/version"
9
11
  require "problem_child/helpers"
12
+ require "problem_child/memcache"
10
13
 
11
14
  module ProblemChild
12
15
 
@@ -26,6 +29,10 @@ module ProblemChild
26
29
 
27
30
  include ProblemChild::Helpers
28
31
 
32
+ configure do
33
+ use Rack::Session::Dalli, cache: ProblemChild::Memcache.client
34
+ end
35
+
29
36
  set :github_options, {
30
37
  :scopes => "repo,read:org"
31
38
  }
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "sinatra_auth_github", "~> 1.0"
25
25
  spec.add_dependency "activesupport", "~> 4.2"
26
26
  spec.add_dependency "rack", "1.5.2"
27
+ spec.add_dependency "dalli", "~> 2.7"
27
28
 
28
29
  spec.add_development_dependency "rspec", "~> 3.1"
29
30
  spec.add_development_dependency "rack-test", "~> 0.6"
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe "ProblemChild::MemcacheHelper" do
4
+
5
+ it "knows the server" do
6
+ with_env "MEMCACHIER_SERVERS", "localhost:1234" do
7
+ expect(ProblemChild::Memcache.server).to eql(["localhost:1234"])
8
+ end
9
+ end
10
+
11
+ it "can process multiple servers" do
12
+ with_env "MEMCACHIER_SERVERS", "localhost:1234, localhost:4567" do
13
+ expect(ProblemChild::Memcache.server).to eql(["localhost:1234", " localhost:4567"])
14
+ end
15
+ end
16
+
17
+ it "pulls the username and password" do
18
+ with_env "MEMCACHIER_USERNAME", "user" do
19
+ with_env "MEMCACHIER_PASSWORD", "pass" do
20
+ expected = {
21
+ :username => "user",
22
+ :password => "pass",
23
+ :failover => true,
24
+ :socket_timeout => 1.5,
25
+ :socket_failure_delay => 0.2
26
+ }
27
+ expect(ProblemChild::Memcache.options).to eql(expected)
28
+ end
29
+ end
30
+ end
31
+
32
+ it "returns the client" do
33
+ expect(ProblemChild::Memcache.client.class).to eql(Dalli::Client)
34
+ end
35
+ end
@@ -107,9 +107,11 @@ describe "logged out user" do
107
107
 
108
108
  it "asks the user to log in" do
109
109
  with_env "GITHUB_ORG_ID", "balter-test-org" do
110
- get "/"
111
- expect(last_response.status).to eql(302)
112
- expect(last_response.headers['Location']).to match(%r{^https://github\.com/login/oauth/authorize})
110
+ with_env "GITHUB_TOKEN", nil do
111
+ get "/"
112
+ expect(last_response.status).to eql(302)
113
+ expect(last_response.headers['Location']).to match(%r{^https://github\.com/login/oauth/authorize})
114
+ end
113
115
  end
114
116
  end
115
117
 
@@ -137,4 +139,23 @@ describe "logged out user" do
137
139
  end
138
140
  end
139
141
  end
142
+
143
+ it "supports submissions > 4k" do
144
+ with_env "GITHUB_TOKEN", "1234" do
145
+ with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
146
+ long_string = "0" * 5000
147
+
148
+ stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
149
+ with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: #{long_string}\"}").
150
+ to_return(:status => 200)
151
+
152
+
153
+ post "/", :title => "title", :foo => long_string
154
+ follow_redirect!
155
+
156
+ expect(last_response.status).to eql(200)
157
+ expect(last_response.body).to match(/Your issue was successfully submitted/)
158
+ end
159
+ end
160
+ end
140
161
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,9 @@ RSpec.configure do |config|
15
15
  config.include(Sinatra::Auth::Github::Test::Helper)
16
16
  end
17
17
 
18
+ ENV["GITHUB_CLIENT_ID"] = "1234"
19
+ ENV["GITHUB_CLIENT_SECRET"] = "asdf"
20
+
18
21
  def with_env(key, value)
19
22
  old_env = ENV[key]
20
23
  ENV[key] = value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: problem_child
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
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.5.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: dalli
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.7'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.7'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +239,7 @@ files:
225
239
  - config.ru
226
240
  - lib/problem_child.rb
227
241
  - lib/problem_child/helpers.rb
242
+ - lib/problem_child/memcache.rb
228
243
  - lib/problem_child/public/vendor/bootstrap/.bower.json
229
244
  - lib/problem_child/public/vendor/bootstrap/Gruntfile.js
230
245
  - lib/problem_child/public/vendor/bootstrap/LICENSE
@@ -278,6 +293,7 @@ files:
278
293
  - script/release
279
294
  - script/server
280
295
  - spec/problem_child_helpers_spec.rb
296
+ - spec/problem_child_memcache_spec.rb
281
297
  - spec/problem_child_spec.rb
282
298
  - spec/spec_helper.rb
283
299
  homepage: https://github.com/benbalter/problem_child
@@ -307,5 +323,6 @@ summary: Allows authenticated or anonymous users to fill out a standard web form
307
323
  creat GitHub issues.
308
324
  test_files:
309
325
  - spec/problem_child_helpers_spec.rb
326
+ - spec/problem_child_memcache_spec.rb
310
327
  - spec/problem_child_spec.rb
311
328
  - spec/spec_helper.rb