2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-17 04:01:03 -04:00
|
|
|
require('spec_helper')
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.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 }
|
2020-01-28 07:08:44 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-07-16 09:35:19 -04:00
|
|
|
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,
|
2018-12-17 17:52:17 -05:00
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
issuable_id: issue.id,
|
|
|
|
issuable_type: 'issue'
|
|
|
|
},
|
2016-07-11 02:10:04 -04:00
|
|
|
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,
|
2018-12-17 17:52:17 -05:00
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
issuable_id: merge_request.id,
|
|
|
|
issuable_type: 'merge_request'
|
|
|
|
},
|
2016-07-11 02:10:04 -04:00
|
|
|
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
|