Commit 905a2993 authored by George Andrinopoulos's avatar George Andrinopoulos

Fix json response in branches controller

parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment