FEATURE: Handle oneboxes for complex GitHub URLs (#18474)

GitHub PR URLs can link to a commit of the PR, a comment or a review
discussion.
This commit is contained in:
Bianca Nenciu
2022-10-06 20:26:04 +03:00
committed by GitHub
parent e83d35d6f3
commit 73e9875a1d
7 changed files with 327 additions and 27 deletions

View File

@ -49,4 +49,30 @@ RSpec.describe Onebox::Engine::GithubPullRequestOnebox do
expect(html).not_to include("test comment")
end
end
context "with commit links" do
before do
@link = "https://github.com/discourse/discourse/pull/1253/commits/d7d3be1130c665cc7fab9f05dbf32335229137a6"
@uri = "https://api.github.com/repos/discourse/discourse/commits/d7d3be1130c665cc7fab9f05dbf32335229137a6"
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name + "_commit"))
end
it "includes commit name" do
expect(html).to include("Add audio onebox")
end
end
context "with comment links" do
before do
@link = "https://github.com/discourse/discourse/pull/1253/#issuecomment-21597425"
@uri = "https://api.github.com/repos/discourse/discourse/issues/comments/21597425"
stub_request(:get, @uri).to_return(status: 200, body: onebox_response(described_class.onebox_name + "_comment"))
end
it "includes comment" do
expect(html).to include("You've signed the CLA")
end
end
end