Commit 02fed9a9 authored by Felipe Artur's avatar Felipe Artur

Backport specs

parent 8077b728
require 'spec_helper' require 'spec_helper'
describe Projects::Boards::IssuesController do describe Boards::IssuesController do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:board) { create(:board, project: project) } let(:board) { create(:board, project: project) }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -133,6 +133,22 @@ describe Projects::Boards::IssuesController do ...@@ -133,6 +133,22 @@ describe Projects::Boards::IssuesController do
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
end end
context 'with invalid board id' do
it 'returns a not found 404 response' do
create_issue user: user, board: 999, list: list1, title: 'New issue'
expect(response).to have_http_status(404)
end
end
context 'with invalid list id' do
it 'returns a not found 404 response' do
create_issue user: user, board: board, list: 999, title: 'New issue'
expect(response).to have_http_status(404)
end
end
end end
context 'with unauthorized user' do context 'with unauthorized user' do
...@@ -146,17 +162,15 @@ describe Projects::Boards::IssuesController do ...@@ -146,17 +162,15 @@ describe Projects::Boards::IssuesController do
def create_issue(user:, board:, list:, title:) def create_issue(user:, board:, list:, title:)
sign_in(user) sign_in(user)
post :create, namespace_id: project.namespace.to_param, post :create, board_id: board.to_param,
project_id: project,
board_id: board.to_param,
list_id: list.to_param, list_id: list.to_param,
issue: { title: title }, issue: { title: title, project_id: project.id },
format: :json format: :json
end end
end end
describe 'PATCH update' do describe 'PATCH update' do
let(:issue) { create(:labeled_issue, project: project, labels: [planning]) } let!(:issue) { create(:labeled_issue, project: project, labels: [planning]) }
context 'with valid params' do context 'with valid params' do
it 'returns a successful 200 response' do it 'returns a successful 200 response' do
...@@ -186,7 +200,7 @@ describe Projects::Boards::IssuesController do ...@@ -186,7 +200,7 @@ describe Projects::Boards::IssuesController do
end end
it 'returns a not found 404 response for invalid issue id' do it 'returns a not found 404 response for invalid issue id' do
move user: user, board: board, issue: 999, from_list_id: list1.id, to_list_id: list2.id move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
...@@ -210,9 +224,9 @@ describe Projects::Boards::IssuesController do ...@@ -210,9 +224,9 @@ describe Projects::Boards::IssuesController do
sign_in(user) sign_in(user)
patch :update, namespace_id: project.namespace.to_param, patch :update, namespace_id: project.namespace.to_param,
project_id: project, project_id: project.id,
board_id: board.to_param, board_id: board.to_param,
id: issue.to_param, id: issue.id,
from_list_id: from_list_id, from_list_id: from_list_id,
to_list_id: to_list_id, to_list_id: to_list_id,
format: :json format: :json
......
require 'spec_helper' require 'spec_helper'
describe Projects::Boards::ListsController do describe Boards::ListsController do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:board) { create(:board, project: project) } let(:board) { create(:board, project: project) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -7,6 +7,7 @@ FactoryGirl.define do ...@@ -7,6 +7,7 @@ FactoryGirl.define do
group nil group nil
project_id nil project_id nil
group_id nil group_id nil
parent nil
end end
trait :active do trait :active do
...@@ -26,6 +27,9 @@ FactoryGirl.define do ...@@ -26,6 +27,9 @@ FactoryGirl.define do
milestone.project = evaluator.project milestone.project = evaluator.project
elsif evaluator.project_id elsif evaluator.project_id
milestone.project_id = evaluator.project_id milestone.project_id = evaluator.project_id
elsif evaluator.parent
id = evaluator.parent.id
evaluator.parent.is_a?(Group) ? board.group_id = id : evaluator.project_id = id
else else
milestone.project = create(:project) milestone.project = create(:project)
end end
......
...@@ -8,10 +8,15 @@ ...@@ -8,10 +8,15 @@
"properties" : { "properties" : {
"id": { "type": "integer" }, "id": { "type": "integer" },
"iid": { "type": "integer" }, "iid": { "type": "integer" },
"project_id": { "type": ["integer", "null"] },
"title": { "type": "string" }, "title": { "type": "string" },
"confidential": { "type": "boolean" }, "confidential": { "type": "boolean" },
"due_date": { "type": ["date", "null"] }, "due_date": { "type": ["date", "null"] },
"relative_position": { "type": "integer" }, "relative_position": { "type": "integer" },
"project": {
"id": { "type": "integer" },
"path": { "type": "string" }
},
"labels": { "labels": {
"type": "array", "type": "array",
"items": { "items": {
......
...@@ -8,7 +8,7 @@ describe Boards::Issues::CreateService do ...@@ -8,7 +8,7 @@ describe Boards::Issues::CreateService do
let(:label) { create(:label, project: project, name: 'in-progress') } let(:label) { create(:label, project: project, name: 'in-progress') }
let!(:list) { create(:list, board: board, label: label, position: 0) } let!(:list) { create(:list, board: board, label: label, position: 0) }
subject(:service) { described_class.new(project, user, board_id: board.id, list_id: list.id, title: 'New issue') } subject(:service) { described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }
before do before do
project.team << [user, :developer] project.team << [user, :developer]
......
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