problem_child 2.1.1 → 3.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23e61aafef42b2d8a22e1eb9cd300108f808d714
4
- data.tar.gz: 6dfde2eafb3c1ef44074c76aa94eafea6abfca5e
3
+ metadata.gz: 3ced371fbdeea3928bd926e3f1af3e9f472b18c5
4
+ data.tar.gz: 9b4d65b7429a1bbce244ba69b93ec9533e0bf761
5
5
  SHA512:
6
- metadata.gz: 628253249fe3d9b38f2cace36492c6c9b5752035fca94e98413617d4c811a8822dce803f11da8e7929161fbffdd8009a3a864a61f3d86901542f37370e1c7736
7
- data.tar.gz: fc1bbf214d479260fcfc852b935f9e1d9a25df0048f71eae79c7ed4384cd0bf939d7cbd6b8c014474abc4188a6560bc229d499fa207ca1bad1f756e0f76eac43
6
+ metadata.gz: 66c12bc11831546f120a1d7a4c315c4fdfddcc78d9e8cad3cfccf5b7e3e49a4b36663b59078037f385801c2eb1a21411b9355c0b2b47ae98eae9863ab3bc4545
7
+ data.tar.gz: eaad18bf0333c3e90c11b89576417b1851f3fe90f4f4d1b2cf0455e0ddeb5162ed4f66c4d55d8e9862bb58063e2c6f5785582900b6af94c4f2374197b51d7150
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Metrics/AbcSize:
8
+ Enabled: false
9
+
10
+ Metrics/MethodLength:
11
+ Enabled: false
data/README.md CHANGED
@@ -22,14 +22,6 @@ run ProblemChild::App
22
22
 
23
23
  Then, follow the configuration options below.
24
24
 
25
- ## Requirements
26
-
27
- If you have OAuth (e.g., non-anonymous submission), you'll need to have [Redis](http://redis.io/) running to properly maintain sessions and support submissions larger than 4k:
28
-
29
- On OS X, run `brew install redis` to install, followed by `redis-server` to run the redis server. The site should work fine, but for tests to pass, you'll want to add `REDIS_URL=redis://localhost:6379` to your `.env` file.
30
-
31
- On Heroku you'll want to run `heroku addons:create heroku-redis:hobby-dev` to add a free Redis instance to your app (Heroku will set `REDIS_URL` for you).
32
-
33
25
  ## Configuring
34
26
 
35
27
  First, you must set the following environmental variable:
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
- desc "Run specs"
4
+ desc 'Run specs'
5
5
  RSpec::Core::RakeTask.new do |t|
6
6
  t.pattern = 'spec/**/*_spec.rb'
7
- t.rspec_opts = ["--order", "rand", "--color"]
7
+ t.rspec_opts = ['--order', 'rand', '--color']
8
8
  end
data/config.ru CHANGED
@@ -1,3 +1,3 @@
1
- require "problem_child"
1
+ require 'problem_child'
2
2
 
3
3
  run ProblemChild::App
@@ -1,56 +1,55 @@
1
1
  module ProblemChild
2
2
  module Helpers
3
-
4
3
  def repo
5
- ENV["GITHUB_REPO"]
4
+ ENV['GITHUB_REPO']
6
5
  end
7
6
 
8
7
  def anonymous_submissions?
9
- !!(ENV["GITHUB_TOKEN"] && !ENV["GITHUB_TOKEN"].to_s.empty?)
8
+ !ENV['GITHUB_TOKEN'].to_s.empty?
10
9
  end
11
10
 
12
11
  def token
13
12
  if anonymous_submissions?
14
- ENV["GITHUB_TOKEN"]
13
+ ENV['GITHUB_TOKEN']
15
14
  elsif !github_user.nil?
16
15
  github_user.token
17
16
  end
18
17
  end
19
18
 
20
19
  def client
21
- @client ||= Octokit::Client.new :access_token => token
20
+ @client ||= Octokit::Client.new access_token: token
22
21
  end
23
22
 
24
- def render_template(template, locals={})
25
- halt erb template, :layout => :layout, :locals => locals.merge({ :template => template })
23
+ def render_template(template, locals = {})
24
+ halt erb template, layout: :layout, locals: locals.merge(template: template)
26
25
  end
27
26
 
28
27
  def issue_title
29
- form_data["title"]
28
+ form_data['title']
30
29
  end
31
30
 
32
31
  def issue_body
33
- form_data.reject { |key, value| key == "title" || value.empty? || key == "labels" || value.is_a?(Hash) }.map { |key,value| "* **#{key.humanize}**: #{value}"}.join("\n")
32
+ form_data.reject { |key, value| key == 'title' || value.empty? || key == 'labels' || value.is_a?(Hash) }.map { |key, value| "* **#{key.humanize}**: #{value}" }.join("\n")
34
33
  end
35
34
 
36
35
  # abstraction to allow cached form data to be used in place of default params
37
36
  def form_data
38
- session["form_data"].nil? ? params : JSON.parse(session["form_data"])
37
+ session['form_data'].nil? ? params : JSON.parse(session['form_data'])
39
38
  end
40
39
 
41
40
  def labels
42
- form_data["labels"].join(",") if form_data["labels"]
41
+ form_data['labels'].join(',') if form_data['labels']
43
42
  end
44
43
 
45
44
  def uploads
46
- form_data.select do |key, value|
47
- value.is_a?(Hash) && ( value.has_key?("filename") || value.has_key?(:filename) )
45
+ form_data.select do |_key, value|
46
+ value.is_a?(Hash) && value.key?(:tempfile) && value[:tempfile].is_a?(Tempfile)
48
47
  end
49
48
  end
50
49
 
51
50
  def create_issue
52
- issue = client.create_issue(repo, form_data["title"], issue_body, :labels => labels)
53
- issue["number"] if issue
51
+ issue = client.create_issue(repo, form_data['title'], issue_body, labels: labels)
52
+ issue['number'] if issue
54
53
  end
55
54
 
56
55
  # Returns array of Octokit branch objects
@@ -72,11 +71,11 @@ module ProblemChild
72
71
  # Starts with patch-1 and keeps going until it finds one not taken
73
72
  def patch_branch
74
73
  num = 1
75
- branch_name = form_data["title"].parameterize
74
+ branch_name = form_data['title'].parameterize
76
75
  return branch_name unless branch_exists?(branch_name)
77
76
  branch = "#{branch_name}-#{num}"
78
- while branch_exists?(branch) do
79
- num = num + 1
77
+ while branch_exists?(branch)
78
+ num += 1
80
79
  branch = "#{branch_name}-#{num}"
81
80
  end
82
81
  branch
@@ -95,32 +94,25 @@ module ProblemChild
95
94
  uploads.each do |key, upload|
96
95
  client.create_contents(
97
96
  repo,
98
- upload["filename"],
99
- "Create #{upload["filename"]}",
100
- session["file_#{key}"],
101
- :branch => branch
97
+ upload[:filename],
98
+ "Create #{upload[:filename]}",
99
+ branch: branch,
100
+ file: upload[:tempfile]
102
101
  )
103
102
  session["file_#{key}"] = nil
104
103
  end
105
104
  end
106
- pr = client.create_pull_request(repo, "master", branch, form_data["title"], issue_body, :labels => labels)
107
- pr["number"] if pr
105
+ pr = client.create_pull_request(repo, 'master', branch, form_data['title'], issue_body, labels: labels)
106
+ pr['number'] if pr
108
107
  end
109
108
 
110
109
  def repo_access?
111
110
  return true unless anonymous_submissions?
112
- !client.repository(repo)["private"]
111
+ !client.repository(repo)['private']
113
112
  rescue
114
113
  false
115
114
  end
116
115
 
117
- def cache_form_data
118
- uploads.each do |key, upload|
119
- session["file_#{key}"] = File.open(upload[:tempfile]).read
120
- end
121
- session[:form_data] = params.to_json
122
- end
123
-
124
116
  def auth!
125
117
  if anonymous_submissions?
126
118
  true
@@ -129,8 +121,7 @@ module ProblemChild
129
121
  elsif ENV['GITHUB_ORG_ID']
130
122
  github_organization_authenticate!(ENV['GITHUB_ORG_ID'])
131
123
  else
132
- raise "Must define GITHUB_TEAM_ID, GITHUB_ORG_ID, OR GITHUB_TOKEN"
133
- halt 401
124
+ raise 'Must define GITHUB_TEAM_ID, GITHUB_ORG_ID, OR GITHUB_TOKEN'
134
125
  end
135
126
  end
136
127
  end
@@ -1,3 +1,3 @@
1
1
  module ProblemChild
2
- VERSION = "2.1.1"
2
+ VERSION = '3.0.0'.freeze
3
3
  end
data/lib/problem_child.rb CHANGED
@@ -3,21 +3,18 @@ require 'sinatra'
3
3
  require 'sinatra_auth_github'
4
4
  require 'dotenv'
5
5
  require 'json'
6
- require 'redis'
7
- require 'rack/session/moneta'
8
6
  require 'active_support'
9
7
  require 'active_support/core_ext/string'
10
- require "problem_child/version"
11
- require "problem_child/helpers"
8
+ require 'problem_child/version'
9
+ require 'problem_child/helpers'
12
10
 
13
11
  module ProblemChild
14
-
15
12
  def self.root
16
- File.expand_path "./problem_child", File.dirname(__FILE__)
13
+ File.expand_path './problem_child', File.dirname(__FILE__)
17
14
  end
18
15
 
19
16
  def self.views_dir
20
- @views_dir ||= File.expand_path "views", ProblemChild.root
17
+ @views_dir ||= File.expand_path 'views', ProblemChild.root
21
18
  end
22
19
 
23
20
  def self.views_dir=(dir)
@@ -25,7 +22,7 @@ module ProblemChild
25
22
  end
26
23
 
27
24
  def self.public_dir
28
- @public_dir ||= File.expand_path "public", ProblemChild.root
25
+ @public_dir ||= File.expand_path 'public', ProblemChild.root
29
26
  end
30
27
 
31
28
  def self.public_dir=(dir)
@@ -33,18 +30,12 @@ module ProblemChild
33
30
  end
34
31
 
35
32
  class App < Sinatra::Base
36
-
37
33
  include ProblemChild::Helpers
38
34
 
39
- set :github_options, {
40
- :scopes => "repo,read:org"
41
- }
35
+ set :github_options, scopes: 'repo,read:org'
42
36
 
43
- if ENV["REDIS_URL"] && !ENV["REDIS_URL"].to_s.empty?
44
- use Rack::Session::Moneta, store: :Redis, url: ENV["REDIS_URL"]
45
- else
46
- use Rack::Session::Cookie
47
- end
37
+ use Rack::Session::Cookie, http_only: true,
38
+ secret: ENV['SESSION_SECRET'] || SecureRandom.hex
48
39
 
49
40
  configure :production do
50
41
  require 'rack-ssl-enforcer'
@@ -54,34 +45,32 @@ module ProblemChild
54
45
  ENV['WARDEN_GITHUB_VERIFIER_SECRET'] ||= SecureRandom.hex
55
46
  register Sinatra::Auth::Github
56
47
 
57
- set :views, Proc.new { ProblemChild.views_dir }
58
- set :root, Proc.new { ProblemChild.root }
59
- set :public_folder, Proc.new { ProblemChild.public_dir }
48
+ set :views, proc { ProblemChild.views_dir }
49
+ set :root, proc { ProblemChild.root }
50
+ set :public_folder, proc { ProblemChild.public_dir }
60
51
 
61
- get "/" do
52
+ get '/' do
62
53
  flash = nil
63
54
  issue = nil
64
55
  access = false
65
56
 
66
- if session[:form_data]
67
- if issue_title.empty?
68
- flash = 'Please enter a title.'
69
- else
70
- issue = uploads.empty? ? create_issue : create_pull_request
71
- session[:form_data] = nil
72
- access = repo_access?
73
- end
74
- else
75
- auth!
76
- end
57
+ auth!
77
58
 
78
- halt erb :form, :layout => :layout, :locals => { :repo => repo, :anonymous => anonymous_submissions?, :flash => flash, :issue => issue, :access => access }
59
+ halt erb :form, layout: :layout, locals: { repo: repo, anonymous: anonymous_submissions?, flash: flash, issue: issue, access: access }
79
60
  end
80
61
 
81
- post "/" do
82
- cache_form_data
62
+ post '/' do
83
63
  auth! unless anonymous_submissions?
84
- halt redirect "/"
64
+
65
+ if issue_title.empty?
66
+ flash = 'Please enter a title.'
67
+ else
68
+ issue = uploads.empty? ? create_issue : create_pull_request
69
+ session[:form_data] = nil
70
+ access = repo_access?
71
+ end
72
+
73
+ halt erb :form, layout: :layout, locals: { repo: repo, anonymous: anonymous_submissions?, flash: flash, issue: issue, access: access }
85
74
  end
86
75
  end
87
76
  end
@@ -4,34 +4,33 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'problem_child/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "problem_child"
7
+ spec.name = 'problem_child'
8
8
  spec.version = ProblemChild::VERSION
9
- spec.authors = ["Ben Balter"]
10
- spec.email = ["ben.balter@github.com"]
11
- spec.summary = "Allows authenticated or anonymous users to fill out a standard web form to creat GitHub issues."
12
- spec.homepage = "https://github.com/benbalter/problem_child"
13
- spec.license = "MIT"
9
+ spec.authors = ['Ben Balter']
10
+ spec.email = ['ben.balter@github.com']
11
+ spec.summary = 'Allows authenticated or anonymous users to fill out a standard web form to creat GitHub issues.'
12
+ spec.homepage = 'https://github.com/benbalter/problem_child'
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency "sinatra", "~> 1.4"
21
- spec.add_dependency "octokit", "~> 3.7"
22
- spec.add_dependency "dotenv", "~> 1.0"
23
- spec.add_dependency "rack-ssl-enforcer", "~> 0.2"
24
- spec.add_dependency "sinatra_auth_github", "~> 1.0"
25
- spec.add_dependency "activesupport", "~> 4.2"
26
- spec.add_dependency "rack", "1.6"
27
- spec.add_dependency "redis", "~> 3.2"
28
- spec.add_dependency "moneta", "~> 0.8"
20
+ spec.add_dependency 'sinatra', '~> 1.4'
21
+ spec.add_dependency 'octokit', '~> 3.7'
22
+ spec.add_dependency 'dotenv', '~> 1.0'
23
+ spec.add_dependency 'rack-ssl-enforcer', '~> 0.2'
24
+ spec.add_dependency 'sinatra_auth_github', '~> 1.0'
25
+ spec.add_dependency 'activesupport', '~> 4.2'
26
+ spec.add_dependency 'rack', '1.6'
29
27
 
30
- spec.add_development_dependency "rspec", "~> 3.1"
31
- spec.add_development_dependency "rack-test", "~> 0.6"
32
- spec.add_development_dependency "webmock", "~> 1.2 "
33
- spec.add_development_dependency "foreman", "~> 0.77"
34
- spec.add_development_dependency "bundler", "~> 1.6"
35
- spec.add_development_dependency "rake", "~> 10.4"
36
- spec.add_development_dependency "pry", "~> 0.10"
28
+ spec.add_development_dependency 'rspec', '~> 3.1'
29
+ spec.add_development_dependency 'rack-test', '~> 0.6'
30
+ spec.add_development_dependency 'webmock', '~> 1.2 '
31
+ spec.add_development_dependency 'foreman', '~> 0.77'
32
+ spec.add_development_dependency 'bundler', '~> 1.6'
33
+ spec.add_development_dependency 'rake', '~> 10.4'
34
+ spec.add_development_dependency 'pry', '~> 0.10'
35
+ spec.add_development_dependency 'rubocop', '~> 0.41'
37
36
  end
data/script/cibuild CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  set -e
4
4
  bundle exec rake spec
5
+ bundle exec rubocop -S -D
5
6
  bundle exec gem build problem_child.gemspec
@@ -1,98 +1,84 @@
1
- require "spec_helper"
2
-
3
- describe "ProblemChild::Helpers" do
1
+ require 'spec_helper'
4
2
 
3
+ describe 'ProblemChild::Helpers' do
5
4
  class TestHelper
6
5
  include ProblemChild::Helpers
7
6
 
8
7
  attr_accessor :session, :params
9
8
 
10
- def initialize(path=nil)
9
+ def initialize(path = nil)
11
10
  @path = path
12
11
  end
13
12
 
14
13
  def request
15
- Rack::Request.new("PATH_INFO" => @path)
14
+ Rack::Request.new('PATH_INFO' => @path)
16
15
  end
17
16
  end
18
17
 
19
18
  before(:each) do
20
- @helper = TestHelper.new
21
- @helper.session = {}
22
- @helper.params = {}
19
+ @helper = TestHelper.new
20
+ @helper.session = {}
21
+ @helper.params = {}
23
22
  end
24
23
 
25
- it "knows the github repo" do
26
- with_env "GITHUB_REPO", "foo/bar" do
27
- expect(@helper.repo).to eql("foo/bar")
24
+ it 'knows the github repo' do
25
+ with_env 'GITHUB_REPO', 'foo/bar' do
26
+ expect(@helper.repo).to eql('foo/bar')
28
27
  end
29
28
  end
30
29
 
31
- it "knows to allow anonymous submisssions when a token is passed" do
32
- with_env "GITHUB_TOKEN", "asdf" do
30
+ it 'knows to allow anonymous submisssions when a token is passed' do
31
+ with_env 'GITHUB_TOKEN', 'asdf' do
33
32
  expect(@helper.anonymous_submissions?).to be(true)
34
33
  end
35
34
 
36
- with_env "GITHUB_TOKEN", "" do
35
+ with_env 'GITHUB_TOKEN', '' do
37
36
  expect(@helper.anonymous_submissions?).to be(false)
38
37
  end
39
38
  end
40
39
 
41
- it "knows not to allow anonymous submisssions when no token is passed" do
42
- with_env "GITHUB_TOKEN", "" do
40
+ it 'knows not to allow anonymous submisssions when no token is passed' do
41
+ with_env 'GITHUB_TOKEN', '' do
43
42
  expect(@helper.anonymous_submissions?).to be(false)
44
43
  end
45
44
 
46
- with_env "GITHUB_TOKEN", nil do
45
+ with_env 'GITHUB_TOKEN', nil do
47
46
  expect(@helper.anonymous_submissions?).to be(false)
48
47
  end
49
48
  end
50
49
 
51
- it "uses a token if passed" do
52
- with_env "GITHUB_TOKEN", "asdf" do
53
- expect(@helper.token).to eql("asdf")
50
+ it 'uses a token if passed' do
51
+ with_env 'GITHUB_TOKEN', 'asdf' do
52
+ expect(@helper.token).to eql('asdf')
54
53
  end
55
54
  end
56
55
 
57
- it "inits the octokit client" do
58
- with_env "GITHUB_TOKEN", "asdf" do
56
+ it 'inits the octokit client' do
57
+ with_env 'GITHUB_TOKEN', 'asdf' do
59
58
  expect(@helper.client.class).to eql(Octokit::Client)
60
- expect(@helper.client.access_token).to eql("asdf")
59
+ expect(@helper.client.access_token).to eql('asdf')
61
60
  end
62
61
  end
63
62
 
64
- it "caches the form data" do
65
- @helper.params = {"title" => "title", "foo" => "bar"}
66
- @helper.cache_form_data
67
- expect(@helper.form_data["foo"]).to eql("bar")
68
- end
69
-
70
- it "grabs the form data from the session" do
71
- expected = {"title" => "title", "foo" => "bar"}
72
- @helper.session["form_data"] = expected.to_json
73
- expect(@helper.form_data).to eql(expected)
74
- end
75
-
76
- it "grabs the form data when posted" do
77
- expected = {"title" => "title", "foo" => "bar"}
63
+ it 'grabs the form data when posted' do
64
+ expected = { 'title' => 'title', 'foo' => 'bar' }
78
65
  @helper.params = expected
79
66
  expect(@helper.form_data).to eql(expected)
80
67
  end
81
68
 
82
- it "builds the issue body" do
83
- expected = {"title" => "title", "foo" => "bar"}
69
+ it 'builds the issue body' do
70
+ expected = { 'title' => 'title', 'foo' => 'bar' }
84
71
  @helper.params = expected
85
- expect(@helper.issue_body).to eql("* **Foo**: bar")
72
+ expect(@helper.issue_body).to eql('* **Foo**: bar')
86
73
  end
87
74
 
88
- it "submits the issue" do
89
- @helper.params = {"title" => "title", "foo" => "bar", "labels" => ["foo", "bar"]}
90
- with_env "GITHUB_TOKEN", "1234" do
91
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
92
-
93
- stub = stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
94
- with(:body => "{\"labels\":[\"foo\",\"bar\"],\"title\":\"title\",\"body\":\"* **Foo**: bar\"}").
95
- to_return(:status => 200, :body => '{"number": 1234}', :headers => { 'Content-Type' => 'application/json' })
75
+ it 'submits the issue' do
76
+ @helper.params = { 'title' => 'title', 'foo' => 'bar', 'labels' => %w(foo bar) }
77
+ with_env 'GITHUB_TOKEN', '1234' do
78
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
79
+ stub = stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/issues')
80
+ .with(body: '{"labels":["foo","bar"],"title":"title","body":"* **Foo**: bar"}')
81
+ .to_return(status: 200, body: '{"number": 1234}', headers: { 'Content-Type' => 'application/json' })
96
82
 
97
83
  expect(@helper.create_issue).to eql(1234)
98
84
  expect(stub).to have_been_requested
@@ -101,158 +87,165 @@ describe "ProblemChild::Helpers" do
101
87
  end
102
88
 
103
89
  it "knows auth'd users can access a repo" do
104
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
105
- to_return(:status => 200, :body => '{"private": true}', :headers => { 'Content-Type' => 'application/json' })
90
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
91
+ .to_return(status: 200, body: '{"private": true}', headers: { 'Content-Type' => 'application/json' })
106
92
 
107
- with_env "GITHUB_TOKEN", nil do
108
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
93
+ with_env 'GITHUB_TOKEN', nil do
94
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
109
95
  expect(@helper.repo_access?).to eql(true)
110
96
  end
111
97
  end
112
98
  end
113
99
 
114
- it "knows anonymous users can access public repos" do
115
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
116
- to_return(:status => 200, :body => '{"private": false}', :headers => { 'Content-Type' => 'application/json' })
100
+ it 'knows anonymous users can access public repos' do
101
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
102
+ .to_return(status: 200, body: '{"private": false}', headers: { 'Content-Type' => 'application/json' })
117
103
 
118
- with_env "GITHUB_TOKEN", "1234" do
119
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
104
+ with_env 'GITHUB_TOKEN', '1234' do
105
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
120
106
  expect(@helper.repo_access?).to eql(true)
121
107
  end
122
108
  end
123
109
  end
124
110
 
125
111
  it "knows anonymous users can't access private repos" do
126
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
127
- to_return(:status => 200, :body => '{"private": true}', :headers => { 'Content-Type' => 'application/json' })
112
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
113
+ .to_return(status: 200, body: '{"private": true}', headers: { 'Content-Type' => 'application/json' })
128
114
 
129
- with_env "GITHUB_TOKEN", "1234" do
130
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
115
+ with_env 'GITHUB_TOKEN', '1234' do
116
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
131
117
  expect(@helper.repo_access?).to eql(false)
132
118
  end
133
119
  end
134
120
  end
135
121
 
136
- it "knows the labels" do
137
- @helper.params["labels"] = ["foo", "bar"]
138
- expect(@helper.labels).to eql("foo,bar")
122
+ it 'knows the labels' do
123
+ @helper.params['labels'] = %w(foo bar)
124
+ expect(@helper.labels).to eql('foo,bar')
139
125
  end
140
126
 
141
- context "uploads" do
142
- it "can identify uploads" do
143
- @helper.params = {"title" => "title", "file" => { :filename => "foo.md"} }
144
- expect(@helper.uploads.first[0]).to eql("file")
127
+ context 'uploads' do
128
+ it 'can identify uploads' do
129
+ Tempfile.open do |tempfile|
130
+ tempfile.write("FOO\n")
131
+ tempfile.rewind
132
+ file = { filename: 'foo.md', tempfile: tempfile }
133
+ @helper.params = { 'title' => 'title', 'file' => file }
134
+ expect(@helper.uploads.first[0]).to eql('file')
135
+ end
145
136
  end
146
137
 
147
- it "fetches the branches" do
148
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
149
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "1" } }])
138
+ it 'fetches the branches' do
139
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
140
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '1' } }])
150
141
 
151
- with_env "GITHUB_TOKEN", "1234" do
152
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
153
- expect(@helper.branches[0][:name]).to eql("master")
142
+ with_env 'GITHUB_TOKEN', '1234' do
143
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
144
+ expect(@helper.branches[0][:name]).to eql('master')
154
145
  end
155
146
  end
156
147
  end
157
148
 
158
- it "fetches the base sha" do
159
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
160
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "123" } }])
149
+ it 'fetches the base sha' do
150
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
151
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '123' } }])
161
152
 
162
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
163
- to_return(:status => 200, :body => {:default_branch => "master"}.to_json,
164
- :headers => { "Content-Type" => "application/json" })
153
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
154
+ .to_return(status: 200, body: { default_branch: 'master' }.to_json,
155
+ headers: { 'Content-Type' => 'application/json' })
165
156
 
166
- with_env "GITHUB_TOKEN", "1234" do
167
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
168
- expect(@helper.base_sha).to eql("123")
157
+ with_env 'GITHUB_TOKEN', '1234' do
158
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
159
+ expect(@helper.base_sha).to eql('123')
169
160
  end
170
161
  end
171
162
  end
172
163
 
173
- it "knows if a branch exists" do
174
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
175
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "123" } }].to_json,
176
- :headers => { "Content-Type" => "application/json" })
164
+ it 'knows if a branch exists' do
165
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
166
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '123' } }].to_json,
167
+ headers: { 'Content-Type' => 'application/json' })
177
168
 
178
- with_env "GITHUB_TOKEN", "1234" do
179
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
180
- expect(@helper.branch_exists?("master")).to eql(true)
181
- expect(@helper.branch_exists?("master2")).to eql(false)
169
+ with_env 'GITHUB_TOKEN', '1234' do
170
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
171
+ expect(@helper.branch_exists?('master')).to eql(true)
172
+ expect(@helper.branch_exists?('master2')).to eql(false)
182
173
  end
183
174
  end
184
175
  end
185
176
 
186
- it "creates the branch name" do
187
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
188
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "123" } }].to_json,
189
- :headers => { "Content-Type" => "application/json" })
177
+ it 'creates the branch name' do
178
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
179
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '123' } }].to_json,
180
+ headers: { 'Content-Type' => 'application/json' })
190
181
 
191
- with_env "GITHUB_TOKEN", "1234" do
192
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
193
- @helper.params = {"title" => "My title" }
194
- expect(@helper.patch_branch).to eql("my-title")
182
+ with_env 'GITHUB_TOKEN', '1234' do
183
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
184
+ @helper.params = { 'title' => 'My title' }
185
+ expect(@helper.patch_branch).to eql('my-title')
195
186
 
196
- @helper.params = {"title" => "master" }
197
- expect(@helper.patch_branch).to eql("master-1")
187
+ @helper.params = { 'title' => 'master' }
188
+ expect(@helper.patch_branch).to eql('master-1')
198
189
  end
199
190
  end
200
191
  end
201
192
 
202
- it "creates a branch" do
203
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
204
- to_return(:status => 200, :body => {:default_branch => "master"}.to_json,
205
- :headers => { "Content-Type" => "application/json" })
193
+ it 'creates a branch' do
194
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
195
+ .to_return(status: 200, body: { default_branch: 'master' }.to_json,
196
+ headers: { 'Content-Type' => 'application/json' })
206
197
 
207
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
208
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "123" } }].to_json,
209
- :headers => { "Content-Type" => "application/json" })
198
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
199
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '123' } }].to_json,
200
+ headers: { 'Content-Type' => 'application/json' })
210
201
 
211
- stub = stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/git/refs").
212
- with(:body => "{\"ref\":\"refs/heads/my-branch\",\"sha\":\"123\"}")
202
+ stub = stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/git/refs')
203
+ .with(body: '{"ref":"refs/heads/my-branch","sha":"123"}')
213
204
 
214
- with_env "GITHUB_TOKEN", "1234" do
215
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
216
- @helper.create_branch("my-branch")
205
+ with_env 'GITHUB_TOKEN', '1234' do
206
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
207
+ @helper.create_branch('my-branch')
217
208
  expect(stub).to have_been_requested
218
209
  end
219
210
  end
220
211
  end
221
212
 
222
- it "caches uploads" do
223
- path = File.expand_path "./fixtures/file.txt", File.dirname(__FILE__)
224
- @helper.params = { "title" => "title", "some_file" => { :filename => "file.txt", :tempfile => path } }
225
- @helper.cache_form_data
226
- expect(@helper.session["file_some_file"]).to eql("FOO\n")
227
- end
228
-
229
- it "creates the pull request" do
230
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
231
- to_return(:status => 200, :body => {:default_branch => "master"}.to_json,
232
- :headers => { "Content-Type" => "application/json" })
233
-
234
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me/branches").
235
- to_return(:status => 200, :body => [{ :name => "master", :commit => { :sha => "123" } }].to_json,
236
- :headers => { "Content-Type" => "application/json" })
237
-
238
- stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/git/refs").
239
- with(:body => "{\"ref\":\"refs/heads/title\",\"sha\":\"123\"}").
240
- to_return(:status => 200)
241
-
242
- push = stub_request(:put, "https://api.github.com/repos/benbalter/test-repo-ignore-me/contents/").
243
- with(:body => "{\"branch\":\"title\",\"content\":\"Rk9PCg==\",\"message\":\"Create \"}")
244
-
245
- pr = stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/pulls").
246
- with(:body => "{\"labels\":null,\"base\":\"master\",\"head\":\"title\",\"title\":\"title\",\"body\":\"* **Foo**: bar\"}")
247
-
248
- with_env "GITHUB_TOKEN", "1234" do
249
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
250
- path = File.expand_path "./fixtures/file.txt", File.dirname(__FILE__)
251
- @helper.params = { "title" => "title", "some_file" => { :filename => "file.txt", :tempfile => path }, "foo" => "bar" }
252
- @helper.cache_form_data
253
- @helper.create_pull_request
254
- expect(push).to have_been_requested
255
- expect(pr).to have_been_requested
213
+ it 'creates the pull request' do
214
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
215
+ .to_return(status: 200, body: { default_branch: 'master' }.to_json,
216
+ headers: { 'Content-Type' => 'application/json' })
217
+
218
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/branches')
219
+ .to_return(status: 200, body: [{ name: 'master', commit: { sha: '123' } }].to_json,
220
+ headers: { 'Content-Type' => 'application/json' })
221
+
222
+ stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/git/refs')
223
+ .with(body: '{"ref":"refs/heads/title","sha":"123"}')
224
+ .to_return(status: 200)
225
+
226
+ push = stub_request(:put, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/contents/file.txt')
227
+ .with(body: {
228
+ branch: 'title',
229
+ content: 'Rk9PCg==',
230
+ message: 'Create file.txt'
231
+ }.to_json)
232
+
233
+ pr = stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/pulls')
234
+ .with(body: '{"labels":null,"base":"master","head":"title","title":"title","body":"* **Foo**: bar"}')
235
+
236
+ with_env 'GITHUB_TOKEN', '1234' do
237
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
238
+ Tempfile.open do |tempfile|
239
+ tempfile.write("FOO\n")
240
+ tempfile.rewind
241
+ @helper.params = { 'title' => 'title', 'some_file' => {
242
+ filename: 'file.txt',
243
+ tempfile: tempfile
244
+ }, 'foo' => 'bar' }
245
+ @helper.create_pull_request
246
+ expect(push).to have_been_requested
247
+ expect(pr).to have_been_requested
248
+ end
256
249
  end
257
250
  end
258
251
  end
@@ -1,34 +1,33 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- describe "ProblemChild" do
4
- it "knows the root" do
5
- expected = File.expand_path "../lib/problem_child", File.dirname(__FILE__)
6
- expect(ProblemChild.root).to eql(expected)
3
+ describe 'ProblemChild' do
4
+ it 'knows the root' do
5
+ expected = File.expand_path '../lib/problem_child', File.dirname(__FILE__)
6
+ expect(ProblemChild.root).to eql(expected)
7
7
  end
8
8
 
9
- it "knows the views dir" do
10
- expected = File.expand_path "../lib/problem_child/views", File.dirname(__FILE__)
11
- expect(ProblemChild.views_dir).to eql(expected)
9
+ it 'knows the views dir' do
10
+ expected = File.expand_path '../lib/problem_child/views', File.dirname(__FILE__)
11
+ expect(ProblemChild.views_dir).to eql(expected)
12
12
  end
13
13
 
14
- it "allows users to set the views dir" do
15
- old = ProblemChild.views_dir
16
- ProblemChild.views_dir = "./foo"
17
- expect(ProblemChild.views_dir).to eql("./foo")
18
- ProblemChild.views_dir = old
14
+ it 'allows users to set the views dir' do
15
+ old = ProblemChild.views_dir
16
+ ProblemChild.views_dir = './foo'
17
+ expect(ProblemChild.views_dir).to eql('./foo')
18
+ ProblemChild.views_dir = old
19
19
  end
20
20
  end
21
21
 
22
- describe "logged in user" do
23
-
22
+ describe 'logged in user' do
24
23
  before(:each) do
25
24
  @user = make_user('login' => 'benbaltertest')
26
25
  login_as @user
27
26
 
28
- ENV["GITHUB_TEAM_ID"] = nil
29
- ENV["GITHUB_ORG_ID"] = nil
30
- ENV["GITHUB_TOKEN"] = nil
31
- ENV["GITHUB_REPO"] = nil
27
+ ENV['GITHUB_TEAM_ID'] = nil
28
+ ENV['GITHUB_ORG_ID'] = nil
29
+ ENV['GITHUB_TOKEN'] = nil
30
+ ENV['GITHUB_REPO'] = nil
32
31
  end
33
32
 
34
33
  include Rack::Test::Methods
@@ -37,59 +36,57 @@ describe "logged in user" do
37
36
  ProblemChild::App
38
37
  end
39
38
 
40
- it "shows the securocat when github returns an oauth error" do
41
- with_env "GITHUB_ORG_ID", "balter-test-org" do
42
- get "/auth/github/callback?error=redirect_uri_mismatch"
39
+ it 'shows the securocat when github returns an oauth error' do
40
+ with_env 'GITHUB_ORG_ID', 'balter-test-org' do
41
+ get '/auth/github/callback?error=redirect_uri_mismatch'
43
42
  follow_redirect!
44
- expect(last_response.body).to match(%r{securocat\.png})
43
+ expect(last_response.body).to match(/securocat\.png/)
45
44
  end
46
45
  end
47
46
 
48
47
  it "shows the form when properly org auth'd" do
49
- with_env "GITHUB_ORG_ID", "balter-test-org" do
50
- stub_request(:get, "https://api.github.com/orgs/balter-test-org/members/benbaltertest").
51
- to_return(:status => 204)
48
+ with_env 'GITHUB_ORG_ID', 'balter-test-org' do
49
+ stub_request(:get, 'https://api.github.com/orgs/balter-test-org/members/benbaltertest')
50
+ .to_return(status: 204)
52
51
 
53
- get "/"
52
+ get '/'
54
53
  expect(last_response.status).to eql(200)
55
54
  expect(last_response.body).to match(/Submit an issue/)
56
55
  end
57
56
  end
58
57
 
59
58
  it "shows the form when properly team auth'd" do
60
- with_env "GITHUB_TEAM_ID", "1234" do
61
- stub_request(:get, "https://api.github.com/teams/1234/members/benbaltertest").
62
- to_return(:status => 204)
59
+ with_env 'GITHUB_TEAM_ID', '1234' do
60
+ stub_request(:get, 'https://api.github.com/teams/1234/members/benbaltertest')
61
+ .to_return(status: 204)
63
62
 
64
- get "/"
63
+ get '/'
65
64
  expect(last_response.status).to eql(200)
66
65
  expect(last_response.body).to match(/Submit an issue/)
67
66
  end
68
67
  end
69
68
 
70
- it "refuses to show the site with no auth strategy" do
71
- with_env "GITHUB_TEAM_ID", nil do
72
- with_env "GITHUB_ORG_ID", nil do
73
- with_env "GITHUB_TOKEN", nil do
74
- expect{get "/"}.to raise_error(/Must define GITHUB_TEAM_ID, GITHUB_ORG_ID, OR GITHUB_TOKEN/)
69
+ it 'refuses to show the site with no auth strategy' do
70
+ with_env 'GITHUB_TEAM_ID', nil do
71
+ with_env 'GITHUB_ORG_ID', nil do
72
+ with_env 'GITHUB_TOKEN', nil do
73
+ expect { get '/' }.to raise_error(/Must define GITHUB_TEAM_ID, GITHUB_ORG_ID, OR GITHUB_TOKEN/)
75
74
  end
76
75
  end
77
76
  end
78
77
  end
79
78
 
80
- it "allows the user to create an issue" do
81
- with_env "GITHUB_ORG_ID", "balter-test-org" do
82
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
83
-
84
- stub_request(:get, "https://api.github.com/orgs/balter-test-org/members/benbaltertest").
85
- to_return(:status => 204)
79
+ it 'allows the user to create an issue' do
80
+ with_env 'GITHUB_ORG_ID', 'balter-test-org' do
81
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
82
+ stub_request(:get, 'https://api.github.com/orgs/balter-test-org/members/benbaltertest')
83
+ .to_return(status: 204)
86
84
 
87
- stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
88
- with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: bar\"}").
89
- to_return(:status => 200, :body => '{"number": 1234}', :headers => { 'Content-Type' => 'application/json' })
85
+ stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/issues')
86
+ .with(body: '{"labels":[],"title":"title","body":"* **Foo**: bar"}')
87
+ .to_return(status: 200, body: '{"number": 1234}', headers: { 'Content-Type' => 'application/json' })
90
88
 
91
- post "/", :title => "title", :foo => "bar"
92
- follow_redirect!
89
+ post '/', title: 'title', foo: 'bar'
93
90
 
94
91
  expect(last_response.status).to eql(200)
95
92
  expected = '<a href="http://github.com/benbalter/test-repo-ignore-me/issues/1234">benbalter/test-repo-ignore-me#1234</a>'
@@ -99,44 +96,42 @@ describe "logged in user" do
99
96
  end
100
97
  end
101
98
 
102
- describe "logged out user" do
99
+ describe 'logged out user' do
103
100
  include Rack::Test::Methods
104
101
 
105
102
  def app
106
103
  ProblemChild::App
107
104
  end
108
105
 
109
- it "asks the user to log in" do
110
- with_env "GITHUB_ORG_ID", "balter-test-org" do
111
- with_env "GITHUB_TOKEN", nil do
112
- get "/"
106
+ it 'asks the user to log in' do
107
+ with_env 'GITHUB_ORG_ID', 'balter-test-org' do
108
+ with_env 'GITHUB_TOKEN', nil do
109
+ get '/'
113
110
  expect(last_response.status).to eql(302)
114
111
  expect(last_response.headers['Location']).to match(%r{^https://github\.com/login/oauth/authorize})
115
112
  end
116
113
  end
117
114
  end
118
115
 
119
- it "allows anonymous users to see the form" do
120
- with_env "GITHUB_TOKEN", "1234" do
121
- get "/"
116
+ it 'allows anonymous users to see the form' do
117
+ with_env 'GITHUB_TOKEN', '1234' do
118
+ get '/'
122
119
  expect(last_response.status).to eql(200)
123
120
  expect(last_response.body).to match(/Submit an issue/)
124
121
  end
125
122
  end
126
123
 
127
- it "allows anonymous submissions" do
128
- with_env "GITHUB_TOKEN", "1234" do
129
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
130
-
131
- stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
132
- with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: bar\"}").
133
- to_return(:status => 200, :body => '{"number": 1234}', :headers => { 'Content-Type' => 'application/json' })
124
+ it 'allows anonymous submissions' do
125
+ with_env 'GITHUB_TOKEN', '1234' do
126
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
127
+ stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/issues')
128
+ .with(body: '{"labels":[],"title":"title","body":"* **Foo**: bar"}')
129
+ .to_return(status: 200, body: '{"number": 1234}', headers: { 'Content-Type' => 'application/json' })
134
130
 
135
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
136
- to_return(:status => 200, :body => '{"private": true}', :headers => { 'Content-Type' => 'application/json' })
131
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
132
+ .to_return(status: 200, body: '{"private": true}', headers: { 'Content-Type' => 'application/json' })
137
133
 
138
- post "/", :title => "title", :foo => "bar"
139
- follow_redirect!
134
+ post '/', title: 'title', foo: 'bar'
140
135
 
141
136
  expect(last_response.status).to eql(200)
142
137
  expect(last_response.body).to match(/Your issue was successfully submitted\./)
@@ -144,20 +139,19 @@ describe "logged out user" do
144
139
  end
145
140
  end
146
141
 
147
- it "supports submissions > 4k" do
148
- with_env "GITHUB_TOKEN", "1234" do
149
- with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
150
- long_string = "0" * 5000
142
+ it 'supports submissions > 4k' do
143
+ with_env 'GITHUB_TOKEN', '1234' do
144
+ with_env 'GITHUB_REPO', 'benbalter/test-repo-ignore-me' do
145
+ long_string = '0' * 5000
151
146
 
152
- stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
153
- with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: #{long_string}\"}").
154
- to_return(:status => 200, :body => '{"number": 1234}', :headers => { 'Content-Type' => 'application/json' })
147
+ stub_request(:post, 'https://api.github.com/repos/benbalter/test-repo-ignore-me/issues')
148
+ .with(body: "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: #{long_string}\"}")
149
+ .to_return(status: 200, body: '{"number": 1234}', headers: { 'Content-Type' => 'application/json' })
155
150
 
156
- stub_request(:get, "https://api.github.com/repos/benbalter/test-repo-ignore-me").
157
- to_return(:status => 200, :body => '{"private": true}', :headers => { 'Content-Type' => 'application/json' })
151
+ stub_request(:get, 'https://api.github.com/repos/benbalter/test-repo-ignore-me')
152
+ .to_return(status: 200, body: '{"private": true}', headers: { 'Content-Type' => 'application/json' })
158
153
 
159
- post "/", :title => "title", :foo => long_string
160
- follow_redirect!
154
+ post '/', title: 'title', foo: long_string
161
155
 
162
156
  expect(last_response.status).to eql(200)
163
157
  expect(last_response.body).to match(/Your issue was successfully submitted\./)
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,22 @@
1
- require "bundler/setup"
1
+ require 'bundler/setup'
2
2
 
3
3
  ENV['RACK_ENV'] = 'test'
4
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.push File.join(File.dirname(__FILE__), '..', 'lib')
5
5
 
6
6
  require 'rack/test'
7
7
  require 'sinatra/auth/github'
8
8
  require 'sinatra/auth/github/test/test_helper'
9
9
  require 'webmock/rspec'
10
10
 
11
- require_relative "../lib/problem_child"
11
+ require_relative '../lib/problem_child'
12
12
  WebMock.disable_net_connect!
13
13
 
14
14
  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"
18
+ ENV['GITHUB_CLIENT_ID'] = '1234'
19
+ ENV['GITHUB_CLIENT_SECRET'] = 'asdf'
20
20
 
21
21
  def with_env(key, value)
22
22
  old_env = ENV[key]
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: 2.1.1
4
+ version: 3.0.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-11-25 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -108,34 +108,6 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.6'
111
- - !ruby/object:Gem::Dependency
112
- name: redis
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.2'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.2'
125
- - !ruby/object:Gem::Dependency
126
- name: moneta
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.8'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.8'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: rspec
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +206,20 @@ dependencies:
234
206
  - - "~>"
235
207
  - !ruby/object:Gem::Version
236
208
  version: '0.10'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.41'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.41'
237
223
  description:
238
224
  email:
239
225
  - ben.balter@github.com
@@ -243,6 +229,7 @@ extra_rdoc_files: []
243
229
  files:
244
230
  - ".bowerrc"
245
231
  - ".gitignore"
232
+ - ".rubocop.yml"
246
233
  - ".travis.yml"
247
234
  - Gemfile
248
235
  - LICENSE.txt
@@ -330,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
317
  version: '0'
331
318
  requirements: []
332
319
  rubyforge_project:
333
- rubygems_version: 2.5.0
320
+ rubygems_version: 2.6.6
334
321
  signing_key:
335
322
  specification_version: 4
336
323
  summary: Allows authenticated or anonymous users to fill out a standard web form to
@@ -340,4 +327,3 @@ test_files:
340
327
  - spec/problem_child_helpers_spec.rb
341
328
  - spec/problem_child_spec.rb
342
329
  - spec/spec_helper.rb
343
- has_rdoc: