debian-mirror-gitlab/spec/services/issues/after_create_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.5 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Issues::AfterCreateService, feature_category: :team_planning do
2021-04-29 21:17:54 +05:30
include AfterNextHelpers
let_it_be(:project) { create(:project) }
let_it_be(:current_user) { create(:user) }
let_it_be(:assignee) { create(:user) }
let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:issue) { create(:issue, project: project, author: current_user, milestone: milestone, assignee_ids: [assignee.id]) }
2023-04-23 21:23:45 +05:30
subject(:after_create_service) { described_class.new(container: project, current_user: current_user) }
2021-04-29 21:17:54 +05:30
describe '#execute' do
it 'creates a pending todo for new assignee' do
attributes = {
project: project,
author: current_user,
user: assignee,
target_id: issue.id,
target_type: issue.class.name,
action: Todo::ASSIGNED,
state: :pending
}
expect { after_create_service.execute(issue) }.to change { Todo.where(attributes).count }.by(1)
end
context 'with a regular issue' do
it_behaves_like 'does not track incident management event', :incident_management_incident_created do
subject { after_create_service.execute(issue) }
end
end
context 'with an incident issue' do
let(:issue) { create(:issue, :incident, project: project, author: current_user) }
it_behaves_like 'an incident management tracked event', :incident_management_incident_created do
subject { after_create_service.execute(issue) }
end
end
end
end