diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 83ff898e68a..91b24b8bc29 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -20,8 +20,8 @@ module MergeRequestsHelper end def mr_widget_refresh_url(mr) - if mr && mr.source_project - merge_widget_refresh_namespace_project_merge_request_url(mr.source_project.namespace, mr.source_project, mr) + if mr && mr.target_project + merge_widget_refresh_namespace_project_merge_request_url(mr.target_project.namespace, mr.target_project, mr) else '' end diff --git a/changelogs/unreleased/27632_fix_mr_widget_url.yml b/changelogs/unreleased/27632_fix_mr_widget_url.yml new file mode 100644 index 00000000000..958621a43a1 --- /dev/null +++ b/changelogs/unreleased/27632_fix_mr_widget_url.yml @@ -0,0 +1,4 @@ +--- +title: Fix MR widget url +merge_request: 8989 +author: diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb index 550b4a66a6a..8d268dbcf36 100644 --- a/spec/helpers/merge_requests_helper_spec.rb +++ b/spec/helpers/merge_requests_helper_spec.rb @@ -63,9 +63,11 @@ describe MergeRequestsHelper do end end - describe 'mr_widget_refresh_url' do - let(:project) { create(:empty_project) } - let(:merge_request) { create(:merge_request, source_project: project) } + describe '#mr_widget_refresh_url' do + let(:guest) { create(:user) } + let(:project) { create(:project, :public) } + let(:project_fork) { Projects::ForkService.new(project, guest).execute } + let(:merge_request) { create(:merge_request, source_project: project_fork, target_project: project) } it 'returns correct url for MR' do expected_url = "#{project.path_with_namespace}/merge_requests/#{merge_request.iid}/merge_widget_refresh" @@ -74,7 +76,7 @@ describe MergeRequestsHelper do end it 'returns empty string for nil' do - expect(mr_widget_refresh_url(nil)).to end_with('') + expect(mr_widget_refresh_url(nil)).to eq('') end end end