summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-07-04 12:57:37 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-07-04 12:57:37 +0000
commit4d9a3f42f1fd3be21555e19872b7121cca65015e (patch)
tree9218831b49cb106165e01b41492981089a37de10 /spec/support
parentecf9c145f6e4d170cd059df88743393d9e63c489 (diff)
parent0d11c4a8c7f69278bdef812374e334ad11b1cd98 (diff)
downloadgitlab-ce-4d9a3f42f1fd3be21555e19872b7121cca65015e.tar.gz
Merge branch 'ee-5481-epic-todos' into 'master'
Port of Todos for epics See merge request gitlab-org/gitlab-ce!19908
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_examples/controllers/todos_shared_examples.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/support/shared_examples/controllers/todos_shared_examples.rb b/spec/support/shared_examples/controllers/todos_shared_examples.rb
new file mode 100644
index 00000000000..bafd9bac8d0
--- /dev/null
+++ b/spec/support/shared_examples/controllers/todos_shared_examples.rb
@@ -0,0 +1,43 @@
+shared_examples 'todos actions' do
+ 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)
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+
+ it 'returns todo path and pending count' do
+ post_create
+
+ expect(response).to have_gitlab_http_status(200)
+ 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)
+
+ expect(response).to have_gitlab_http_status(404)
+ 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)
+
+ expect(response).to have_gitlab_http_status(parent.is_a?(Group) ? 401 : 302)
+ end
+ end
+end