Commit 60b40492 authored by Phil Hughes's avatar Phil Hughes

Added todo controller tests for merge requests

parent 7c95dc41
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
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