diff options
author | Phil Hughes <me@iamphill.com> | 2016-06-17 09:13:21 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-06-17 09:13:21 +0100 |
commit | 60b4049280e631d186ecf17fac9c4228095f06b5 (patch) | |
tree | 9680a67bf51cac4faaa92fe566116e71950f36e0 /spec/controllers | |
parent | 7c95dc41ef133f4d8e1ec43ea9aab2ef537b9568 (diff) | |
download | gitlab-ce-60b4049280e631d186ecf17fac9c4228095f06b5.tar.gz |
Added todo controller tests for merge requests
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/todo_controller_spec.rb | 127 |
1 files changed, 90 insertions, 37 deletions
diff --git a/spec/controllers/projects/todo_controller_spec.rb b/spec/controllers/projects/todo_controller_spec.rb index ea554d99fc1..2160f0b802c 100644 --- a/spec/controllers/projects/todo_controller_spec.rb +++ b/spec/controllers/projects/todo_controller_spec.rb @@ -1,55 +1,108 @@ 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] + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:issue) { create(:issue, project: project) } + 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] + 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) + describe 'POST #create when not authorized' do + before do + sign_in(user) + end - expect(response.status).to eq(200) + 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) + end end end - describe 'POST #create when not authorized' do - before do - sign_in(user) + context 'Merge Requests' do + 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: 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: issue.id, - issuable_type: "issue") - end.to change { user.todos.count }.by(0) + describe 'POST #create when not authorized' do + before do + sign_in(user) + end - expect(response.status).to eq(404) + 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 - 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) + 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) + expect(response.status).to eq(302) + end end end end |