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

43 lines
1.1 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
2015-12-23 02:04:40 +05:30
describe Issues::CreateService, services: true do
2014-09-02 18:07:02 +05:30
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
2016-04-02 18:10:28 +05:30
let(:assignee) { create(:user) }
2014-09-02 18:07:02 +05:30
describe :execute do
2016-04-02 18:10:28 +05:30
context 'valid params' do
2014-09-02 18:07:02 +05:30
before do
project.team << [user, :master]
2016-04-02 18:10:28 +05:30
project.team << [assignee, :master]
2014-09-02 18:07:02 +05:30
opts = {
title: 'Awesome issue',
2016-04-02 18:10:28 +05:30
description: 'please fix',
assignee: assignee
2014-09-02 18:07:02 +05:30
}
@issue = Issues::CreateService.new(project, user, opts).execute
end
2015-04-26 12:48:37 +05:30
it { expect(@issue).to be_valid }
it { expect(@issue.title).to eq('Awesome issue') }
2016-04-02 18:10:28 +05:30
it { expect(@issue.assignee).to eq assignee }
it 'creates a pending todo for new assignee' do
attributes = {
project: project,
author: user,
user: assignee,
target_id: @issue.id,
target_type: @issue.class.name,
action: Todo::ASSIGNED,
state: :pending
}
expect(Todo.where(attributes).count).to eq 1
end
2014-09-02 18:07:02 +05:30
end
end
end