Commit 09df8126 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-05-17

# Conflicts:
#	app/assets/javascripts/pipelines/components/graph/graph_component.vue
#	app/assets/javascripts/pipelines/components/graph/stage_column_component.vue
#	app/services/keys/destroy_service.rb

[ci skip]
parents ecb865ca 4609a126
...@@ -105,7 +105,10 @@ export default { ...@@ -105,7 +105,10 @@ export default {
:stage-connector-class="stageConnectorClass(index, stage)" :stage-connector-class="stageConnectorClass(index, stage)"
:is-first-column="isFirstColumn(index)" :is-first-column="isFirstColumn(index)"
@refreshPipelineGraph="refreshPipelineGraph" @refreshPipelineGraph="refreshPipelineGraph"
<<<<<<< HEAD
:has-triggered-by="hasTriggeredBy" :has-triggered-by="hasTriggeredBy"
=======
>>>>>>> upstream/master
/> />
</ul> </ul>
......
...@@ -29,11 +29,14 @@ export default { ...@@ -29,11 +29,14 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
<<<<<<< HEAD
hasTriggeredBy: { hasTriggeredBy: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
=======
>>>>>>> upstream/master
}, },
methods: { methods: {
......
...@@ -12,8 +12,8 @@ module Sortable ...@@ -12,8 +12,8 @@ module Sortable
scope :order_created_asc, -> { reorder(created_at: :asc) } scope :order_created_asc, -> { reorder(created_at: :asc) }
scope :order_updated_desc, -> { reorder(updated_at: :desc) } scope :order_updated_desc, -> { reorder(updated_at: :desc) }
scope :order_updated_asc, -> { reorder(updated_at: :asc) } scope :order_updated_asc, -> { reorder(updated_at: :asc) }
scope :order_name_asc, -> { reorder(name: :asc) } scope :order_name_asc, -> { reorder("lower(name) asc") }
scope :order_name_desc, -> { reorder(name: :desc) } scope :order_name_desc, -> { reorder("lower(name) desc") }
end end
module ClassMethods module ClassMethods
......
...@@ -53,6 +53,10 @@ module TimeTrackable ...@@ -53,6 +53,10 @@ module TimeTrackable
Gitlab::TimeTrackingFormatter.output(time_estimate) Gitlab::TimeTrackingFormatter.output(time_estimate)
end end
def time_estimate=(val)
val.is_a?(Integer) ? super([val, Gitlab::Database::MAX_INT_VALUE].min) : super(val)
end
private private
def touchable? def touchable?
......
module Keys module Keys
class DestroyService < ::Keys::BaseService class DestroyService < ::Keys::BaseService
<<<<<<< HEAD
prepend EE::Keys::DestroyService prepend EE::Keys::DestroyService
=======
>>>>>>> upstream/master
def execute(key) def execute(key)
key.destroy if destroy_possible?(key) key.destroy if destroy_possible?(key)
end end
......
---
title: Fixes 500 error on /estimate BIG_VALUE
merge_request: 18964
author: Jacopo Beschi @jacopo-beschi
type: fixed
---
title: "Use case in-sensitive ordering by name for dashboard"
merge_request: 18553
author: "@vedharish"
type: fixed
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class ProjectNameLowerIndex < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
INDEX_NAME = 'index_projects_on_lower_name'
disable_ddl_transaction!
def up
return unless Gitlab::Database.postgresql?
disable_statement_timeout
execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON projects (LOWER(name))"
end
def down
return unless Gitlab::Database.postgresql?
disable_statement_timeout
if supports_drop_index_concurrently?
execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}"
else
execute "DROP INDEX IF EXISTS #{INDEX_NAME}"
end
end
end
...@@ -8,6 +8,7 @@ task setup_postgresql: :environment do ...@@ -8,6 +8,7 @@ task setup_postgresql: :environment do
require Rails.root.join('db/migrate/20170503185032_index_redirect_routes_path_for_like') require Rails.root.join('db/migrate/20170503185032_index_redirect_routes_path_for_like')
require Rails.root.join('db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb') require Rails.root.join('db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb')
require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb') require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb')
require Rails.root.join('db/migrate/20180504195842_project_name_lower_index.rb')
require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb') require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb')
NamespacesProjectsPathLowerIndexes.new.up NamespacesProjectsPathLowerIndexes.new.up
...@@ -18,6 +19,7 @@ task setup_postgresql: :environment do ...@@ -18,6 +19,7 @@ task setup_postgresql: :environment do
IndexRedirectRoutesPathForLike.new.up IndexRedirectRoutesPathForLike.new.up
AddIndexOnNamespacesLowerName.new.up AddIndexOnNamespacesLowerName.new.up
UsersNameLowerIndex.new.up UsersNameLowerIndex.new.up
ProjectNameLowerIndex.new.up
AddPathIndexToRedirectRoutes.new.up AddPathIndexToRedirectRoutes.new.up
end end
......
...@@ -266,6 +266,19 @@ describe Issuable do ...@@ -266,6 +266,19 @@ describe Issuable do
end end
end end
describe '#time_estimate=' do
it 'coerces the value below Gitlab::Database::MAX_INT_VALUE' do
expect { issue.time_estimate = 100 }.to change { issue.time_estimate }.to(100)
expect { issue.time_estimate = Gitlab::Database::MAX_INT_VALUE + 100 }.to change { issue.time_estimate }.to(Gitlab::Database::MAX_INT_VALUE)
end
it 'skips coercion for not Integer values' do
expect { issue.time_estimate = nil }.to change { issue.time_estimate }.to(nil)
expect { issue.time_estimate = 'invalid time' }.not_to raise_error(StandardError)
expect { issue.time_estimate = 22.33 }.not_to raise_error(StandardError)
end
end
describe '#to_hook_data' do describe '#to_hook_data' do
let(:builder) { double } let(:builder) { double }
......
require 'spec_helper'
describe Sortable do
describe '.order_by' do
let(:relation) { Group.all }
describe 'ordering by id' do
it 'ascending' do
expect(relation).to receive(:reorder).with(id: :asc)
relation.order_by('id_asc')
end
it 'descending' do
expect(relation).to receive(:reorder).with(id: :desc)
relation.order_by('id_desc')
end
end
describe 'ordering by created day' do
it 'ascending' do
expect(relation).to receive(:reorder).with(created_at: :asc)
relation.order_by('created_asc')
end
it 'descending' do
expect(relation).to receive(:reorder).with(created_at: :desc)
relation.order_by('created_desc')
end
it 'order by "date"' do
expect(relation).to receive(:reorder).with(created_at: :desc)
relation.order_by('created_date')
end
end
describe 'ordering by name' do
it 'ascending' do
expect(relation).to receive(:reorder).with("lower(name) asc")
relation.order_by('name_asc')
end
it 'descending' do
expect(relation).to receive(:reorder).with("lower(name) desc")
relation.order_by('name_desc')
end
end
describe 'ordering by Updated Time' do
it 'ascending' do
expect(relation).to receive(:reorder).with(updated_at: :asc)
relation.order_by('updated_asc')
end
it 'descending' do
expect(relation).to receive(:reorder).with(updated_at: :desc)
relation.order_by('updated_desc')
end
end
it 'does not call reorder in case of unrecognized ordering' do
expect(relation).not_to receive(:reorder)
relation.order_by('random_ordering')
end
end
describe 'sorting groups' do
def ordered_group_names(order)
Group.all.order_by(order).map(&:name)
end
let!(:ref_time) { Time.parse('2018-05-01 00:00:00') }
let!(:group1) { create(:group, name: 'aa', id: 1, created_at: ref_time - 15.seconds, updated_at: ref_time) }
let!(:group2) { create(:group, name: 'AAA', id: 2, created_at: ref_time - 10.seconds, updated_at: ref_time - 5.seconds) }
let!(:group3) { create(:group, name: 'BB', id: 3, created_at: ref_time - 5.seconds, updated_at: ref_time - 10.seconds) }
let!(:group4) { create(:group, name: 'bbb', id: 4, created_at: ref_time, updated_at: ref_time - 15.seconds) }
it 'sorts groups by id' do
expect(ordered_group_names('id_asc')).to eq(%w(aa AAA BB bbb))
expect(ordered_group_names('id_desc')).to eq(%w(bbb BB AAA aa))
end
it 'sorts groups by name via case-insentitive comparision' do
expect(ordered_group_names('name_asc')).to eq(%w(aa AAA BB bbb))
expect(ordered_group_names('name_desc')).to eq(%w(bbb BB AAA aa))
end
it 'sorts groups by created_at' do
expect(ordered_group_names('created_asc')).to eq(%w(aa AAA BB bbb))
expect(ordered_group_names('created_desc')).to eq(%w(bbb BB AAA aa))
expect(ordered_group_names('created_date')).to eq(%w(bbb BB AAA aa))
end
it 'sorts groups by updated_at' do
expect(ordered_group_names('updated_asc')).to eq(%w(bbb BB AAA aa))
expect(ordered_group_names('updated_desc')).to eq(%w(aa AAA BB bbb))
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