2018-07-16 14:30:17 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Todos::Destroy::ConfidentialIssueService do
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:user) { create(:user) }
|
2018-07-26 10:53:50 -04:00
|
|
|
let(:author) { create(:user) }
|
|
|
|
let(:assignee) { create(:user) }
|
|
|
|
let(:guest) { create(:user) }
|
2018-07-16 14:30:17 -04:00
|
|
|
let(:project_member) { create(:user) }
|
2018-07-26 10:53:50 -04:00
|
|
|
let(:issue) { create(:issue, project: project, author: author, assignees: [assignee]) }
|
2018-07-16 14:30:17 -04:00
|
|
|
|
|
|
|
let!(:todo_issue_non_member) { create(:todo, user: user, target: issue, project: project) }
|
|
|
|
let!(:todo_issue_member) { create(:todo, user: project_member, target: issue, project: project) }
|
2018-07-26 10:53:50 -04:00
|
|
|
let!(:todo_issue_author) { create(:todo, user: author, target: issue, project: project) }
|
|
|
|
let!(:todo_issue_asignee) { create(:todo, user: assignee, target: issue, project: project) }
|
|
|
|
let!(:todo_issue_guest) { create(:todo, user: guest, target: issue, project: project) }
|
2018-07-16 14:30:17 -04:00
|
|
|
let!(:todo_another_non_member) { create(:todo, user: user, project: project) }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
before do
|
|
|
|
project.add_developer(project_member)
|
2018-07-26 10:53:50 -04:00
|
|
|
project.add_guest(guest)
|
2018-07-16 14:30:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { described_class.new(issue.id).execute }
|
|
|
|
|
|
|
|
context 'when provided issue is confidential' do
|
|
|
|
before do
|
|
|
|
issue.update!(confidential: true)
|
|
|
|
end
|
|
|
|
|
2018-08-06 04:42:51 -04:00
|
|
|
it 'removes issue todos for users who can not access the confidential issue' do
|
2018-07-26 10:53:50 -04:00
|
|
|
expect { subject }.to change { Todo.count }.from(6).to(4)
|
2018-07-16 14:30:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when provided issue is not confidential' do
|
|
|
|
it 'does not remove any todos' do
|
|
|
|
expect { subject }.not_to change { Todo.count }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|