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

58 lines
1.6 KiB
Ruby
Raw Normal View History

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,
2017-08-17 22:00:37 +05:30
namespace_id: project.namespace,
project_id: project,
2016-08-24 12:49:21 +05:30
issuable_id: issue.id,
issuable_type: 'issue',
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,
2017-08-17 22:00:37 +05:30
namespace_id: project.namespace,
project_id: project,
2016-08-24 12:49:21 +05:30
issuable_id: merge_request.id,
issuable_type: 'merge_request',
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