Skip to content

Commit

Permalink
[enhancement] Fixes #62 - Provide link towards created issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeloupy committed Oct 6, 2016
1 parent 7b6388e commit 5e4c6ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
3 changes: 2 additions & 1 deletion bin/checklister
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ command :new do |c|
puts " to the project: #{project[:name]}"
parsed_checklist = Checklister::Parser.new(checklist_path, title)
issue = api_client.issue.create(project_id, parsed_checklist.to_params)
puts "* Issue successfully created!"
issue_url = issue.html_url || issue.web_url
puts "* Issue successfully created! (#{issue_url})"
end
end

Expand Down
14 changes: 6 additions & 8 deletions spec/checklister/github/issue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
{ endpoint: "https://api.github.com", private_token: "supersecret", kind: "github" }
end
let(:client) { Checklister::Client.new(github_config).api_client }
let(:issue) { Checklister::Github::Issue.new(client).create(3, title: "Beatae possimus nostrum", body: "nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.") }

before(:each) do
stub_request(:post, /api.github.com/).
to_return(status: 200, body: load_fixture("github_issue"), headers: {})
end

describe "#create" do
before(:each) do
stub_request(:post, /api.github.com/).
to_return(status: 200, body: load_fixture("github_issue"), headers: {})
end

context "with valid attributes" do
it "creates an issue by calling the remote service" do
issue = Checklister::Github::Issue.new(client).create(3, title: "Beatae possimus nostrum", body: "nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.")
expect(JSON.parse(issue)["title"]).to eq("Found a bug")
expect(JSON.parse(issue)["body"]).to eq("I'm having a problem with this.")
end
end

context "with invalid attributes" do
end
end
end
15 changes: 6 additions & 9 deletions spec/checklister/gitlab/issue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
{ endpoint: "https://www.gitlab.com/api", private_token: "supersecret", kind: "gitlab" }
end
let(:client) { Checklister::Client.new(gitlab_config).api_client }
let(:issue) { Checklister::Gitlab::Issue.new(client).create(3, title: "Beatae possimus nostrum", body: "nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.") }

describe "#create" do
before(:each) do
stub_request(:post, /www.gitlab.com/).
to_return(status: 200, body: load_fixture("issue"), headers: {})
end
before(:each) do
stub_request(:post, /www.gitlab.com/).
to_return(status: 200, body: load_fixture("issue"), headers: {})
end

describe "#create" do
context "with valid attributes" do
it "creates an issue by calling the remote service" do
issue = Checklister::Gitlab::Issue.new(client).create(3, title: "Beatae possimus nostrum", body: "nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.")
expect(issue.to_hash["project_id"]).to eq(3)
expect(issue.to_hash["title"]).to eq("Beatae possimus nostrum")
expect(issue.to_hash["description"]).to eq("nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.")
end
end

context "with invalid attributes" do
end
end
end
3 changes: 2 additions & 1 deletion spec/fixtures/issue.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
},
"closed":false,
"updated_at":"2012-09-17T09:42:20Z",
"created_at":"2012-09-17T09:42:20Z"
"created_at":"2012-09-17T09:42:20Z",
"web_url": "http://example.com/example/example/issues/14"
}

0 comments on commit 5e4c6ad

Please sign in to comment.