Commit 5dc7222b authored by Steve Azzopardi's avatar Steve Azzopardi

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

CE upstream - 2018-12-04 15:22 UTC

See merge request gitlab-org/gitlab-ee!8699
parents b5ee3590 58d4233e
...@@ -845,7 +845,7 @@ gitlab:assets:compile: ...@@ -845,7 +845,7 @@ gitlab:assets:compile:
only: only:
- //@gitlab-org/gitlab-ce - //@gitlab-org/gitlab-ce
- //@gitlab-org/gitlab-ee - //@gitlab-org/gitlab-ee
- //@gitlab/gitabhq - //@gitlab/gitlabhq
- //@gitlab/gitlab-ee - //@gitlab/gitlab-ee
tags: tags:
- gitlab-org-delivery - gitlab-org-delivery
......
...@@ -371,10 +371,10 @@ $note-form-margin-left: 72px; ...@@ -371,10 +371,10 @@ $note-form-margin-left: 72px;
&::after { &::after {
content: ''; content: '';
width: 100%;
height: 70px; height: 70px;
position: absolute; position: absolute;
left: 0; left: $gl-padding-24;
right: 0;
bottom: 0; bottom: 0;
background: linear-gradient(rgba($white-light, 0.1) -100px, $white-light 100%); background: linear-gradient(rgba($white-light, 0.1) -100px, $white-light 100%);
} }
......
...@@ -91,7 +91,7 @@ module IssuableCollections ...@@ -91,7 +91,7 @@ module IssuableCollections
options = { options = {
scope: params[:scope], scope: params[:scope],
state: params[:state], state: params[:state],
sort: set_sort_order_from_cookie || default_sort_order sort: set_sort_order
} }
# Used by view to highlight active option # Used by view to highlight active option
...@@ -113,6 +113,32 @@ module IssuableCollections ...@@ -113,6 +113,32 @@ module IssuableCollections
'opened' 'opened'
end end
def set_sort_order
set_sort_order_from_user_preference || set_sort_order_from_cookie || default_sort_order
end
def set_sort_order_from_user_preference
return unless current_user
return unless issuable_sorting_field
user_preference = current_user.user_preference
sort_param = params[:sort]
sort_param ||= user_preference[issuable_sorting_field]
if user_preference[issuable_sorting_field] != sort_param
user_preference.update_attribute(issuable_sorting_field, sort_param)
end
sort_param
end
# Implement default_sorting_field method on controllers
# to choose which column to store the sorting parameter.
def issuable_sorting_field
nil
end
def set_sort_order_from_cookie def set_sort_order_from_cookie
sort_param = params[:sort] if params[:sort].present? sort_param = params[:sort] if params[:sort].present?
# fallback to legacy cookie value for backward compatibility # fallback to legacy cookie value for backward compatibility
......
...@@ -47,6 +47,11 @@ module TokenAuthenticatable ...@@ -47,6 +47,11 @@ module TokenAuthenticatable
define_method("reset_#{token_field}!") do define_method("reset_#{token_field}!") do
strategy.reset_token!(self) strategy.reset_token!(self)
end end
define_method("#{token_field}_matches?") do |other_token|
token = read_attribute(token_field)
token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(other_token, token)
end
end end
def token_authenticatable_fields def token_authenticatable_fields
......
---
title: Fix multiple commits shade overlapping vertical discussion line
merge_request: 23515
author:
type: fixed
...@@ -43,7 +43,7 @@ are very appreciative of the work done by translators and proofreaders! ...@@ -43,7 +43,7 @@ are very appreciative of the work done by translators and proofreaders!
- Greek - Greek
- Proofreaders needed. - Proofreaders needed.
- Hebrew - Hebrew
- Proofreaders needed. - Yaron Shahrabani - [GitLab](https://gitlab.com/yarons), [Crowdin](https://crowdin.com/profile/YaronSh)
- Hungarian - Hungarian
- Proofreaders needed. - Proofreaders needed.
- Indonesian - Indonesian
......
...@@ -86,6 +86,7 @@ describe IssuableCollections do ...@@ -86,6 +86,7 @@ describe IssuableCollections do
it 'only allows whitelisted params' do it 'only allows whitelisted params' do
allow(controller).to receive(:cookies).and_return({}) allow(controller).to receive(:cookies).and_return({})
allow(controller).to receive(:current_user).and_return(nil)
finder_options = controller.send(:finder_options) finder_options = controller.send(:finder_options)
......
...@@ -15,6 +15,8 @@ describe Ci::BuildMetadata do ...@@ -15,6 +15,8 @@ describe Ci::BuildMetadata do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:build) { create(:ci_build, pipeline: pipeline) }
let(:build_metadata) { build.metadata } let(:build_metadata) { build.metadata }
it_behaves_like 'having unique enum values'
describe '#update_timeout_state' do describe '#update_timeout_state' do
subject { build_metadata } subject { build_metadata }
......
...@@ -12,6 +12,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -12,6 +12,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
described_class.new(build: build, chunk_index: chunk_index, data_store: data_store, raw_data: raw_data) described_class.new(build: build, chunk_index: chunk_index, data_store: data_store, raw_data: raw_data)
end end
it_behaves_like 'having unique enum values'
before do before do
stub_feature_flags(ci_enable_live_trace: true) stub_feature_flags(ci_enable_live_trace: true)
stub_artifacts_object_storage stub_artifacts_object_storage
......
...@@ -15,6 +15,8 @@ describe Ci::JobArtifact do ...@@ -15,6 +15,8 @@ describe Ci::JobArtifact do
it { is_expected.to delegate_method(:open).to(:file) } it { is_expected.to delegate_method(:open).to(:file) }
it { is_expected.to delegate_method(:exists?).to(:file) } it { is_expected.to delegate_method(:exists?).to(:file) }
it_behaves_like 'having unique enum values'
describe '.test_reports' do describe '.test_reports' do
subject { described_class.test_reports } subject { described_class.test_reports }
......
...@@ -8,6 +8,8 @@ describe Ci::Pipeline, :mailer do ...@@ -8,6 +8,8 @@ describe Ci::Pipeline, :mailer do
create(:ci_empty_pipeline, status: :created, project: project) create(:ci_empty_pipeline, status: :created, project: project)
end end
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:auto_canceled_by) } it { is_expected.to belong_to(:auto_canceled_by) }
...@@ -1282,6 +1284,23 @@ describe Ci::Pipeline, :mailer do ...@@ -1282,6 +1284,23 @@ describe Ci::Pipeline, :mailer do
end end
end end
context 'the source is the repository' do
let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
before do
pipeline.repository_source!
end
it 'returns the configuration if found' do
allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
.and_return('config')
expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil
end
end
context 'when pipeline is for auto-devops' do context 'when pipeline is for auto-devops' do
before do before do
pipeline.config_source = 'auto_devops_source' pipeline.config_source = 'auto_devops_source'
......
require 'spec_helper' require 'spec_helper'
describe Ci::Runner do describe Ci::Runner do
it_behaves_like 'having unique enum values'
describe 'validation' do describe 'validation' do
it { is_expected.to validate_presence_of(:access_level) } it { is_expected.to validate_presence_of(:access_level) }
it { is_expected.to validate_presence_of(:runner_type) } it { is_expected.to validate_presence_of(:runner_type) }
......
...@@ -3,6 +3,8 @@ require 'spec_helper' ...@@ -3,6 +3,8 @@ require 'spec_helper'
describe Ci::Stage, :models do describe Ci::Stage, :models do
let(:stage) { create(:ci_stage_entity) } let(:stage) { create(:ci_stage_entity) }
it_behaves_like 'having unique enum values'
describe 'associations' do describe 'associations' do
before do before do
create(:ci_build, stage_id: stage.id) create(:ci_build, stage_id: stage.id)
......
...@@ -3,6 +3,8 @@ require 'rails_helper' ...@@ -3,6 +3,8 @@ require 'rails_helper'
describe Clusters::Applications::Ingress do describe Clusters::Applications::Ingress do
let(:ingress) { create(:clusters_applications_ingress) } let(:ingress) { create(:clusters_applications_ingress) }
it_behaves_like 'having unique enum values'
include_examples 'cluster application core specs', :clusters_applications_ingress include_examples 'cluster application core specs', :clusters_applications_ingress
include_examples 'cluster application status specs', :clusters_applications_ingress include_examples 'cluster application status specs', :clusters_applications_ingress
include_examples 'cluster application helm specs', :clusters_applications_ingress include_examples 'cluster application helm specs', :clusters_applications_ingress
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Clusters::Cluster do describe Clusters::Cluster do
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:cluster_projects) } it { is_expected.to have_many(:cluster_projects) }
it { is_expected.to have_many(:projects) } it { is_expected.to have_many(:projects) }
......
...@@ -18,6 +18,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching ...@@ -18,6 +18,8 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to delegate_method(:managed?).to(:cluster) } it { is_expected.to delegate_method(:managed?).to(:cluster) }
it { is_expected.to delegate_method(:kubernetes_namespace).to(:cluster) } it { is_expected.to delegate_method(:kubernetes_namespace).to(:cluster) }
it_behaves_like 'having unique enum values'
describe 'before_validation' do describe 'before_validation' do
context 'when namespace includes upper case' do context 'when namespace includes upper case' do
let(:kubernetes) { create(:cluster_platform_kubernetes, :configured, namespace: namespace) } let(:kubernetes) { create(:cluster_platform_kubernetes, :configured, namespace: namespace) }
......
...@@ -13,6 +13,8 @@ describe CommitStatus do ...@@ -13,6 +13,8 @@ describe CommitStatus do
create(:commit_status, pipeline: pipeline, **opts) create(:commit_status, pipeline: pipeline, **opts)
end end
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:pipeline) } it { is_expected.to belong_to(:pipeline) }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
......
...@@ -16,6 +16,8 @@ describe Deployment do ...@@ -16,6 +16,8 @@ describe Deployment do
it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:ref) }
it { is_expected.to validate_presence_of(:sha) } it { is_expected.to validate_presence_of(:sha) }
it_behaves_like 'having unique enum values'
describe '#scheduled_actions' do describe '#scheduled_actions' do
subject { deployment.scheduled_actions } subject { deployment.scheduled_actions }
......
...@@ -8,6 +8,8 @@ RSpec.describe GpgSignature do ...@@ -8,6 +8,8 @@ RSpec.describe GpgSignature do
let(:gpg_key) { create(:gpg_key) } let(:gpg_key) { create(:gpg_key) }
let(:gpg_key_subkey) { create(:gpg_key_subkey) } let(:gpg_key_subkey) { create(:gpg_key_subkey) }
it_behaves_like 'having unique enum values'
describe 'associations' do describe 'associations' do
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:gpg_key) } it { is_expected.to belong_to(:gpg_key) }
......
...@@ -7,6 +7,8 @@ describe InternalId do ...@@ -7,6 +7,8 @@ describe InternalId do
let(:scope) { { project: project } } let(:scope) { { project: project } }
let(:init) { ->(s) { s.project.issues.size } } let(:init) { ->(s) { s.project.issues.size } }
it_behaves_like 'having unique enum values'
context 'validations' do context 'validations' do
it { is_expected.to validate_presence_of(:usage) } it { is_expected.to validate_presence_of(:usage) }
end end
......
require 'rails_helper' require 'rails_helper'
describe List do describe List do
it_behaves_like 'having unique enum values'
describe 'relationships' do describe 'relationships' do
it { is_expected.to belong_to(:board) } it { is_expected.to belong_to(:board) }
it { is_expected.to belong_to(:label) } it { is_expected.to belong_to(:label) }
......
require 'rails_helper' require 'rails_helper'
RSpec.describe NotificationSetting do RSpec.describe NotificationSetting do
it_behaves_like 'having unique enum values'
describe "Associations" do describe "Associations" do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:source) } it { is_expected.to belong_to(:source) }
......
...@@ -3,6 +3,8 @@ require 'spec_helper' ...@@ -3,6 +3,8 @@ require 'spec_helper'
describe ProjectAutoDevops do describe ProjectAutoDevops do
set(:project) { build(:project) } set(:project) { build(:project) }
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
it { is_expected.to define_enum_for(:deploy_strategy) } it { is_expected.to define_enum_for(:deploy_strategy) }
......
...@@ -4,6 +4,8 @@ describe Project do ...@@ -4,6 +4,8 @@ describe Project do
include ProjectForksHelper include ProjectForksHelper
include GitHelpers include GitHelpers
it_behaves_like 'having unique enum values'
describe 'associations' do describe 'associations' do
it { is_expected.to belong_to(:group) } it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:namespace) } it { is_expected.to belong_to(:namespace) }
......
...@@ -6,6 +6,8 @@ describe PrometheusMetric do ...@@ -6,6 +6,8 @@ describe PrometheusMetric do
subject { build(:prometheus_metric) } subject { build(:prometheus_metric) }
let(:other_project) { build(:project) } let(:other_project) { build(:project) }
it_behaves_like 'having unique enum values'
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_presence_of(:query) } it { is_expected.to validate_presence_of(:query) }
......
require 'spec_helper' require 'spec_helper'
describe PushEventPayload do describe PushEventPayload do
it_behaves_like 'having unique enum values'
describe 'saving payloads' do describe 'saving payloads' do
it 'does not allow commit messages longer than 70 characters' do it 'does not allow commit messages longer than 70 characters' do
event = create(:push_event) event = create(:push_event)
......
...@@ -7,6 +7,8 @@ RSpec.describe ResourceLabelEvent, type: :model do ...@@ -7,6 +7,8 @@ RSpec.describe ResourceLabelEvent, type: :model do
let(:issue) { create(:issue) } let(:issue) { create(:issue) }
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
it_behaves_like 'having unique enum values'
describe 'associations' do describe 'associations' do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:issue) } it { is_expected.to belong_to(:issue) }
......
...@@ -3,6 +3,8 @@ require 'rails_helper' ...@@ -3,6 +3,8 @@ require 'rails_helper'
describe UserCallout do describe UserCallout do
let!(:callout) { create(:user_callout) } let!(:callout) { create(:user_callout) }
it_behaves_like 'having unique enum values'
describe 'relationships' do describe 'relationships' do
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
end end
......
...@@ -4,6 +4,8 @@ describe User do ...@@ -4,6 +4,8 @@ describe User do
include ProjectForksHelper include ProjectForksHelper
include TermsHelper include TermsHelper
it_behaves_like 'having unique enum values'
describe 'modules' do describe 'modules' do
subject { described_class } subject { described_class }
......
# frozen_string_literal: true
shared_examples 'having unique enum values' do
described_class.defined_enums.each do |name, enum|
it "has unique values in #{name.inspect}" do
duplicated = enum.group_by(&:last).select { |key, value| value.size > 1 }
expect(duplicated).to be_empty,
"Duplicated values detected: #{duplicated.values.map(&Hash.method(:[]))}"
end
end
end
...@@ -41,6 +41,11 @@ module StubConfiguration ...@@ -41,6 +41,11 @@ module StubConfiguration
allow(Gitlab.config.gitlab).to receive_messages(to_settings(messages)) allow(Gitlab.config.gitlab).to receive_messages(to_settings(messages))
end end
def stub_default_url_options(host: "localhost", protocol: "http")
url_options = { host: host, protocol: protocol }
allow(Rails.application.routes).to receive(:default_url_options).and_return(url_options)
end
def stub_gravatar_setting(messages) def stub_gravatar_setting(messages)
allow(Gitlab.config.gravatar).to receive_messages(to_settings(messages)) allow(Gitlab.config.gravatar).to receive_messages(to_settings(messages))
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