Commit a1e4d4de authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Igor Drozdov

Support design notes in url generator

This ensures that we can serve events on the activity feed that are
notes on designs
parent f1dd55e8
......@@ -8,9 +8,21 @@ module EE
def event_note_target_url(event)
if event.epic_note?
group_epic_url(event.group, event.note_target, anchor: dom_id(event.target))
elsif event.design_note?
design_url(event.note_target, anchor: dom_id(event.note))
else
super
end
end
private
def design_url(design, opts)
designs_project_issue_url(
design.project,
design.issue,
opts.merge(vueroute: design.filename)
)
end
end
end
---
title: Fix error when viewing events from design notes on project activity page
merge_request: 27840
author:
type: fixed
......@@ -13,7 +13,7 @@ FactoryBot.modify do
trait :for_design do
transient do
design { create(:design, issue: create(:issue, project: project)) }
note { create(:note, project: project, noteable: design) }
note { create(:note, author: author, project: project, noteable: design) }
end
action { Event::COMMENTED }
......
# frozen_string_literal: true
require 'spec_helper'
describe 'Projects > Activity > User sees design comment', :js do
include DesignManagementTestHelpers
let_it_be(:project) { create(:project, :repository, :public) }
let_it_be(:user) { project.creator }
let_it_be(:commenter) { create(:user) }
let_it_be(:issue) { create(:closed_issue, project: project) }
let_it_be(:design) { create(:design, issue: issue) }
let(:design_activity) do
"#{commenter.name} #{commenter.to_reference} commented on design"
end
let(:issue_activity) do
"#{user.name} #{user.to_reference} closed issue #{issue.to_reference}"
end
before(:all) do
project.add_developer(commenter)
create(:event, :for_design, project: project, author: commenter, design: design)
create(:closed_issue_event, project: project, author: user, target: issue)
end
before do
enable_design_management
end
it 'shows the design comment action in the activity page' do
visit activity_project_path(project)
expect(page).to have_content(design_activity)
end
it 'allows to filter out the design event with the "event_filter=issue" URL param', :aggregate_failures do
visit activity_project_path(project, event_filter: EventFilter::ISSUE)
expect(page).not_to have_content(design_activity)
expect(page).to have_content(issue_activity)
end
it 'allows to filter in the event with the "event_filter=comments" URL param', :aggregate_failures do
visit activity_project_path(project, event_filter: EventFilter::COMMENTS)
expect(page).to have_content(design_activity)
expect(page).not_to have_content(issue_activity)
end
end
# frozen_string_literal: true
require 'spec_helper'
describe EventsHelper do
describe '#event_note_target_url' do
let(:project) { event.project }
let(:project_base_url) { project_url(project) }
subject { helper.event_note_target_url(event) }
context 'for design note events' do
let(:event) { create(:event, :for_design) }
it 'returns an appropriate URL' do
iid = event.note_target.issue.iid
filename = event.note_target.filename
note_id = event.target.id
expect(subject).to eq("#{project_base_url}/-/issues/#{iid}/designs/#{filename}#note_#{note_id}")
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment