Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix specs generating macros

Oliver Güntherc77afd50c392
diff --git a/modules/github_integration/frontend/module/tab-prs/tab-prs.component.spec.ts b/modules/github_integration/frontend/module/tab-prs/tab-prs.component.spec.ts
index 85660eada82..2627254b677 100644
--- a/modules/github_integration/frontend/module/tab-prs/tab-prs.component.spec.ts
+++ b/modules/github_integration/frontend/module/tab-prs/tab-prs.component.spec.ts
@@ -128,7 +128,7 @@ describe('TabPrsComponent', () => {
});
it('should display a message when there are no pull requests', () => {
- component.pullRequests = [];
+ component.pullRequests$ = of([]);
fixture.detectChanges();
const pullRequests = fixture.debugElement.queryAll(By.css('github-pull-request'));
const textMessage = fixture.debugElement.queryAll(By.css('p'));
diff --git a/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb b/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
index 2916c4e7449..a8cb29be5af 100644
--- a/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
+++ b/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
@@ -86,9 +86,8 @@ module OpenProject::GithubIntegration
##
# Filters a list of work packages, removing those that are associated to
# the given `GithubPullRequest`.
- def without_already_referenced(work_packages, github_pull_request)
- referenced_work_packages = github_pull_request&.work_packages || []
- work_packages - referenced_work_packages
+ def without_already_referenced(work_packages, already_referenced)
+ work_packages - already_referenced
end
##
diff --git a/modules/github_integration/lib/open_project/github_integration/notification_handler/issue_comment.rb b/modules/github_integration/lib/open_project/github_integration/notification_handler/issue_comment.rb
index a0920174d0a..0220b6a8002 100644
--- a/modules/github_integration/lib/open_project/github_integration/notification_handler/issue_comment.rb
+++ b/modules/github_integration/lib/open_project/github_integration/notification_handler/issue_comment.rb
@@ -47,8 +47,8 @@ module OpenProject::GithubIntegration
github_system_user = User.find_by(id: payload.open_project_user_id)
work_packages = find_mentioned_work_packages(payload.comment.body, github_system_user)
- new_work_packages = without_already_referenced(work_packages, pull_request)
- return unless new_work_packages.any?
+ new_work_packages = without_already_referenced(work_packages, pull_request&.work_packages.to_a || [])
+ return if new_work_packages.none?
pull_request = upsert_partial_pull_request(new_work_packages)
notes = journal_entry(pull_request, payload)
diff --git a/modules/github_integration/lib/open_project/github_integration/notification_handler/pull_request.rb b/modules/github_integration/lib/open_project/github_integration/notification_handler/pull_request.rb
index 4db582c8698..f698d1df55b 100644
--- a/modules/github_integration/lib/open_project/github_integration/notification_handler/pull_request.rb
+++ b/modules/github_integration/lib/open_project/github_integration/notification_handler/pull_request.rb
@@ -43,14 +43,17 @@ module OpenProject::GithubIntegration
].freeze
def process(params)
- @payload = wrap_payload(params)
+ payload = wrap_payload(params)
github_system_user = User.find_by(id: payload.open_project_user_id)
+
work_packages = find_mentioned_work_packages(payload.pull_request.body, github_system_user)
+ return if work_packages.empty?
- pull_request = upsert_pull_request(work_packages)
+ already_referenced = already_referenced_work_packages(payload)
+ pull_request = upsert_pull_request(payload, work_packages)
comment_on_referenced_work_packages(
- work_packages_to_comment_on(payload.action, pull_request, work_packages),
+ work_packages_to_comment_on(payload.action, work_packages, already_referenced),
github_system_user,
journal_entry(pull_request, payload)
)
@@ -58,19 +61,24 @@ module OpenProject::GithubIntegration
private
- attr_reader :payload
-
- def work_packages_to_comment_on(action, pull_request, work_packages)
+ def work_packages_to_comment_on(action, work_packages, already_referenced)
if action == 'edited'
- without_already_referenced(work_packages, pull_request)
+ without_already_referenced(work_packages, already_referenced)
else
COMMENT_ACTIONS.include?(action) ? work_packages : []
end
end
- def upsert_pull_request(work_packages)
- return if work_packages.empty? && pull_request.nil?
+ def already_referenced_work_packages(payload)
+ pull_request = GithubPullRequest
+ .where(github_id: payload.pull_request.id)
+ .or(GithubPullRequest.where(github_html_url: payload.pull_request.html_url))
+ .take
+
+ pull_request&.work_packages.to_a || []
+ end
+ def upsert_pull_request(payload, work_packages)
OpenProject::GithubIntegration::Services::UpsertPullRequest.new.call(payload.pull_request.to_h,
work_packages:)
end
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/hook_handler_integration_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/hook_handler_integration_spec.rb
index 9a6c9244e4e..742afc81f10 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/hook_handler_integration_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/hook_handler_integration_spec.rb
@@ -80,7 +80,7 @@ describe OpenProject::GithubIntegration::HookHandler do
process_webhook
expect(work_packages[0].journals.count).to be(journal_counts_before[0] + 1)
- expect(work_packages[0].journals.last.notes).to include(journal_entry)
+ expect(work_packages[0].journals.last.notes).to match(journal_entry)
expect(work_packages[1].journals.count).to be(journal_counts_before[1])
expect(work_packages[2].journals.count).to be(journal_counts_before[2])
@@ -207,7 +207,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Opened' }
+ let(:journal_entry) { /<macro.+opened/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a pull request and github user'
@@ -234,7 +234,7 @@ describe OpenProject::GithubIntegration::HookHandler do
work_packages.each_with_index do |work_package, index|
expect(work_package.journals.count).to be(journal_counts_before[index] + 1)
- expect(work_package.journals.last.notes).to include('PR Opened')
+ expect(work_package.journals.last.notes).to match(/<macro.+opened/)
end
end
@@ -333,7 +333,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Opened' }
+ let(:journal_entry) { /<macro.+opened/ }
let(:pr_draft) { true }
it_behaves_like 'it comments on the first work_package'
@@ -363,7 +363,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Ready for Review' }
+ let(:journal_entry) { /<macro.+ready_for_review/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a pull request and github user'
@@ -399,7 +399,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'Referenced in PR' }
+ let(:journal_entry) { /<macro.+referenced/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a pull request and github user'
@@ -415,7 +415,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'Referenced in PR' }
+ let(:journal_entry) { /<macro.+referenced/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a pull request and github user'
@@ -445,7 +445,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Closed' }
+ let(:journal_entry) { /<macro.+closed/ }
let(:pr_state) { 'closed' }
it_behaves_like 'it comments on the first work_package'
@@ -461,7 +461,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Opened' }
+ let(:journal_entry) { /<macro.+opened/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a pull request and github user'
@@ -476,7 +476,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR body mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'PR Merged' }
+ let(:journal_entry) { /<macro.+merged/ }
let(:pr_state) { 'closed' }
let(:pr_merged) { true }
@@ -515,7 +515,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR comment mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'Referenced' }
+ let(:journal_entry) { /<macro.+referenced/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a partial pull request' do
@@ -545,7 +545,7 @@ describe OpenProject::GithubIntegration::HookHandler do
body: "A PR comment mentioning OP##{work_packages[0].id}"
)
end
- let(:journal_entry) { 'Referenced' }
+ let(:journal_entry) { /<macro.+referenced/ }
it_behaves_like 'it comments on the first work_package'
it_behaves_like 'it creates a partial pull request' do
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
index 521f8dff4d7..ce49e5ff7fd 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
@@ -124,14 +124,4 @@ describe OpenProject::GithubIntegration::NotificationHandler::Helper do
it_behaves_like 'it finds visible work packages'
end
end
-
- describe '#without_already_referenced' do
- let(:work_packages) { create_list(:work_package, 2) }
- let(:referenced_work_packages) { [work_packages[0]] }
- let(:github_pull_request) { create(:github_pull_request, work_packages: referenced_work_packages) }
-
- it 'returns only the not already referenced work packages' do
- expect(handler.without_already_referenced(work_packages, github_pull_request)).to match_array([work_packages[1]])
- end
- end
end
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/issue_comment_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/issue_comment_spec.rb
index 980b2340d55..cca26a3a596 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/issue_comment_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/issue_comment_spec.rb
@@ -33,7 +33,7 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
let(:handler_instance) { described_class.new }
let(:upsert_partial_pull_request_service) do
- instance_double(OpenProject::GithubIntegration::Services::UpsertPartialPullRequest)
+ OpenProject::GithubIntegration::Services::UpsertPartialPullRequest.new
end
let(:payload) do
{
@@ -47,9 +47,17 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
}
},
'issue' => {
+ 'state' => 'open',
'number' => pr_number,
'title' => 'PR or issue title',
- 'pull_request' => pr_payload
+ 'updated_at' => Time.current.iso8601,
+ 'pull_request' => pr_payload,
+ 'user' => {
+ 'id' => 345,
+ 'login' => 'test_user',
+ 'html_url' => 'https://github.com/test_user',
+ 'avatar_url' => 'https://github.com/test_user.jpg'
+ }
},
'repository' => {
'full_name' => repo_full_name,
@@ -65,6 +73,7 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
let(:repo_full_name) { 'test_user/repo' }
let(:github_system_user) { create(:admin) }
let(:work_package) { create(:work_package) }
+ let(:github_pull_request) { GithubPullRequest.find_by(github_html_url: pr_html_url) }
before do
allow(handler_instance)
@@ -75,7 +84,7 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
.and_return(upsert_partial_pull_request_service)
allow(upsert_partial_pull_request_service)
.to receive(:call)
- .and_return(nil)
+ .and_call_original
end
shared_examples_for 'upserting a GithubPullRequest' do
@@ -101,8 +110,9 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
shared_examples_for 'creating a comment on the work package' do
it 'adds a comment to work packages' do
process
- expect(handler_instance).to have_received(:comment_on_referenced_work_packages).with([work_package], github_system_user,
- comment)
+ expect(handler_instance)
+ .to have_received(:comment_on_referenced_work_packages)
+ .with([work_package], github_system_user, comment)
end
end
@@ -125,8 +135,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
context 'when commented on a PR' do
let(:comment) do
- "**Referenced in PR:** [test_user](https://github.com/test_user) referenced this work package " \
- "in Pull request 123 [PR or issue title](https://comment.url) on [test_user/repo](https://github.com/test_user/repo).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;referenced&quot;"></macro>).squish
end
it_behaves_like 'creating a comment on the work package'
@@ -134,14 +144,10 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
end
context 'when we already have a GithubPullRequest for the commented PR' do
- let(:github_pull_request) { create(:github_pull_request, github_html_url: pr_html_url) }
+ let!(:github_pull_request) { create(:github_pull_request, github_html_url: pr_html_url) }
let(:comment) do
- "**Referenced in PR:** [test_user](https://github.com/test_user) referenced this work package " \
- "in Pull request 123 [PR or issue title](https://comment.url) on [test_user/repo](https://github.com/test_user/repo).\n"
- end
-
- before do
- github_pull_request
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;referenced&quot;"></macro>).squish
end
it_behaves_like 'creating a comment on the work package'
@@ -149,25 +155,15 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
end
context 'when we already have a GithubPullRequest with that work_package' do
- let(:github_pull_request) do
+ let!(:github_pull_request) do
create(:github_pull_request, github_html_url: pr_html_url, work_packages: [work_package])
end
- before do
- github_pull_request
- end
-
it_behaves_like 'not creating comments on work packages'
it 'calls the UpsertPartialPullRequest service without adding already known work_packages' do
process
- expect(upsert_partial_pull_request_service)
- .to have_received(:call) do |received_payload, work_packages:|
- expect(received_payload.to_h)
- .to eql payload
- expect(work_packages)
- .to match_array []
- end
+ expect(upsert_partial_pull_request_service).not_to have_received(:call)
end
end
end
@@ -184,8 +180,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
context 'when editing a PR comment with a new work package reference' do
let(:comment) do
- "**Referenced in PR:** [test_user](https://github.com/test_user) referenced this work package " \
- "in Pull request 123 [PR or issue title](https://comment.url) on [test_user/repo](https://github.com/test_user/repo).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;referenced&quot;"></macro>).squish
end
it_behaves_like 'creating a comment on the work package'
@@ -193,14 +189,10 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
end
context 'when we already have a GithubPullRequest for the commented PR' do
- let(:github_pull_request) { create(:github_pull_request, github_html_url: pr_html_url) }
+ let!(:github_pull_request) { create(:github_pull_request, github_html_url: pr_html_url) }
let(:comment) do
- "**Referenced in PR:** [test_user](https://github.com/test_user) referenced this work package " \
- "in Pull request 123 [PR or issue title](https://comment.url) on [test_user/repo](https://github.com/test_user/repo).\n"
- end
-
- before do
- github_pull_request
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;referenced&quot;"></macro>).squish
end
it_behaves_like 'creating a comment on the work package'
@@ -208,25 +200,16 @@ describe OpenProject::GithubIntegration::NotificationHandler::IssueComment do
end
context 'when we already have a GithubPullRequest with that work_package' do
- let(:github_pull_request) do
+ let!(:github_pull_request) do
create(:github_pull_request, github_html_url: pr_html_url, work_packages: [work_package])
end
- before do
- github_pull_request
- end
-
it_behaves_like 'not creating comments on work packages'
it 'calls the UpsertPartialPullRequest service without adding already known work_packages' do
process
expect(upsert_partial_pull_request_service)
- .to have_received(:call) do |received_payload, work_packages:|
- expect(received_payload.to_h)
- .to eql payload
- expect(work_packages)
- .to match_array []
- end
+ .not_to have_received(:call)
end
end
end
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/pull_request_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/pull_request_spec.rb
index 50574cd28eb..7e1cec1a5ad 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/pull_request_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/pull_request_spec.rb
@@ -33,7 +33,7 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
let(:handler_instance) { described_class.new }
let(:github_system_user) { create(:admin) }
- let(:upsert_service) { instance_double(OpenProject::GithubIntegration::Services::UpsertPullRequest) }
+ let(:upsert_service) { OpenProject::GithubIntegration::Services::UpsertPullRequest.new }
let(:payload) do
{
@@ -80,11 +80,12 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
let(:pr_body) { "Mentioning OP##{work_package.id}" }
let(:pr_merged) { false }
let(:pr_draft) { false }
+ let(:github_pull_request) { GithubPullRequest.find_by_github_identifiers id: 123 }
before do
allow(handler_instance).to receive(:comment_on_referenced_work_packages).and_return(nil)
allow(OpenProject::GithubIntegration::Services::UpsertPullRequest).to receive(:new).and_return(upsert_service)
- allow(upsert_service).to receive(:call).and_return(nil)
+ allow(upsert_service).to receive(:call).and_call_original
end
shared_examples_for 'not adding a comment' do
@@ -128,8 +129,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
context 'with a closed action' do
let(:action) { 'closed' }
let(:comment) do
- "**PR Closed:** Pull request 1 [A PR title](http://pr.url) for [test_user/repo](github.com/test_user/repo) " \
- "has been closed by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;closed&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
@@ -140,17 +141,15 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
let(:action) { 'closed' }
let(:pr_merged) { true }
let(:comment) do
- "**PR Merged:** Pull request 1 [A PR title](http://pr.url) for [test_user/repo](github.com/test_user/repo) " \
- "has been merged by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;merged&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
it_behaves_like 'calls the pull request upsert service'
context 'when the work package is already known to the GithubPullRequest' do
- let(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
-
- before { github_pull_request }
+ let!(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
it_behaves_like 'adding a comment'
@@ -171,17 +170,15 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
context 'with an edited action' do
let(:action) { 'edited' }
let(:comment) do
- "**Referenced in PR:** [test_user](github.com/test_user) referenced this work package " \
- "in Pull request 1 [A PR title](http://pr.url) on [test_user/repo](github.com/test_user/repo).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;referenced&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
it_behaves_like 'calls the pull request upsert service'
context 'when a GithubPullRequest exists that is not linked to the mentioned work package yet' do
- let(:github_pull_request) { create(:github_pull_request, github_id: 123) }
-
- before { github_pull_request }
+ let!(:github_pull_request) { create(:github_pull_request, github_id: 123) }
it_behaves_like 'adding a comment'
@@ -192,9 +189,7 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
end
context 'when the work package is already known to the GithubPullRequest' do
- let(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
-
- before { github_pull_request }
+ let!(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
it_behaves_like 'not adding a comment'
@@ -205,15 +200,10 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
end
context 'when the a work package is already known to the GithubPullRequest but another work package is new' do
- let(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
- let(:other_work_package) { create(:work_package) }
+ let!(:github_pull_request) { create(:github_pull_request, github_id: 123, work_packages: [work_package]) }
+ let!(:other_work_package) { create(:work_package) }
let(:pr_body) { "Mentioning OP##{work_package.id} and OP##{other_work_package.id}" }
- before do
- github_pull_request
- other_work_package
- end
-
it 'adds a comment only for the other_work_package' do
process
expect(handler_instance).to have_received(:comment_on_referenced_work_packages).with(
@@ -241,8 +231,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
context 'with an opened action' do
let(:action) { 'opened' }
let(:comment) do
- "**PR Opened:** Pull request 1 [A PR title](http://pr.url) for [test_user/repo](github.com/test_user/repo) " \
- "has been opened by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;opened&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
@@ -253,8 +243,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
let(:action) { 'opened' }
let(:pr_draft) { true }
let(:comment) do
- "**PR Opened:** Pull request 1 [A PR title](http://pr.url) for [test_user/repo](github.com/test_user/repo) " \
- "has been opened by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;opened&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
@@ -264,8 +254,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
context 'with a ready_for_review action' do
let(:action) { 'ready_for_review' }
let(:comment) do
- "**PR Ready for Review:** Pull request 1 [A PR title](http://pr.url) " \
- "for [test_user/repo](github.com/test_user/repo) was marked as ready for review by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;ready_for_review&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
@@ -275,8 +265,8 @@ describe OpenProject::GithubIntegration::NotificationHandler::PullRequest do
context 'with a reopened action' do
let(:action) { 'reopened' }
let(:comment) do
- "**PR Opened:** Pull request 1 [A PR title](http://pr.url) for [test_user/repo](github.com/test_user/repo) " \
- "has been opened by [test_user](github.com/test_user).\n"
+ %(<macro class="github_pull_request" data-pull-request-id="#{github_pull_request.id}"
+ data-pull-request-state="&quot;opened&quot;"></macro>).squish
end
it_behaves_like 'adding a comment'
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/services/upsert_pull_request_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/services/upsert_pull_request_spec.rb
index 013112ca457..762827a04c2 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/services/upsert_pull_request_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/services/upsert_pull_request_spec.rb
@@ -49,7 +49,8 @@ describe OpenProject::GithubIntegration::Services::UpsertPullRequest do
'labels' => labels_payload,
'base' => {
'repo' => {
- 'full_name' => 'test_user/repo'
+ 'full_name' => 'test_user/repo',
+ 'html_url' => 'https://github.com/test_user/repo'
}
},
'user' => user_payload,