problem_child 1.0.0 → 1.1.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: 054ff3ece80e2d56567e0852631eb17406a13935
4
- data.tar.gz: f943642e28dd13536bf7daab9cd950fe7a258249
3
+ metadata.gz: 6b194f981f4da29f466015a0147e28f2ea7f98fe
4
+ data.tar.gz: a8fca157ebe6c7718ba59b46692c63d103c690ab
5
5
  SHA512:
6
- metadata.gz: 3f62815854bd1f1fc0dee735893056ecd60fb683e33865c44393f581f6dc1972336b3a98bf861acb87abab73ca828ab395a3b08431e4c309f46734abcbe97df3
7
- data.tar.gz: 1152a305b0aa0a5c1e0b92396f16541a9065b097df335ad8695b2fe09b16c86f14df5fbd5d07d672c61f3eef8fa83736a914854ca8851f3fb76f190c77f3971e
6
+ metadata.gz: b1202f58aef1959d41fb1cba180e127e389ddf26148af0ef42ac53036f18abf3eb64ed7a8c9d21cca833baf8f5e9e04143192921500f493fa03b865a272670f4
7
+ data.tar.gz: b472d792040dd8e939461402c16ca3e3bd4a40b9258734e62846440c2e4c5f087f42873bd09e78601bd2d987a552898e68c5f37680ad144de56fc350a27888bf
data/README.md CHANGED
@@ -60,6 +60,19 @@ run ProblemChild::App
60
60
 
61
61
  *Pro-tip*: You can use any standard HTML form fields, but be sure to name one field `title`, which will become the issue title.
62
62
 
63
+ *Pro-tip II*: Problem child can set labels. You can do this either as a hidden field:
64
+
65
+ ```html
66
+ <input type="hidden" name="labels[]" value="bug" />
67
+ ```
68
+
69
+ or as a checkbox:
70
+
71
+ ```html
72
+ <input type="checkbox" name="labels[]" value="bug" />
73
+ <input type="checkbox" name="labels[]" value="suggestion" />
74
+ ```
75
+
63
76
  ## Contributing
64
77
 
65
78
  1. Fork it ( https://github.com/[my-github-username]/problem_child/fork )
@@ -26,7 +26,7 @@ module ProblemChild
26
26
  end
27
27
 
28
28
  def issue_body
29
- form_data.reject { |key, value| key == "title" || value.empty? }.map { |key,value| "* **#{key.humanize}**: #{value}"}.join("\n")
29
+ form_data.reject { |key, value| key == "title" || value.empty? || key == "labels" }.map { |key,value| "* **#{key.humanize}**: #{value}"}.join("\n")
30
30
  end
31
31
 
32
32
  # abstraction to allow cached form data to be used in place of default params
@@ -34,8 +34,12 @@ module ProblemChild
34
34
  session["form_data"].nil? ? params : JSON.parse(session["form_data"])
35
35
  end
36
36
 
37
+ def labels
38
+ form_data["labels"].join(",") if form_data["labels"]
39
+ end
40
+
37
41
  def create_issue
38
- issue = client.create_issue(repo, form_data["title"], issue_body)
42
+ issue = client.create_issue(repo, form_data["title"], issue_body, :labels => labels)
39
43
  issue["number"] if issue
40
44
  end
41
45
 
@@ -1,3 +1,3 @@
1
1
  module ProblemChild
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -20,5 +20,6 @@
20
20
  <label for="body">Body</label>
21
21
  <textarea class="form-control" rows="10" id="body" name="body"></textarea>
22
22
  </div>
23
+
23
24
  <button type="submit" class="btn btn-default">Submit</button>
24
25
  </form>
@@ -76,13 +76,12 @@ describe "ProblemChild::Helpers" do
76
76
  end
77
77
 
78
78
  it "submits the issue" do
79
- expected = {"title" => "title", "foo" => "bar"}
80
- @helper.params = expected
79
+ @helper.params = {"title" => "title", "foo" => "bar", "labels" => ["foo", "bar"]}
81
80
  with_env "GITHUB_TOKEN", "1234" do
82
81
  with_env "GITHUB_REPO", "benbalter/test-repo-ignore-me" do
83
82
 
84
83
  stub = stub_request(:post, "https://api.github.com/repos/benbalter/test-repo-ignore-me/issues").
85
- with(:body => "{\"labels\":[],\"title\":\"title\",\"body\":\"* **Foo**: bar\"}").
84
+ with(:body => "{\"labels\":[\"foo\",\"bar\"],\"title\":\"title\",\"body\":\"* **Foo**: bar\"}").
86
85
  to_return(:status => 200, :body => '{"number": 1234}', :headers => { 'Content-Type' => 'application/json' })
87
86
 
88
87
  expect(@helper.create_issue).to eql(1234)
@@ -123,4 +122,9 @@ describe "ProblemChild::Helpers" do
123
122
  end
124
123
  end
125
124
  end
125
+
126
+ it "knows the labels" do
127
+ @helper.params["labels"] = ["foo", "bar"]
128
+ expect(@helper.labels).to eql("foo,bar")
129
+ end
126
130
  end
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter