summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-06-17 09:01:03 +0100
committerPhil Hughes <me@iamphill.com>2016-06-17 09:01:03 +0100
commit85fab13ebaf10982c0957daca0afd1ea145e64df (patch)
tree0515480dd7d509dca5e0a7e2b714b6e1bdf29573 /spec/controllers
parentf011b86beb89557afdaf2b0ec5ae904d0be237d8 (diff)
downloadgitlab-ce-85fab13ebaf10982c0957daca0afd1ea145e64df.tar.gz
Improved manual todos
Based on feedback from !4502
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/todo_controller_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/controllers/projects/todo_controller_spec.rb b/spec/controllers/projects/todo_controller_spec.rb
new file mode 100644
index 00000000000..ce9c57873fc
--- /dev/null
+++ b/spec/controllers/projects/todo_controller_spec.rb
@@ -0,0 +1,42 @@
+require('spec_helper')
+
+describe Projects::TodosController do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+ let(:issue) { create(:issue, project: project) }
+
+ describe 'POST #create' do
+ before do
+ sign_in(user)
+ project.team << [user, :developer]
+ end
+
+ it 'should create todo for issue' do
+ expect do
+ post(:create, namespace_id: project.namespace.path,
+ project_id: project.path,
+ issuable_id: issue.id,
+ issuable_type: "issue")
+ end.to change { user.todos.count }.by(1)
+
+ expect(response.status).to eq(200)
+ end
+ end
+
+ describe 'POST #create when not authorized' do
+ before do
+ sign_in(user)
+ end
+
+ it 'should create todo for issue' do
+ expect do
+ post(:create, namespace_id: project.namespace.path,
+ project_id: project.path,
+ issuable_id: issue.id,
+ issuable_type: "issue")
+ end.to change { user.todos.count }.by(0)
+
+ expect(response.status).to eq(404)
+ end
+ end
+end