summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/board_issues_controller_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/controllers/projects/board_issues_controller_spec.rb b/spec/controllers/projects/board_issues_controller_spec.rb
new file mode 100644
index 00000000000..64c98443caa
--- /dev/null
+++ b/spec/controllers/projects/board_issues_controller_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe Projects::BoardIssuesController do
+ let(:project) { create(:project_with_board) }
+ let(:user) { create(:user) }
+
+ before do
+ project.team << [user, :master]
+ sign_in(user)
+ end
+
+ describe 'GET #index' do
+ context 'with valid list id' do
+ it 'returns issues that have the list label applied' do
+ label1 = create(:label, project: project, name: 'Planning')
+ label2 = create(:label, project: project, name: 'Development')
+
+ create(:labeled_issue, project: project, labels: [label1])
+ create(:labeled_issue, project: project, labels: [label2])
+ create(:labeled_issue, project: project, labels: [label2])
+
+ create(:list, board: project.board, label: label1, position: 1)
+ development = create(:list, board: project.board, label: label2, position: 2)
+
+ get :index, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ list_id: development.to_param
+
+ parsed_response = JSON.parse(response.body)
+
+ expect(response).to match_response_schema('issue', array: true)
+ expect(parsed_response.length).to eq 2
+ end
+ end
+
+ context 'with invalid list id' do
+ it 'returns a not found 404 response' do
+ get :index, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: 999
+
+ expect(response).to have_http_status(404)
+ end
+ end
+ end
+end