mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 09:03:39 +08:00
Various GitHub Onebox improvements (#13163)
* FIX: Improve GitHub folder regexp in Onebox It used to match any GitHub URL that was not matched by the other GitHub Oneboxes and it did not do a good job at handling those. With this change, the generic Onebox will handle the remaining URLs. * FEATURE: Add Onebox for GitHub Actions * FEATURE: Add Onebox for PR check runs * FIX: Remove image from GitHub folder Oneboxes It is a generic, auto-generated image which does not provide any value. * DEV: Add tests * FIX: Strip HTML comments from PR body
This commit is contained in:
56
spec/lib/onebox/engine/github_actions_onebox_spec.rb
Normal file
56
spec/lib/onebox/engine/github_actions_onebox_spec.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe Onebox::Engine::GithubActionsOnebox do
|
||||
describe "PR check run" do
|
||||
before do
|
||||
@link = "https://github.com/discourse/discourse/pull/13128/checks?check_run_id=2660861130"
|
||||
|
||||
stub_request(:get, "https://api.github.com/repos/discourse/discourse/pulls/13128")
|
||||
.to_return(status: 200, body: onebox_response("githubactions_pr"))
|
||||
|
||||
stub_request(:get, "https://api.github.com/repos/discourse/discourse/check-runs/2660861130")
|
||||
.to_return(status: 200, body: onebox_response("githubactions_pr_run"))
|
||||
end
|
||||
|
||||
include_context "engines"
|
||||
it_behaves_like "an engine"
|
||||
|
||||
describe "#to_html" do
|
||||
it "includes status" do
|
||||
expect(html).to include("success")
|
||||
end
|
||||
|
||||
it "includes title" do
|
||||
expect(html).to include("simplify post and topic deletion language")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GitHub Actions run" do
|
||||
before do
|
||||
@link = "https://github.com/discourse/discourse/actions/runs/873214216"
|
||||
|
||||
stub_request(:get, "https://api.github.com/repos/discourse/discourse/actions/runs/873214216")
|
||||
.to_return(status: 200, body: onebox_response("githubactions_actions_run"))
|
||||
end
|
||||
|
||||
include_context "engines"
|
||||
it_behaves_like "an engine"
|
||||
|
||||
describe "#to_html" do
|
||||
it "includes status" do
|
||||
expect(html).to include("success")
|
||||
end
|
||||
|
||||
it "includes title" do
|
||||
expect(html).to include("Remove deleted_by_author key")
|
||||
end
|
||||
|
||||
it "includes action name" do
|
||||
expect(html).to include("Linting")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -46,8 +46,9 @@ describe Onebox::Engine::GithubPullRequestOnebox do
|
||||
expect(html).to include("1")
|
||||
end
|
||||
|
||||
it "includes the body" do
|
||||
it "includes the body without comments" do
|
||||
expect(html).to include("http://meta.discourse.org/t/audio-html5-tag/8168")
|
||||
expect(html).not_to include("test comment")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user