Commit ae8a0665 authored by Sean McGivern's avatar Sean McGivern

Merge branch '28898-fix-search-branches-in-cherry-picking' into 'master'

Fix json response in branches controller

Closes #28898

See merge request !9710
parents 633aaf2b 905a2993
......@@ -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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment