diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-08-31 21:18:35 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-08-31 21:18:35 +0300 |
commit | 02fed9a905b65fb9b2a0d61500b51d44cd24ba28 (patch) | |
tree | 011068f576b9df4f3f50bd3c5bc9e4329308b5e4 /spec | |
parent | 8077b728bc26e9ece8055b8301033238ddbdf3f5 (diff) |
Backport specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/boards/issues_controller_spec.rb | 32 | ||||
-rw-r--r-- | spec/controllers/boards/lists_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/factories/milestones.rb | 4 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/issue.json | 5 | ||||
-rw-r--r-- | spec/services/boards/issues/create_service_spec.rb | 2 |
5 files changed, 34 insertions, 11 deletions
diff --git a/spec/controllers/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb index 3f6c1092163..dfa06c78d46 100644 --- a/spec/controllers/boards/issues_controller_spec.rb +++ b/spec/controllers/boards/issues_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::Boards::IssuesController do +describe Boards::IssuesController do let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } @@ -133,6 +133,22 @@ describe Projects::Boards::IssuesController do expect(response).to have_http_status(404) 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 context 'with unauthorized user' do @@ -146,17 +162,15 @@ describe Projects::Boards::IssuesController do def create_issue(user:, board:, list:, title:) sign_in(user) - post :create, namespace_id: project.namespace.to_param, - project_id: project, - board_id: board.to_param, + post :create, board_id: board.to_param, list_id: list.to_param, - issue: { title: title }, + issue: { title: title, project_id: project.id }, format: :json end end 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 it 'returns a successful 200 response' do @@ -186,7 +200,7 @@ describe Projects::Boards::IssuesController do end 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) end @@ -210,9 +224,9 @@ describe Projects::Boards::IssuesController do sign_in(user) patch :update, namespace_id: project.namespace.to_param, - project_id: project, + project_id: project.id, board_id: board.to_param, - id: issue.to_param, + id: issue.id, from_list_id: from_list_id, to_list_id: to_list_id, format: :json diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb index 65beec16307..b11fce0fa58 100644 --- a/spec/controllers/boards/lists_controller_spec.rb +++ b/spec/controllers/boards/lists_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::Boards::ListsController do +describe Boards::ListsController do let(:project) { create(:project) } let(:board) { create(:board, project: project) } let(:user) { create(:user) } diff --git a/spec/factories/milestones.rb b/spec/factories/milestones.rb index 2f75bf12cd7..b5298b2f969 100644 --- a/spec/factories/milestones.rb +++ b/spec/factories/milestones.rb @@ -7,6 +7,7 @@ FactoryGirl.define do group nil project_id nil group_id nil + parent nil end trait :active do @@ -26,6 +27,9 @@ FactoryGirl.define do milestone.project = evaluator.project elsif 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 milestone.project = create(:project) end diff --git a/spec/fixtures/api/schemas/issue.json b/spec/fixtures/api/schemas/issue.json index b9d2d5befbb..e1f62508933 100644 --- a/spec/fixtures/api/schemas/issue.json +++ b/spec/fixtures/api/schemas/issue.json @@ -8,10 +8,15 @@ "properties" : { "id": { "type": "integer" }, "iid": { "type": "integer" }, + "project_id": { "type": ["integer", "null"] }, "title": { "type": "string" }, "confidential": { "type": "boolean" }, "due_date": { "type": ["date", "null"] }, "relative_position": { "type": "integer" }, + "project": { + "id": { "type": "integer" }, + "path": { "type": "string" } + }, "labels": { "type": "array", "items": { diff --git a/spec/services/boards/issues/create_service_spec.rb b/spec/services/boards/issues/create_service_spec.rb index f2ddaa903da..1a56164dba4 100644 --- a/spec/services/boards/issues/create_service_spec.rb +++ b/spec/services/boards/issues/create_service_spec.rb @@ -8,7 +8,7 @@ describe Boards::Issues::CreateService do let(:label) { create(:label, project: project, name: 'in-progress') } 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 project.team << [user, :developer] |