From 59154779d81c6359428af5f5cbdedbbd7ed32d5c Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 20 Jun 2018 12:34:58 +0900 Subject: The json keys of ref switcher should not be translated --- app/controllers/projects_controller.rb | 4 ++-- changelogs/unreleased/48100-fix-branch-not-shown.yml | 6 ++++++ spec/controllers/projects_controller_spec.rb | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/48100-fix-branch-not-shown.yml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a93b116c6fe..efb30ba4715 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -247,13 +247,13 @@ class ProjectsController < Projects::ApplicationController if find_branches branches = BranchesFinder.new(@repository, params).execute.take(100).map(&:name) - options[s_('RefSwitcher|Branches')] = branches + options['Branches'] = branches end if find_tags && @repository.tag_count.nonzero? tags = TagsFinder.new(@repository, params).execute.take(100).map(&:name) - options[s_('RefSwitcher|Tags')] = tags + options['Tags'] = tags end # If reference is commit id - we should add it to branch/tag selectbox diff --git a/changelogs/unreleased/48100-fix-branch-not-shown.yml b/changelogs/unreleased/48100-fix-branch-not-shown.yml new file mode 100644 index 00000000000..917c5c23f67 --- /dev/null +++ b/changelogs/unreleased/48100-fix-branch-not-shown.yml @@ -0,0 +1,6 @@ +--- +title: Fix branches are not shown in Merge Request dropdown when preferred language + is not English +merge_request: 20016 +author: Hiroyuki Sato +type: fixed diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 705b30f0130..90e698925b6 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -597,6 +597,22 @@ describe ProjectsController do expect(parsed_body["Tags"]).to include("v1.0.0") expect(parsed_body["Commits"]).to include("123456") end + + context "when preferred language is Japanese" do + before do + user.update!(preferred_language: 'ja') + sign_in(user) + end + + it "gets a list of branches, tags and commits" do + get :refs, namespace_id: public_project.namespace, id: public_project, ref: "123456" + + parsed_body = JSON.parse(response.body) + expect(parsed_body["Branches"]).to include("master") + expect(parsed_body["Tags"]).to include("v1.0.0") + expect(parsed_body["Commits"]).to include("123456") + end + end end describe 'POST #preview_markdown' do -- cgit v1.2.1