2022-10-02 17:18:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'events/event/_common.html.haml' do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:issue) { create(:issue, project: project) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
before do
|
|
|
|
render partial: 'events/event/common', locals: { event: event.present }
|
|
|
|
end
|
|
|
|
|
2022-10-02 17:18:49 +05:30
|
|
|
context 'when it is a work item event' do
|
2022-11-25 23:54:43 +05:30
|
|
|
let_it_be(:work_item) { create(:work_item, :task, project: project) }
|
2022-10-02 17:18:49 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
let_it_be(:event) do
|
2022-10-02 17:18:49 +05:30
|
|
|
create(:event, :created, project: project, target: work_item, target_type: 'WorkItem', author: user)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'renders the correct url with iid' do
|
2022-10-02 17:18:49 +05:30
|
|
|
expect(rendered).to have_link(
|
2023-01-13 00:05:48 +05:30
|
|
|
work_item.reference_link_text, href: "/#{project.full_path}/-/work_items/#{work_item.iid}?iid_path=true"
|
2022-10-02 17:18:49 +05:30
|
|
|
)
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
it 'uses issue_type for the target_name' do
|
|
|
|
expect(rendered).to have_content("#{s_('Event|opened')} task #{work_item.to_reference}")
|
|
|
|
end
|
2022-10-02 17:18:49 +05:30
|
|
|
end
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
context 'when it is an issue event' do
|
|
|
|
let_it_be(:issue) { create(:issue, project: project) }
|
2022-10-02 17:18:49 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
let_it_be(:event) do
|
2022-10-02 17:18:49 +05:30
|
|
|
create(:event, :created, project: project, target: issue, author: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the correct url' do
|
|
|
|
expect(rendered).to have_link(issue.reference_link_text, href: "/#{project.full_path}/-/issues/#{issue.iid}")
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
it 'uses issue_type for the target_name' do
|
|
|
|
expect(rendered).to have_content("#{s_('Event|opened')} issue #{issue.to_reference}")
|
|
|
|
end
|
2022-10-02 17:18:49 +05:30
|
|
|
end
|
|
|
|
end
|