problem_child 2.1.0 → 2.1.1

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: bba9a9faf97164a454765c969947cdd01c0483f8
4
- data.tar.gz: c6dc44c535d6cd7e83ccad88c078dfa593b82029
3
+ metadata.gz: 23e61aafef42b2d8a22e1eb9cd300108f808d714
4
+ data.tar.gz: 6dfde2eafb3c1ef44074c76aa94eafea6abfca5e
5
5
  SHA512:
6
- metadata.gz: 9fb22eb689fc603aad6e6ca036bdf258faf5fbaf3ec7b167145f8ae89ad6ef0cb0a341eb36af97fb223a2b77c8873b6942d29f29a0452da04f230ad4fd46b542
7
- data.tar.gz: cd2d71646e61d08cd32ab36a9aa5e5d65372a2f9338f96c3822423f3c240e73d2625475d04bed3a6b672b66aeb07f6bf8f1befea0f12a55be3aafdd30424f1a0
6
+ metadata.gz: 628253249fe3d9b38f2cace36492c6c9b5752035fca94e98413617d4c811a8822dce803f11da8e7929161fbffdd8009a3a864a61f3d86901542f37370e1c7736
7
+ data.tar.gz: fc1bbf214d479260fcfc852b935f9e1d9a25df0048f71eae79c7ed4384cd0bf939d7cbd6b8c014474abc4188a6560bc229d499fa207ca1bad1f756e0f76eac43
data/.travis.yml CHANGED
@@ -13,3 +13,4 @@ env:
13
13
  global:
14
14
  GITHUB_CLIENT_ID: "1234"
15
15
  GITHUB_CLIENT_SECRET: "1234"
16
+ REDIS_URL: "redis://127.0.0.1:6379"
data/README.md CHANGED
@@ -24,30 +24,27 @@ Then, follow the configuration options below.
24
24
 
25
25
  ## Requirements
26
26
 
27
- You'll need to have [Redis](http://redis.io/) running.
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
28
 
29
- On OS X, run `brew install redis` to install, followed by `redis-server` to run the redis server.
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
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.
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
32
 
33
33
  ## Configuring
34
34
 
35
- You must set the following as environmental variables:
35
+ First, you must set the following environmental variable:
36
36
 
37
- * `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` - Created via [github.com/settings/applications/new](https://github.com/settings/applications/new)
38
37
  * `GITHUB_REPO` - the repo to open the issue against in the form of `owner/repo`
39
38
 
40
39
  You must also set **one** of the following:
41
40
 
42
41
  * `GITHUB_TOKEN` - A personal access token for a bot account with the ability to create an issue in the `GITHUB_REPO` if you would like all submissions to be anonymous
43
- * `GITHUB_ORG_ID` - The GitHub Org ID e.g, `@whitehouse` if you'd like all users to authenticate against a GitHub Org prior to being presented the form
42
+ * `GITHUB_ORG_ID` - The GitHub Org ID e.g, `@whitehouse` if you'd like all users to authenticate against a GitHub Org prior to being presented the form, or
44
43
  * `GITHUB_TEAM_ID` - The numeric Team ID (e.g., 1234) if you'd like all users to authenticate against a GitHub Team prior to being presented the form
45
44
 
46
- You can also set a variable to enable Google reCAPTCHA support:
47
-
48
- * `REACAPTCHA_SITE_KEY` - The key created for your reCAPTCHA site via https://www.google.com/recaptcha/admin
45
+ If you are using OAuth Authentication (e.g., you set `GITHUB_ORG_ID` or `GITHUB_TEAM_ID` so that the user submits as themselves), you must also set the following as environmental variables:
49
46
 
50
- If set, the Problem child default form will include a bit of JavaScript to test if the reCAPTCHA test was passed before submitting.
47
+ * `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` - Created via [github.com/settings/applications/new](https://github.com/settings/applications/new)
51
48
 
52
49
  *Pro-tip*: When developing locally, you can add these values to a `.env` file in the project root, and they will be automatically read in on load
53
50
 
@@ -120,4 +117,3 @@ Problem child can also be used to create pull requests. Simply add one or more f
120
117
  3. Commit your changes (`git commit -am 'Add some feature'`)
121
118
  4. Push to the branch (`git push origin my-new-feature`)
122
119
  5. Create a new Pull Request
123
-
@@ -17,10 +17,6 @@ module ProblemChild
17
17
  end
18
18
  end
19
19
 
20
- def recaptcha
21
- ENV["RECAPTCHA_SITE_KEY"] unless ENV["RECAPTCHA_SITE_KEY"].nil? || ENV["RECAPTCHA_SITE_KEY"].to_s.empty?
22
- end
23
-
24
20
  def client
25
21
  @client ||= Octokit::Client.new :access_token => token
26
22
  end
@@ -34,11 +30,7 @@ module ProblemChild
34
30
  end
35
31
 
36
32
  def issue_body
37
- form_data.reject { |key, value|
38
- key == "title" || value.empty? || key == "labels" || value.is_a?(Hash)
39
- }.except( "g-recaptcha-response" ).map { |key, value|
40
- "* **#{key.humanize}**: #{value}"
41
- }.join("\n")
33
+ form_data.reject { |key, value| key == "title" || value.empty? || key == "labels" || value.is_a?(Hash) }.map { |key,value| "* **#{key.humanize}**: #{value}"}.join("\n")
42
34
  end
43
35
 
44
36
  # abstraction to allow cached form data to be used in place of default params
@@ -1,3 +1,3 @@
1
1
  module ProblemChild
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -5,10 +5,6 @@
5
5
  <% end %>
6
6
  </h1>
7
7
 
8
- <div class="alert alert-warning alert-recaptcha hidden" role="alert">
9
- Please verify that you are not a robot.
10
- </div>
11
-
12
8
  <% if issue %>
13
9
  <div class="alert alert-success" role="alert">
14
10
  Your issue was successfully submitted<% if access %> as <a href="http://github.com/<%= repo %>/issues/<%= issue %>"><%= repo %>#<%= issue %></a><% end %>.
@@ -31,9 +27,5 @@
31
27
  <textarea class="form-control" rows="10" id="body" name="body"></textarea>
32
28
  </div>
33
29
 
34
- <% if recaptcha.present? %>
35
- <div class="g-recaptcha" data-sitekey="<%= recaptcha %>"></div>
36
- <% end %>
37
-
38
30
  <button type="submit" class="btn btn-default">Submit</button>
39
31
  </form>
@@ -16,13 +16,6 @@
16
16
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
17
17
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
18
18
  <![endif]-->
19
-
20
- <% if recaptcha.present? %>
21
- <script src='https://www.google.com/recaptcha/api.js'></script>
22
- <% end %>
23
-
24
- <script src='https://www.google.com/recaptcha/api.js'></script>
25
-
26
19
  </head>
27
20
  <body>
28
21
  <div class="container">
@@ -30,25 +23,5 @@
30
23
  <%= yield %>
31
24
 
32
25
  </div>
33
-
34
- <% if recaptcha.present? %>
35
- <script src="/vendor/jquery/dist/jquery.min.js"></script>
36
-
37
- <script>
38
- $( 'form' ).submit( function( e ) {
39
- var prevent = false;
40
-
41
- if ( !grecaptcha.getResponse() ) {
42
- $( '.alert-recaptcha' ).removeClass( 'hidden' );
43
- prevent = true;
44
- }
45
-
46
- if ( prevent ) {
47
- e.preventDefault();
48
- return false;
49
- }
50
- } );
51
- </script>
52
- <% end %>
53
26
  </body>
54
27
  </html>
data/lib/problem_child.rb CHANGED
@@ -40,7 +40,11 @@ module ProblemChild
40
40
  :scopes => "repo,read:org"
41
41
  }
42
42
 
43
- use Rack::Session::Moneta, store: :Redis, url: ENV["REDIS_URL"]
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
44
48
 
45
49
  configure :production do
46
50
  require 'rack-ssl-enforcer'
@@ -32,6 +32,10 @@ describe "ProblemChild::Helpers" do
32
32
  with_env "GITHUB_TOKEN", "asdf" do
33
33
  expect(@helper.anonymous_submissions?).to be(true)
34
34
  end
35
+
36
+ with_env "GITHUB_TOKEN", "" do
37
+ expect(@helper.anonymous_submissions?).to be(false)
38
+ end
35
39
  end
36
40
 
37
41
  it "knows not to allow anonymous submisssions when no token is passed" do
@@ -240,7 +244,7 @@ describe "ProblemChild::Helpers" do
240
244
 
241
245
  pr = stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/pulls").
242
246
  with(:body => "{\"labels\":null,\"base\":\"master\",\"head\":\"title\",\"title\":\"title\",\"body\":\"* **Foo**: bar\"}")
243
-
247
+
244
248
  with_env "GITHUB_TOKEN", "1234" do
245
249
  with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
246
250
  path = File.expand_path "./fixtures/file.txt", File.dirname(__FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: problem_child
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter