diff options
author | Phil Hughes <me@iamphill.com> | 2016-06-17 20:31:37 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-06-17 20:31:37 +0300 |
commit | 914f97310815365f083a38b02d8dbf6c99b63b5f (patch) | |
tree | 8c4d46a886616eb043c1c1c5d11da6685b59e741 /spec/controllers | |
parent | a210cd1f3763065e3ac8f8f2174b4c4a67a076c0 (diff) |
Removed update method
Re-structured controller spec
Renamed issuable param to issuable_id
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/todo_controller_spec.rb | 166 |
1 files changed, 80 insertions, 86 deletions
diff --git a/spec/controllers/projects/todo_controller_spec.rb b/spec/controllers/projects/todo_controller_spec.rb index 2160f0b802c..40a3403b660 100644 --- a/spec/controllers/projects/todo_controller_spec.rb +++ b/spec/controllers/projects/todo_controller_spec.rb @@ -7,101 +7,95 @@ describe Projects::TodosController do let(:merge_request) { create(:merge_request, source_project: project) } context 'Issues' do - describe 'POST #create' do - before do - sign_in(user) - project.team << [user, :developer] + describe 'POST create' do + context 'when authorized' 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 - 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 - - 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) + context 'when not authorized' do + it 'should not create todo for issue that user has no access to' do + sign_in(user) + 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 + + it 'should not create todo for issue when user not logged in' 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 context 'Merge Requests' do - describe 'POST #create' do - before do - sign_in(user) - project.team << [user, :developer] + describe 'POST create' do + context 'when authorized' do + before do + 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 - 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(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: merge_request.id, - issuable_type: "merge_request") - 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) + context 'when not authorized' do + it 'should not create todo for merge request user has no access to' do + sign_in(user) + 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(404) + end + + it 'should not create todo for merge request user has no access to' 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 |