2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'todos actions' do
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'when authorized' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
parent.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates todo' do
|
|
|
|
expect do
|
|
|
|
post_create
|
|
|
|
end.to change { user.todos.count }.by(1)
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns todo path and pending count' do
|
|
|
|
post_create
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2018-11-18 11:00:15 +05:30
|
|
|
expect(json_response['count']).to eq 1
|
|
|
|
expect(json_response['delete_path']).to match(%r{/dashboard/todos/\d{1}})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not authorized for project/group' do
|
|
|
|
it 'does not create todo for resource that user has no access to' do
|
|
|
|
sign_in(user)
|
|
|
|
expect do
|
|
|
|
post_create
|
|
|
|
end.to change { user.todos.count }.by(0)
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create todo when user is not logged in' do
|
|
|
|
expect do
|
|
|
|
post_create
|
|
|
|
end.to change { user.todos.count }.by(0)
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|