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 +4 -4
- data/README.md +13 -0
- data/lib/problem_child/helpers.rb +6 -2
- data/lib/problem_child/version.rb +1 -1
- data/lib/problem_child/views/form.erb +1 -0
- data/spec/problem_child_helpers_spec.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b194f981f4da29f466015a0147e28f2ea7f98fe
|
4
|
+
data.tar.gz: a8fca157ebe6c7718ba59b46692c63d103c690ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -76,13 +76,12 @@ describe "ProblemChild::Helpers" do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "submits the issue" do
|
79
|
-
|
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
|