debian-mirror-gitlab/spec/services/notes/destroy_service_spec.rb

26 lines
806 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Notes::DestroyService do
2018-03-17 18:26:18 +05:30
set(:project) { create(:project, :public) }
set(:issue) { create(:issue, project: project) }
let(:user) { issue.author }
2016-06-02 11:05:42 +05:30
describe '#execute' do
it 'deletes a note' do
note = create(:note, project: project, noteable: issue)
2018-03-17 18:26:18 +05:30
described_class.new(project, user).execute(note)
2016-06-02 11:05:42 +05:30
expect(project.issues.find(issue.id).notes).not_to include(note)
end
2018-03-17 18:26:18 +05:30
it 'updates the todo counts for users with todos for the note' do
note = create(:note, project: project, noteable: issue)
create(:todo, note: note, target: issue, user: user, author: user, project: project)
expect { described_class.new(project, user).execute(note) }
.to change { user.todos_pending_count }.from(1).to(0)
end
2016-06-02 11:05:42 +05:30
end
end