2016-06-17 04:01:03 -04:00
|
|
|
require('spec_helper')
|
|
|
|
|
|
|
|
describe Projects::TodosController do
|
2016-06-17 04:13:21 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-06-17 04:13:21 -04:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
2018-07-16 09:35:19 -04:00
|
|
|
let(:parent) { project }
|
|
|
|
|
|
|
|
shared_examples 'project todos actions' do
|
|
|
|
it_behaves_like 'todos actions'
|
|
|
|
|
|
|
|
context 'when not authorized for resource' do
|
|
|
|
before do
|
|
|
|
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
|
|
|
|
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't create todo" do
|
|
|
|
expect { post_create }.not_to change { user.todos.count }
|
|
|
|
expect(response).to have_gitlab_http_status(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-17 04:13:21 -04:00
|
|
|
|
|
|
|
context 'Issues' do
|
2016-06-17 13:31:37 -04:00
|
|
|
describe 'POST create' do
|
2018-07-16 09:35:19 -04:00
|
|
|
def post_create
|
2016-07-11 02:10:04 -04:00
|
|
|
post :create,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-07-11 02:10:04 -04:00
|
|
|
issuable_id: issue.id,
|
|
|
|
issuable_type: 'issue',
|
|
|
|
format: 'html'
|
|
|
|
end
|
|
|
|
|
2018-07-16 09:35:19 -04:00
|
|
|
it_behaves_like 'project todos actions'
|
2016-06-17 04:01:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-17 04:13:21 -04:00
|
|
|
context 'Merge Requests' do
|
2016-06-17 13:31:37 -04:00
|
|
|
describe 'POST create' do
|
2018-07-16 09:35:19 -04:00
|
|
|
def post_create
|
2016-07-11 02:10:04 -04:00
|
|
|
post :create,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-07-11 02:10:04 -04:00
|
|
|
issuable_id: merge_request.id,
|
|
|
|
issuable_type: 'merge_request',
|
|
|
|
format: 'html'
|
|
|
|
end
|
|
|
|
|
2018-07-16 09:35:19 -04:00
|
|
|
it_behaves_like 'project todos actions'
|
2016-06-17 04:06:00 -04:00
|
|
|
end
|
|
|
|
end
|
2016-06-17 04:01:03 -04:00
|
|
|
end
|