提交 905a2993 编写于 作者: G George Andrinopoulos

Fix json response in branches controller

上级 a69aa3da
......@@ -20,7 +20,7 @@ class Projects::BranchesController < Projects::ApplicationController
respond_to do |format|
format.html
format.json do
render json: @repository.branch_names
render json: @branches.map(&:name)
end
end
end
......
---
title: Fix json response in branches controller
merge_request: 9710
author: George Andrinopoulos
......@@ -244,4 +244,27 @@ describe Projects::BranchesController do
end
end
end
describe "GET index" do
render_views
before do
sign_in(user)
end
context 'when rendering a JSON format' do
it 'filters branches by name' do
get :index,
namespace_id: project.namespace,
project_id: project,
format: :json,
search: 'master'
parsed_response = JSON.parse(response.body)
expect(parsed_response.length).to eq 1
expect(parsed_response.first).to eq 'master'
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册