debian-mirror-gitlab/spec/controllers/projects/todos_controller_spec.rb

64 lines
1.7 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-06-22 15:30:34 +05:30
require('spec_helper')
describe Projects::TodosController do
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-06-22 15:30:34 +05:30
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
2018-11-18 11:00:15 +05:30
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-22 15:30:34 +05:30
context 'Issues' do
describe 'POST create' do
2018-11-18 11:00:15 +05:30
def post_create
2016-08-24 12:49:21 +05:30
post :create,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: issue.id,
issuable_type: 'issue'
},
2016-08-24 12:49:21 +05:30
format: 'html'
end
2018-11-18 11:00:15 +05:30
it_behaves_like 'project todos actions'
2016-06-22 15:30:34 +05:30
end
end
context 'Merge Requests' do
describe 'POST create' do
2018-11-18 11:00:15 +05:30
def post_create
2016-08-24 12:49:21 +05:30
post :create,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: merge_request.id,
issuable_type: 'merge_request'
},
2016-08-24 12:49:21 +05:30
format: 'html'
end
2018-11-18 11:00:15 +05:30
it_behaves_like 'project todos actions'
2016-06-22 15:30:34 +05:30
end
end
end