Commit c105ce64 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ce-to-ee-2018-04-09' into 'master'

CE upstream - 2018-04-09 09:27 UTC

See merge request gitlab-org/gitlab-ee!5293
parents 48c538f0 f45b741a
...@@ -396,6 +396,7 @@ group :test do ...@@ -396,6 +396,7 @@ group :test do
gem 'email_spec', '~> 1.6.0' gem 'email_spec', '~> 1.6.0'
gem 'json-schema', '~> 2.8.0' gem 'json-schema', '~> 2.8.0'
gem 'webmock', '~> 2.3.2' gem 'webmock', '~> 2.3.2'
gem 'rails-controller-testing' if rails5? # Rails5 only gem.
gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0. gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0.
gem 'sham_rack', '~> 1.3.6' gem 'sham_rack', '~> 1.3.6'
gem 'concurrent-ruby', '~> 1.0.5' gem 'concurrent-ruby', '~> 1.0.5'
......
...@@ -678,6 +678,10 @@ GEM ...@@ -678,6 +678,10 @@ GEM
bundler (>= 1.3.0) bundler (>= 1.3.0)
railties (= 5.0.6) railties (= 5.0.6)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-deprecated_sanitizer (1.0.3) rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha) activesupport (>= 4.2.0.alpha)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
...@@ -1145,6 +1149,7 @@ DEPENDENCIES ...@@ -1145,6 +1149,7 @@ DEPENDENCIES
rack-oauth2 (~> 1.2.1) rack-oauth2 (~> 1.2.1)
rack-proxy (~> 0.6.0) rack-proxy (~> 0.6.0)
rails (= 5.0.6) rails (= 5.0.6)
rails-controller-testing
rails-deprecated_sanitizer (~> 1.0.3) rails-deprecated_sanitizer (~> 1.0.3)
rails-i18n (~> 5.1) rails-i18n (~> 5.1)
rainbow (~> 2.2) rainbow (~> 2.2)
......
...@@ -94,7 +94,7 @@ export default class FileTemplateMediator { ...@@ -94,7 +94,7 @@ export default class FileTemplateMediator {
const hash = urlPieces[1]; const hash = urlPieces[1];
if (hash === 'preview') { if (hash === 'preview') {
this.hideTemplateSelectorMenu(); this.hideTemplateSelectorMenu();
} else if (hash === 'editor') { } else if (hash === 'editor' && !this.typeSelector.isHidden()) {
this.showTemplateSelectorMenu(); this.showTemplateSelectorMenu();
} }
}); });
......
...@@ -32,6 +32,10 @@ export default class FileTemplateSelector { ...@@ -32,6 +32,10 @@ export default class FileTemplateSelector {
} }
} }
isHidden() {
return this.$wrapper.hasClass('hidden');
}
getToggleText() { getToggleText() {
return this.$dropdownToggleText.text(); return this.$dropdownToggleText.text();
} }
......
...@@ -16,8 +16,10 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -16,8 +16,10 @@ class Projects::RepositoriesController < Projects::ApplicationController
def archive def archive
append_sha = params[:append_sha] append_sha = params[:append_sha]
shortname = "#{@project.path}-#{@ref.tr('/', '-')}" if @ref
append_sha = false if @filename == shortname shortname = "#{@project.path}-#{@ref.tr('/', '-')}"
append_sha = false if @filename == shortname
end
send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha
rescue => ex rescue => ex
...@@ -27,6 +29,9 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -27,6 +29,9 @@ class Projects::RepositoriesController < Projects::ApplicationController
def assign_archive_vars def assign_archive_vars
@id = params[:id] @id = params[:id]
return unless @id
@ref, @filename = extract_ref(@id) @ref, @filename = extract_ref(@id)
rescue InvalidPathError rescue InvalidPathError
render_404 render_404
......
...@@ -207,7 +207,11 @@ class Service < ActiveRecord::Base ...@@ -207,7 +207,11 @@ class Service < ActiveRecord::Base
args.each do |arg| args.each do |arg|
class_eval %{ class_eval %{
def #{arg}? def #{arg}?
ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg}) if Gitlab.rails5?
!ActiveModel::Type::Boolean::FALSE_VALUES.include?(#{arg})
else
ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg})
end
end end
} }
end end
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- count = @existing_commits.size - count = @existing_commits.size
%ul %ul
%li %li
- if count.one? - if count == 1
- commit_id = @existing_commits.first[:short_id] - commit_id = @existing_commits.first[:short_id]
= link_to(commit_id, project_commit_url(@merge_request.target_project, commit_id)) = link_to(commit_id, project_commit_url(@merge_request.target_project, commit_id))
- else - else
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\ \
- if @existing_commits.any? - if @existing_commits.any?
- count = @existing_commits.size - count = @existing_commits.size
- commits_id = count.one? ? @existing_commits.first[:short_id] : "#{@existing_commits.first[:short_id]}...#{@existing_commits.last[:short_id]}" - commits_id = count == 1 ? @existing_commits.first[:short_id] : "#{@existing_commits.first[:short_id]}...#{@existing_commits.last[:short_id]}"
- commits_text = "#{count} commit".pluralize(count) - commits_text = "#{count} commit".pluralize(count)
* #{commits_id} - #{commits_text} from branch `#{@merge_request.target_branch}` * #{commits_id} - #{commits_text} from branch `#{@merge_request.target_branch}`
......
---
title: Fix template selector menu visibility when toggling preview mode in file edit
view
merge_request: 18118
author: Fabian Schneider
type: fixed
...@@ -34,6 +34,12 @@ describe Projects::RepositoriesController do ...@@ -34,6 +34,12 @@ describe Projects::RepositoriesController do
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end end
it 'handles legacy queries with no ref' do
get :archive, namespace_id: project.namespace, project_id: project, format: "zip"
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
context "when the service raises an error" do context "when the service raises an error" do
before do before do
allow(Gitlab::Workhorse).to receive(:send_git_archive).and_raise("Archive failed") allow(Gitlab::Workhorse).to receive(:send_git_archive).and_raise("Archive failed")
......
require 'spec_helper'
feature 'Template selector menu', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in user
end
context 'editing a non-matching file' do
before do
create_and_edit_file('README.md')
end
scenario 'is not displayed' do
check_template_selector_menu_display(false)
end
context 'user toggles preview' do
before do
click_link 'Preview'
end
scenario 'template selector menu is not displayed' do
check_template_selector_menu_display(false)
click_link 'Write'
check_template_selector_menu_display(false)
end
end
end
context 'editing a matching file' do
before do
visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
end
scenario 'is displayed' do
check_template_selector_menu_display(true)
end
context 'user toggles preview' do
before do
click_link 'Preview'
end
scenario 'template selector menu is hidden and shown correctly' do
check_template_selector_menu_display(false)
click_link 'Write'
check_template_selector_menu_display(true)
end
end
end
end
def check_template_selector_menu_display(is_visible)
count = is_visible ? 1 : 0
expect(page).to have_css('.template-selectors-menu', count: count)
end
def create_and_edit_file(file_name)
visit project_new_blob_path(project, 'master', file_name: file_name)
click_button "Commit changes"
visit project_edit_blob_path(project, File.join(project.default_branch, file_name))
end
...@@ -401,11 +401,11 @@ describe Notify do ...@@ -401,11 +401,11 @@ describe Notify do
end end
end end
describe 'that have new commits' do shared_examples 'a push to an existing merge request' do
let(:push_user) { create(:user) } let(:push_user) { create(:user) }
subject do subject do
described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits) described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits, existing_commits: existing_commits)
end end
it_behaves_like 'a multiple recipients email' it_behaves_like 'a multiple recipients email'
...@@ -430,6 +430,18 @@ describe Notify do ...@@ -430,6 +430,18 @@ describe Notify do
end end
end end
end end
describe 'that have new commits' do
let(:existing_commits) { [] }
it_behaves_like 'a push to an existing merge request'
end
describe 'that have new commits on top of an existing one' do
let(:existing_commits) { [merge_request.commits.first] }
it_behaves_like 'a push to an existing merge request'
end
end end
context 'for issue notes' do context 'for issue notes' do
......
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