Commit 914f9731 authored by Phil Hughes's avatar Phil Hughes

Removed update method

Re-structured controller spec
Renamed issuable param to issuable_id
parent a210cd1f
...@@ -63,7 +63,7 @@ class @Sidebar ...@@ -63,7 +63,7 @@ class @Sidebar
type: ajaxType type: ajaxType
dataType: 'json' dataType: 'json'
data: data:
issuable_id: $this.data('issuable') issuable_id: $this.data('issuable-id')
issuable_type: $this.data('issuable-type') issuable_type: $this.data('issuable-type')
beforeSend: => beforeSend: =>
@beforeTodoSend($this, $todoLoading) @beforeTodoSend($this, $todoLoading)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
%a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", aria: { label: "Toggle sidebar" } } %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", aria: { label: "Toggle sidebar" } }
= sidebar_gutter_toggle_icon = sidebar_gutter_toggle_icon
- if current_user - if current_user
%button.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo{ type: "button", aria: { label: (todo.nil? ? "Add Todo" : "Mark Done") }, data: { todo_text: "Add Todo", mark_text: "Mark Done", issuable: issuable.id, issuable_type: issuable.class.name.underscore, url: namespace_project_todos_path(@project.namespace, @project), delete_path: (dashboard_todo_path(todo) if todo) } } %button.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo{ type: "button", aria: { label: (todo.nil? ? "Add Todo" : "Mark Done") }, data: { todo_text: "Add Todo", mark_text: "Mark Done", issuable_id: issuable.id, issuable_type: issuable.class.name.underscore, url: namespace_project_todos_path(@project.namespace, @project), delete_path: (dashboard_todo_path(todo) if todo) } }
%span.js-issuable-todo-text %span.js-issuable-todo-text
- if todo - if todo
Mark Done Mark Done
......
...@@ -797,7 +797,7 @@ Rails.application.routes.draw do ...@@ -797,7 +797,7 @@ Rails.application.routes.draw do
end end
end end
resources :todos, only: [:create, :update] resources :todos, only: [:create]
resources :uploads, only: [:create] do resources :uploads, only: [:create] do
collection do collection do
......
...@@ -7,101 +7,95 @@ describe Projects::TodosController do ...@@ -7,101 +7,95 @@ describe Projects::TodosController do
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
context 'Issues' do context 'Issues' do
describe 'POST #create' do describe 'POST create' do
before do context 'when authorized' do
sign_in(user) before do
project.team << [user, :developer] 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 end
it 'should create todo for issue' do context 'when not authorized' do
expect do it 'should not create todo for issue that user has no access to' do
post(:create, namespace_id: project.namespace.path, sign_in(user)
project_id: project.path, expect do
issuable_id: issue.id, post(:create, namespace_id: project.namespace.path,
issuable_type: "issue") project_id: project.path,
end.to change { user.todos.count }.by(1) issuable_id: issue.id,
issuable_type: 'issue')
expect(response.status).to eq(200) end.to change { user.todos.count }.by(0)
end
end expect(response.status).to eq(404)
end
describe 'POST #create when not authorized' do
before do it 'should not create todo for issue when user not logged in' do
sign_in(user) expect do
end post(:create, namespace_id: project.namespace.path,
project_id: project.path,
it 'should create todo for issue' do issuable_id: issue.id,
expect do issuable_type: 'issue')
post(:create, namespace_id: project.namespace.path, end.to change { user.todos.count }.by(0)
project_id: project.path,
issuable_id: issue.id, expect(response.status).to eq(302)
issuable_type: "issue") end
end.to change { user.todos.count }.by(0)
expect(response.status).to eq(404)
end
end
describe 'POST #create when not logged in' do
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(302)
end end
end end
end end
context 'Merge Requests' do context 'Merge Requests' do
describe 'POST #create' do describe 'POST create' do
before do context 'when authorized' do
sign_in(user) before do
project.team << [user, :developer] sign_in(user)
project.team << [user, :developer]
end
it 'should create todo for merge request' do
expect do
post(:create, namespace_id: project.namespace.path,
project_id: project.path,
issuable_id: merge_request.id,
issuable_type: 'merge_request')
end.to change { user.todos.count }.by(1)
expect(response.status).to eq(200)
end
end end
it 'should create todo for issue' do context 'when not authorized' do
expect do it 'should not create todo for merge request user has no access to' do
post(:create, namespace_id: project.namespace.path, sign_in(user)
project_id: project.path, expect do
issuable_id: merge_request.id, post(:create, namespace_id: project.namespace.path,
issuable_type: "merge_request") project_id: project.path,
end.to change { user.todos.count }.by(1) issuable_id: merge_request.id,
issuable_type: 'merge_request')
expect(response.status).to eq(200) end.to change { user.todos.count }.by(0)
end
end expect(response.status).to eq(404)
end
describe 'POST #create when not authorized' do
before do it 'should not create todo for merge request user has no access to' do
sign_in(user) expect do
end post(:create, namespace_id: project.namespace.path,
project_id: project.path,
it 'should create todo for issue' do issuable_id: merge_request.id,
expect do issuable_type: 'merge_request')
post(:create, namespace_id: project.namespace.path, end.to change { user.todos.count }.by(0)
project_id: project.path,
issuable_id: merge_request.id, expect(response.status).to eq(302)
issuable_type: "merge_request") end
end.to change { user.todos.count }.by(0)
expect(response.status).to eq(404)
end
end
describe 'POST #create when not logged in' do
it 'should create todo for issue' do
expect do
post(:create, namespace_id: project.namespace.path,
project_id: project.path,
issuable_id: merge_request.id,
issuable_type: "merge_request")
end.to change { user.todos.count }.by(0)
expect(response.status).to eq(302)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment