Commit f7c55b83 authored by GitLab Bot's avatar GitLab Bot

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

parents 87aef527 f8568baa
......@@ -1021,3 +1021,15 @@ gitlab_git_test:
cache: {}
script:
- spec/support/prepare-gitlab-git-test-for-commit --check-for-changes
no_ee_check:
<<: *dedicated-runner
<<: *except-docs-and-qa
variables:
SETUP_DB: "false"
before_script: []
cache: {}
script:
- scripts/no-ee-check
only:
- //@gitlab-org/gitlab-ce
......@@ -309,7 +309,7 @@ group :metrics do
gem 'influxdb', '~> 0.2', require: false
# Prometheus
gem 'prometheus-client-mmap', '~> 0.9.2'
gem 'prometheus-client-mmap', '~> 0.9.3'
gem 'raindrops', '~> 0.18'
end
......
......@@ -658,7 +658,7 @@ GEM
parser
unparser
procto (0.0.3)
prometheus-client-mmap (0.9.2)
prometheus-client-mmap (0.9.3)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
......@@ -1152,7 +1152,7 @@ DEPENDENCIES
peek-sidekiq (~> 1.0.3)
pg (~> 0.18.2)
premailer-rails (~> 1.9.7)
prometheus-client-mmap (~> 0.9.2)
prometheus-client-mmap (~> 0.9.3)
pry-byebug (~> 3.4.1)
pry-rails (~> 0.3.4)
rack-attack (~> 4.4.1)
......
......@@ -333,6 +333,10 @@
&.invalid {
@include status-color($gray-dark, $gray, $gray-darkest);
border-color: $gray-darkest;
&:not(span):hover {
color: $gray;
}
}
}
......
......@@ -603,7 +603,7 @@ class Repository
cache_method :gitlab_ci_yml
def xcode_project?
file_on_head(:xcode_config).present?
file_on_head(:xcode_config, :tree).present?
end
cache_method :xcode_project?
......@@ -969,11 +969,21 @@ class Repository
end
end
def file_on_head(type)
if head = tree(:head)
head.blobs.find do |blob|
Gitlab::FileDetector.type_of(blob.path) == type
def file_on_head(type, object_type = :blob)
return unless head = tree(:head)
objects =
case object_type
when :blob
head.blobs
when :tree
head.trees
else
raise ArgumentError, "Object type #{object_type} is not supported"
end
objects.find do |object|
Gitlab::FileDetector.type_of(object.path) == type
end
end
......
......@@ -167,8 +167,7 @@ class User < ActiveRecord::Base
validate :signup_domain_valid?, on: :create, if: ->(user) { !user.created_by_id }
before_validation :sanitize_attrs
before_validation :set_notification_email, if: :email_changed?
before_save :set_notification_email, if: :email_changed? # in case validation is skipped
before_validation :set_notification_email, if: :new_record?
before_validation :set_public_email, if: :public_email_changed?
before_save :set_public_email, if: :public_email_changed? # in case validation is skipped
before_save :ensure_incoming_email_token
......@@ -181,8 +180,21 @@ class User < ActiveRecord::Base
after_update :username_changed_hook, if: :username_changed?
after_destroy :post_destroy_hook
after_destroy :remove_key_cache
after_commit :update_emails_with_primary_email, on: :update, if: -> { previous_changes.key?('email') }
after_commit :update_invalid_gpg_signatures, on: :update, if: -> { previous_changes.key?('email') }
after_commit(on: :update) do
if previous_changes.key?('email')
# Grab previous_email here since previous_changes changes after
# #update_emails_with_primary_email and #update_notification_email are called
previous_email = previous_changes[:email][0]
update_emails_with_primary_email(previous_email)
update_invalid_gpg_signatures
if previous_email == notification_email
self.notification_email = email
save
end
end
end
after_initialize :set_projects_limit
......@@ -564,8 +576,7 @@ class User < ActiveRecord::Base
# hash and `_was` variables getting munged.
# By using an `after_commit` instead of `after_update`, we avoid the recursive callback
# scenario, though it then requires us to use the `previous_changes` hash
def update_emails_with_primary_email
previous_email = previous_changes[:email][0] # grab this before the DestroyService is called
def update_emails_with_primary_email(previous_email)
primary_email_record = emails.find_by(email: email)
Emails::DestroyService.new(self, user: self).execute(primary_email_record) if primary_email_record
......@@ -790,13 +801,13 @@ class User < ActiveRecord::Base
end
def set_notification_email
if notification_email.blank? || !all_emails.include?(notification_email)
if notification_email.blank? || all_emails.exclude?(notification_email)
self.notification_email = email
end
end
def set_public_email
if public_email.blank? || !all_emails.include?(public_email)
if public_email.blank? || all_emails.exclude?(public_email)
self.public_email = ''
end
end
......
---
title: Fix an issue where the notification email address would be set to an unconfirmed
email address
merge_request: 18474
author:
type: fixed
---
title: Increase text limit for GPG keys (mysql only).
merge_request: 19069
author:
type: other
---
title: Unverified hover state color changed to black
merge_request:
author:
type: fixed
---
title: Bump prometheus-client-mmap to 0.9.3 to fix nil exception error
merge_request:
author:
type: fixed
# rubocop:disable all
require_relative 'gpg_keys_limits_to_mysql'
class IncreaseMysqlTextLimitForGpgKeys < ActiveRecord::Migration
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
return unless Gitlab::Database.mysql?
change_column :gpg_keys, :key, :text, limit: 16.megabytes - 1
end
def down
# no-op
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180517082340) do
ActiveRecord::Schema.define(version: 20180521171529) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
......@@ -14,7 +14,7 @@ module Gitlab
avatar: /\Alogo\.(png|jpg|gif)\z/,
issue_template: %r{\A\.gitlab/issue_templates/[^/]+\.md\z},
merge_request_template: %r{\A\.gitlab/merge_request_templates/[^/]+\.md\z},
xcode_config: %r{\A[^/]*\.(xcodeproj|xcworkspace)\z},
xcode_config: %r{\A[^/]*\.(xcodeproj|xcworkspace)(/.+)?\z},
# Configuration files
gitignore: '.gitignore',
......
......@@ -2,6 +2,7 @@ require Rails.root.join('db/migrate/limits_to_mysql')
require Rails.root.join('db/migrate/markdown_cache_limits_to_mysql')
require Rails.root.join('db/migrate/merge_request_diff_file_limits_to_mysql')
require Rails.root.join('db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql')
require Rails.root.join('db/migrate/gpg_keys_limits_to_mysql')
desc "GitLab | Add limits to strings in mysql database"
task add_limits_mysql: :environment do
......@@ -10,4 +11,5 @@ task add_limits_mysql: :environment do
MarkdownCacheLimitsToMysql.new.up
MergeRequestDiffFileLimitsToMysql.new.up
LimitsCiBuildTraceChunksRawDataForMysql.new.up
IncreaseMysqlTextLimitForGpgKeys.new.up
end
#!/usr/bin/env ruby
ee_path = File.join(File.expand_path(__dir__), '../ee')
if Dir.exist?(ee_path)
puts 'The repository contains /ee directory. There should be no /ee directory in CE repo.'
exit 1
end
......@@ -2031,27 +2031,27 @@ describe Repository do
describe '#xcode_project?' do
before do
allow(repository).to receive(:tree).with(:head).and_return(double(:tree, blobs: [blob]))
allow(repository).to receive(:tree).with(:head).and_return(double(:tree, trees: [tree]))
end
context 'when the root contains a *.xcodeproj file' do
let(:blob) { double(:blob, path: 'Foo.xcodeproj') }
context 'when the root contains a *.xcodeproj directory' do
let(:tree) { double(:tree, path: 'Foo.xcodeproj') }
it 'returns true' do
expect(repository.xcode_project?).to be_truthy
end
end
context 'when the root contains a *.xcworkspace file' do
let(:blob) { double(:blob, path: 'Foo.xcworkspace') }
context 'when the root contains a *.xcworkspace directory' do
let(:tree) { double(:tree, path: 'Foo.xcworkspace') }
it 'returns true' do
expect(repository.xcode_project?).to be_truthy
end
end
context 'when the root contains no XCode config file' do
let(:blob) { double(:blob, path: 'subdir/Foo.xcworkspace') }
context 'when the root contains no Xcode config directory' do
let(:tree) { double(:tree, path: 'Foo') }
it 'returns false' do
expect(repository.xcode_project?).to be_falsey
......
......@@ -421,24 +421,6 @@ describe User do
end
describe 'after commit hook' do
describe '.update_invalid_gpg_signatures' do
let(:user) do
create(:user, email: 'tula.torphy@abshire.ca').tap do |user|
user.skip_reconfirmation!
end
end
it 'does nothing when the name is updated' do
expect(user).not_to receive(:update_invalid_gpg_signatures)
user.update_attributes!(name: 'Bette')
end
it 'synchronizes the gpg keys when the email is updated' do
expect(user).to receive(:update_invalid_gpg_signatures).at_most(:twice)
user.update_attributes!(email: 'shawnee.ritchie@denesik.com')
end
end
describe '#update_emails_with_primary_email' do
before do
@user = create(:user, email: 'primary@example.com').tap do |user|
......@@ -478,6 +460,76 @@ describe User do
expect(@user.emails.first.confirmed_at).not_to eq nil
end
end
describe '#update_notification_email' do
# Regression: https://gitlab.com/gitlab-org/gitlab-ce/issues/22846
context 'when changing :email' do
let(:user) { create(:user) }
let(:new_email) { 'new-email@example.com' }
it 'sets :unconfirmed_email' do
expect do
user.tap { |u| u.update!(email: new_email) }.reload
end.to change(user, :unconfirmed_email).to(new_email)
end
it 'does not change :notification_email' do
expect do
user.tap { |u| u.update!(email: new_email) }.reload
end.not_to change(user, :notification_email)
end
it 'updates :notification_email to the new email once confirmed' do
user.update!(email: new_email)
expect do
user.tap(&:confirm).reload
end.to change(user, :notification_email).to eq(new_email)
end
context 'and :notification_email is set to a secondary email' do
let!(:email_attrs) { attributes_for(:email, :confirmed, user: user) }
let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user) }
before do
user.emails.create(email_attrs)
user.tap { |u| u.update!(notification_email: email_attrs[:email]) }.reload
end
it 'does not change :notification_email to :email' do
expect do
user.tap { |u| u.update!(email: new_email) }.reload
end.not_to change(user, :notification_email)
end
it 'does not change :notification_email to :email once confirmed' do
user.update!(email: new_email)
expect do
user.tap(&:confirm).reload
end.not_to change(user, :notification_email)
end
end
end
end
describe '#update_invalid_gpg_signatures' do
let(:user) do
create(:user, email: 'tula.torphy@abshire.ca').tap do |user|
user.skip_reconfirmation!
end
end
it 'does nothing when the name is updated' do
expect(user).not_to receive(:update_invalid_gpg_signatures)
user.update_attributes!(name: 'Bette')
end
it 'synchronizes the gpg keys when the email is updated' do
expect(user).to receive(:update_invalid_gpg_signatures).at_most(:twice)
user.update_attributes!(email: 'shawnee.ritchie@denesik.com')
end
end
end
describe '#update_tracked_fields!', :clean_gitlab_redis_shared_state do
......
......@@ -499,10 +499,6 @@ describe API::Users do
describe "PUT /users/:id" do
let!(:admin_user) { create(:admin) }
before do
admin
end
it "updates user with new bio" do
put api("/users/#{user.id}", admin), { bio: 'new test bio' }
......@@ -539,27 +535,28 @@ describe API::Users do
expect(json_response['avatar_url']).to include(user.avatar_path)
end
it 'updates user with his own email' do
put api("/users/#{user.id}", admin), email: user.email
expect(response).to have_gitlab_http_status(200)
expect(json_response['email']).to eq(user.email)
expect(user.reload.email).to eq(user.email)
end
it 'updates user with a new email' do
old_email = user.email
old_notification_email = user.notification_email
put api("/users/#{user.id}", admin), email: 'new@email.com'
user.reload
expect(response).to have_gitlab_http_status(200)
expect(user.reload.notification_email).to eq('new@email.com')
expect(user).to be_confirmed
expect(user.email).to eq(old_email)
expect(user.notification_email).to eq(old_notification_email)
expect(user.unconfirmed_email).to eq('new@email.com')
end
it 'skips reconfirmation when requested' do
put api("/users/#{user.id}", admin), { skip_reconfirmation: true }
put api("/users/#{user.id}", admin), email: 'new@email.com', skip_reconfirmation: true
user.reload
expect(user.confirmed_at).to be_present
expect(response).to have_gitlab_http_status(200)
expect(user).to be_confirmed
expect(user.email).to eq('new@email.com')
end
it 'updates user with his own username' 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