Commit e0131c5d authored by Valery Sizov's avatar Valery Sizov

Merge branch 'rails_update_to_4_2' into 'master'

Rails update to 4.2.4

https://gitlab.com/gitlab-org/gitlab-ce/issues/2694

See merge request !1902
parents a8e05cec f1504e1a
source "https://rubygems.org" source "https://rubygems.org"
gem 'rails', '4.1.14' gem 'rails', '4.2.4'
gem 'rails-deprecated_sanitizer', '~> 1.0.3'
# Responders respond_to and respond_with
gem 'responders', '~> 2.0'
# Specify a sprockets version due to security issue # Specify a sprockets version due to security issue
# See https://groups.google.com/forum/#!topic/rubyonrails-security/doAVp0YaTqY # See https://groups.google.com/forum/#!topic/rubyonrails-security/doAVp0YaTqY
...@@ -95,6 +99,7 @@ gem 'org-ruby', '~> 0.9.12' ...@@ -95,6 +99,7 @@ gem 'org-ruby', '~> 0.9.12'
gem 'creole', '~> 0.5.0' gem 'creole', '~> 0.5.0'
gem 'wikicloth', '0.8.1' gem 'wikicloth', '0.8.1'
gem 'asciidoctor', '~> 1.5.2' gem 'asciidoctor', '~> 1.5.2'
gem 'net-ssh', '~> 3.0.1'
# Diffs # Diffs
gem 'diffy', '~> 3.0.3' gem 'diffy', '~> 3.0.3'
...@@ -210,6 +215,7 @@ group :development do ...@@ -210,6 +215,7 @@ group :development do
gem 'rerun', '~> 0.10.0' gem 'rerun', '~> 0.10.0'
gem 'bullet', require: false gem 'bullet', require: false
gem 'rblineprof', platform: :mri, require: false gem 'rblineprof', platform: :mri, require: false
gem 'web-console', '~> 2.0'
# Better errors handler # Better errors handler
gem 'better_errors', '~> 1.0.1' gem 'better_errors', '~> 1.0.1'
...@@ -266,7 +272,7 @@ group :test do ...@@ -266,7 +272,7 @@ group :test do
gem 'shoulda-matchers', '~> 2.8.0', require: false gem 'shoulda-matchers', '~> 2.8.0', require: false
gem 'email_spec', '~> 1.6.0' gem 'email_spec', '~> 1.6.0'
gem 'webmock', '~> 1.21.0' gem 'webmock', '~> 1.21.0'
gem 'test_after_commit', '~> 0.2.2' gem 'test_after_commit', '~> 0.4.2'
gem 'sham_rack' gem 'sham_rack'
end end
......
This diff is collapsed.
web: bundle exec unicorn_rails -p ${PORT:="3000"} -E ${RAILS_ENV:="development"} -c ${UNICORN_CONFIG:="config/unicorn.rb"} web: bundle exec unicorn_rails -p ${PORT:="3000"} -E ${RAILS_ENV:="development"} -c ${UNICORN_CONFIG:="config/unicorn.rb"}
worker: bundle exec sidekiq -q post_receive -q mailer -q archive_repo -q system_hook -q project_web_hook -q gitlab_shell -q incoming_email -q runner -q common -q default worker: bundle exec sidekiq -q post_receive -q mailer -q archive_repo -q system_hook -q project_web_hook -q gitlab_shell -q incoming_email -q runner -q common -q mailers -q default
# mail_room: bundle exec mail_room -q -c config/mail_room.yml # mail_room: bundle exec mail_room -q -c config/mail_room.yml
...@@ -10,7 +10,7 @@ class AbuseReportsController < ApplicationController ...@@ -10,7 +10,7 @@ class AbuseReportsController < ApplicationController
if @abuse_report.save if @abuse_report.save
if current_application_settings.admin_notification_email.present? if current_application_settings.admin_notification_email.present?
AbuseReportMailer.delay.notify(@abuse_report.id) AbuseReportMailer.notify(@abuse_report.id).deliver_later
end end
message = "Thank you for your report. A GitLab administrator will look into it shortly." message = "Thank you for your report. A GitLab administrator will look into it shortly."
......
...@@ -8,10 +8,6 @@ class BaseMailer < ActionMailer::Base ...@@ -8,10 +8,6 @@ class BaseMailer < ActionMailer::Base
default from: Proc.new { default_sender_address.format } default from: Proc.new { default_sender_address.format }
default reply_to: Proc.new { default_reply_to_address.format } default reply_to: Proc.new { default_reply_to_address.format }
def self.delay
delay_for(2.seconds)
end
def can? def can?
Ability.abilities.allowed?(current_user, action, subject) Ability.abilities.allowed?(current_user, action, subject)
end end
......
...@@ -64,9 +64,9 @@ module Ci ...@@ -64,9 +64,9 @@ module Ci
build.project_recipients.each do |recipient| build.project_recipients.each do |recipient|
case build.status.to_sym case build.status.to_sym
when :success when :success
mailer.build_success_email(build.id, recipient) mailer.build_success_email(build.id, recipient).deliver_later
when :failed when :failed
mailer.build_fail_email(build.id, recipient) mailer.build_fail_email(build.id, recipient).deliver_later
end end
end end
end end
...@@ -78,7 +78,7 @@ module Ci ...@@ -78,7 +78,7 @@ module Ci
end end
def mailer def mailer
Ci::Notify.delay Ci::Notify
end end
end end
end end
...@@ -55,7 +55,7 @@ class GitlabCiService < CiService ...@@ -55,7 +55,7 @@ class GitlabCiService < CiService
end end
def get_ci_commit(sha, ref) def get_ci_commit(sha, ref)
Ci::Project.find(project.gitlab_ci_project).commits.find_by_sha!(sha) Ci::Project.find(project.gitlab_ci_project.id).commits.find_by_sha!(sha)
end end
def commit_status(sha, ref) def commit_status(sha, ref)
......
...@@ -17,9 +17,8 @@ class SentNotification < ActiveRecord::Base ...@@ -17,9 +17,8 @@ class SentNotification < ActiveRecord::Base
belongs_to :noteable, polymorphic: true belongs_to :noteable, polymorphic: true
belongs_to :recipient, class_name: "User" belongs_to :recipient, class_name: "User"
validate :project, :recipient, :reply_key, presence: true validates :project, :recipient, :reply_key, presence: true
validate :reply_key, uniqueness: true validates :reply_key, uniqueness: true
validates :noteable_id, presence: true, unless: :for_commit? validates :noteable_id, presence: true, unless: :for_commit?
validates :commit_id, presence: true, if: :for_commit? validates :commit_id, presence: true, if: :for_commit?
validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
......
...@@ -13,14 +13,14 @@ class NotificationService ...@@ -13,14 +13,14 @@ class NotificationService
# even if user disabled notifications # even if user disabled notifications
def new_key(key) def new_key(key)
if key.user if key.user
mailer.new_ssh_key_email(key.id) mailer.new_ssh_key_email(key.id).deliver_later
end end
end end
# Always notify user about email added to profile # Always notify user about email added to profile
def new_email(email) def new_email(email)
if email.user if email.user
mailer.new_email_email(email.id) mailer.new_email_email(email.id).deliver_later
end end
end end
...@@ -79,17 +79,27 @@ class NotificationService ...@@ -79,17 +79,27 @@ class NotificationService
end end
def merge_mr(merge_request, current_user) def merge_mr(merge_request, current_user)
close_resource_email(merge_request, merge_request.target_project, current_user, 'merged_merge_request_email') close_resource_email(
merge_request,
merge_request.target_project,
current_user,
'merged_merge_request_email'
)
end end
def reopen_mr(merge_request, current_user) def reopen_mr(merge_request, current_user)
reopen_resource_email(merge_request, merge_request.target_project, current_user, 'merge_request_status_email', 'reopened') reopen_resource_email(
merge_request,
merge_request.target_project,
current_user, 'merge_request_status_email',
'reopened'
)
end end
# Notify new user with email after creation # Notify new user with email after creation
def new_user(user, token = nil) def new_user(user, token = nil)
# Don't email omniauth created users # Don't email omniauth created users
mailer.new_user_email(user.id, token) unless user.identities.any? mailer.new_user_email(user.id, token).deliver_later unless user.identities.any?
end end
# Notify users on new note in system # Notify users on new note in system
...@@ -138,50 +148,59 @@ class NotificationService ...@@ -138,50 +148,59 @@ class NotificationService
# build notify method like 'note_commit_email' # build notify method like 'note_commit_email'
notify_method = "note_#{note.noteable_type.underscore}_email".to_sym notify_method = "note_#{note.noteable_type.underscore}_email".to_sym
recipients.each do |recipient| recipients.each do |recipient|
mailer.send(notify_method, recipient.id, note.id) mailer.send(notify_method, recipient.id, note.id).deliver_later
end end
end end
def invite_project_member(project_member, token) def invite_project_member(project_member, token)
mailer.project_member_invited_email(project_member.id, token) mailer.project_member_invited_email(project_member.id, token).deliver_later
end end
def accept_project_invite(project_member) def accept_project_invite(project_member)
mailer.project_invite_accepted_email(project_member.id) mailer.project_invite_accepted_email(project_member.id).deliver_later
end end
def decline_project_invite(project_member) def decline_project_invite(project_member)
mailer.project_invite_declined_email(project_member.project.id, project_member.invite_email, project_member.access_level, project_member.created_by_id) mailer.project_invite_declined_email(
project_member.project.id,
project_member.invite_email,
project_member.access_level,
project_member.created_by_id
).deliver_later
end end
def new_project_member(project_member) def new_project_member(project_member)
mailer.project_access_granted_email(project_member.id) mailer.project_access_granted_email(project_member.id).deliver_later
end end
def update_project_member(project_member) def update_project_member(project_member)
mailer.project_access_granted_email(project_member.id) mailer.project_access_granted_email(project_member.id).deliver_later
end end
def invite_group_member(group_member, token) def invite_group_member(group_member, token)
mailer.group_member_invited_email(group_member.id, token) mailer.group_member_invited_email(group_member.id, token).deliver_later
end end
def accept_group_invite(group_member) def accept_group_invite(group_member)
mailer.group_invite_accepted_email(group_member.id) mailer.group_invite_accepted_email(group_member.id).deliver_later
end end
def decline_group_invite(group_member) def decline_group_invite(group_member)
mailer.group_invite_declined_email(group_member.group.id, group_member.invite_email, group_member.access_level, group_member.created_by_id) mailer.group_invite_declined_email(
group_member.group.id,
group_member.invite_email,
group_member.access_level,
group_member.created_by_id
).deliver_later
end end
def new_group_member(group_member) def new_group_member(group_member)
mailer.group_access_granted_email(group_member.id) mailer.group_access_granted_email(group_member.id).deliver_later
end end
def update_group_member(group_member) def update_group_member(group_member)
mailer.group_access_granted_email(group_member.id) mailer.group_access_granted_email(group_member.id).deliver_later
end end
def project_was_moved(project, old_path_with_namespace) def project_was_moved(project, old_path_with_namespace)
...@@ -189,7 +208,11 @@ class NotificationService ...@@ -189,7 +208,11 @@ class NotificationService
recipients = reject_muted_users(recipients, project) recipients = reject_muted_users(recipients, project)
recipients.each do |recipient| recipients.each do |recipient|
mailer.project_was_moved_email(project.id, recipient.id, old_path_with_namespace) mailer.project_was_moved_email(
project.id,
recipient.id,
old_path_with_namespace
).deliver_later
end end
end end
...@@ -339,7 +362,7 @@ class NotificationService ...@@ -339,7 +362,7 @@ class NotificationService
recipients = build_recipients(target, project, target.author) recipients = build_recipients(target, project, target.author)
recipients.each do |recipient| recipients.each do |recipient|
mailer.send(method, recipient.id, target.id) mailer.send(method, recipient.id, target.id).deliver_later
end end
end end
...@@ -347,7 +370,7 @@ class NotificationService ...@@ -347,7 +370,7 @@ class NotificationService
recipients = build_recipients(target, project, current_user) recipients = build_recipients(target, project, current_user)
recipients.each do |recipient| recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, current_user.id) mailer.send(method, recipient.id, target.id, current_user.id).deliver_later
end end
end end
...@@ -358,7 +381,13 @@ class NotificationService ...@@ -358,7 +381,13 @@ class NotificationService
recipients = build_recipients(target, project, current_user, [previous_assignee]) recipients = build_recipients(target, project, current_user, [previous_assignee])
recipients.each do |recipient| recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, previous_assignee_id, current_user.id) mailer.send(
method,
recipient.id,
target.id,
previous_assignee_id,
current_user.id
).deliver_later
end end
end end
...@@ -366,7 +395,7 @@ class NotificationService ...@@ -366,7 +395,7 @@ class NotificationService
recipients = build_recipients(target, project, current_user) recipients = build_recipients(target, project, current_user)
recipients.each do |recipient| recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, status, current_user.id) mailer.send(method, recipient.id, target.id, status, current_user.id).deliver_later
end end
end end
...@@ -388,7 +417,7 @@ class NotificationService ...@@ -388,7 +417,7 @@ class NotificationService
end end
def mailer def mailer
Notify.delay Notify
end end
def previous_record(object, attribute) def previous_record(object, attribute)
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
= label_tag :tag_list, class: 'control-label' do = label_tag :tag_list, class: 'control-label' do
Tags Tags
.col-sm-10 .col-sm-10
= f.text_field :tag_list, class: 'form-control' = f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
.help-block You can setup builds to only use runners with specific tags .help-block You can setup builds to only use runners with specific tags
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= @project.name = @project.name
%p %p
Commit: #{link_to @build.short_sha, namespace_project_commit_path(@build.gl_project.namespace, @build.gl_project, @build.sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_url(@build.gl_project.namespace, @build.gl_project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.commit.git_author_name}
%p %p
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
.form-group .form-group
= f.label :tag_list, "Tags", class: 'control-label' = f.label :tag_list, "Tags", class: 'control-label'
.col-sm-10 .col-sm-10
= f.text_field :tag_list, maxlength: 2000, class: "form-control" = f.text_field :tag_list, value: @project.tag_list.to_s, maxlength: 2000, class: "form-control"
%p.help-block Separate tags with commas. %p.help-block Separate tags with commas.
%fieldset.features %fieldset.features
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
= label_tag :tag_list, class: 'control-label' do = label_tag :tag_list, class: 'control-label' do
Tags Tags
.col-sm-10 .col-sm-10
= f.text_field :tag_list, class: 'form-control' = f.text_field :tag_list, value: @runner.tag_list.to_s, class: 'form-control'
.help-block You can setup jobs to only use runners with specific tags .help-block You can setup jobs to only use runners with specific tags
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
...@@ -46,6 +46,6 @@ class EmailReceiverWorker ...@@ -46,6 +46,6 @@ class EmailReceiverWorker
return return
end end
EmailRejectionMailer.delay.rejection(reason, raw, can_retry) EmailRejectionMailer.rejection(reason, raw, can_retry).deliver_later
end end
end end
...@@ -53,7 +53,7 @@ class EmailsOnPushWorker ...@@ -53,7 +53,7 @@ class EmailsOnPushWorker
reverse_compare: reverse_compare, reverse_compare: reverse_compare,
send_from_committer_email: send_from_committer_email, send_from_committer_email: send_from_committer_email,
disable_diffs: disable_diffs disable_diffs: disable_diffs
).deliver ).deliver_now
# These are input errors and won't be corrected even if Sidekiq retries # These are input errors and won't be corrected even if Sidekiq retries
rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e
logger.info("Failed to send e-mail for project '#{project.name_with_namespace}' to #{recipient}: #{e}") logger.info("Failed to send e-mail for project '#{project.name_with_namespace}' to #{recipient}: #{e}")
......
File mode changed from 100644 to 100755
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin APP_PATH = File.expand_path('../../config/application', __FILE__)
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin require_relative '../config/boot'
load File.expand_path("../spring", __FILE__) require 'rake'
rescue LoadError Rake.application.run
end
require 'bundler/setup'
load Gem.bin_path('rake', 'rake')
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
File mode changed from 100644 to 100755
...@@ -99,6 +99,10 @@ module Gitlab ...@@ -99,6 +99,10 @@ module Gitlab
redis_config_hash[:expires_in] = 2.weeks # Cache should not grow forever redis_config_hash[:expires_in] = 2.weeks # Cache should not grow forever
config.cache_store = :redis_store, redis_config_hash config.cache_store = :redis_store, redis_config_hash
config.active_record.raise_in_transactional_callbacks = true
config.active_job.queue_adapter = :sidekiq
# This is needed for gitlab-shell # This is needed for gitlab-shell
ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH'] ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH']
end end
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__) require File.expand_path('../application', __FILE__)
# Initialize the rails application # Initialize the rails application
Gitlab::Application.initialize! Rails.application.initialize!
Gitlab::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
......
Gitlab::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests # Code is not reloaded between requests
...@@ -9,7 +9,7 @@ Gitlab::Application.configure do ...@@ -9,7 +9,7 @@ Gitlab::Application.configure do
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this) # Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false config.serve_static_files = false
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
......
Gitlab::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
...@@ -8,7 +8,7 @@ Gitlab::Application.configure do ...@@ -8,7 +8,7 @@ Gitlab::Application.configure do
config.cache_classes = false config.cache_classes = false
# Configure static asset server for tests with Cache-Control for performance # Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true config.serve_static_files = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = "public, max-age=3600"
# Show full error reports and disable caching # Show full error reports and disable caching
...@@ -32,4 +32,6 @@ Gitlab::Application.configure do ...@@ -32,4 +32,6 @@ Gitlab::Application.configure do
config.eager_load = false config.eager_load = false
config.cache_store = :null_store config.cache_store = :null_store
config.active_job.queue_adapter = :test
end end
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Gitlab::Application.config.action_dispatch.cookies_serializer = :hybrid Rails.application.config.action_dispatch.cookies_serializer = :hybrid
...@@ -8,4 +8,4 @@ unless Gitlab.config.gitlab_on_standard_port? ...@@ -8,4 +8,4 @@ unless Gitlab.config.gitlab_on_standard_port?
default_url_options[:port] = Gitlab.config.gitlab.port default_url_options[:port] = Gitlab.config.gitlab.port
end end
Gitlab::Application.routes.default_url_options = default_url_options Rails.application.routes.default_url_options = default_url_options
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
# If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests
paths_to_be_protected = [ paths_to_be_protected = [
"#{Gitlab::Application.config.relative_url_root}/users/password", "#{Rails.application.config.relative_url_root}/users/password",
"#{Gitlab::Application.config.relative_url_root}/users/sign_in", "#{Rails.application.config.relative_url_root}/users/sign_in",
"#{Gitlab::Application.config.relative_url_root}/api/#{API::API.version}/session.json", "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session.json",
"#{Gitlab::Application.config.relative_url_root}/api/#{API::API.version}/session", "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session",
"#{Gitlab::Application.config.relative_url_root}/users", "#{Rails.application.config.relative_url_root}/users",
"#{Gitlab::Application.config.relative_url_root}/users/confirmation", "#{Rails.application.config.relative_url_root}/users/confirmation",
"#{Gitlab::Application.config.relative_url_root}/unsubscribes/" "#{Rails.application.config.relative_url_root}/unsubscribes/"
] ]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# with darker backgrounds. This patch tweaks the colors a bit so the output is # with darker backgrounds. This patch tweaks the colors a bit so the output is
# actually readable. # actually readable.
if Rails.env.development? and RUBY_ENGINE == 'ruby' and ENV['ENABLE_LINEPROF'] if Rails.env.development? and RUBY_ENGINE == 'ruby' and ENV['ENABLE_LINEPROF']
Gitlab::Application.config.middleware.use(Rack::Lineprof) Rails.application.config.middleware.use(Rack::Lineprof)
module Rack module Rack
class Lineprof class Lineprof
......
...@@ -22,15 +22,15 @@ def find_secure_token ...@@ -22,15 +22,15 @@ def find_secure_token
end end
end end
Gitlab::Application.config.secret_token = find_secure_token Rails.application.config.secret_token = find_secure_token
Gitlab::Application.config.secret_key_base = find_secure_token Rails.application.config.secret_key_base = find_secure_token
# CI # CI
def generate_new_secure_token def generate_new_secure_token
SecureRandom.hex(64) SecureRandom.hex(64)
end end
if Gitlab::Application.secrets.db_key_base.blank? if Rails.application.secrets.db_key_base.blank?
warn "Missing `db_key_base` for '#{Rails.env}' environment. The secrets will be generated and stored in `config/secrets.yml`" warn "Missing `db_key_base` for '#{Rails.env}' environment. The secrets will be generated and stored in `config/secrets.yml`"
all_secrets = YAML.load_file('config/secrets.yml') if File.exist?('config/secrets.yml') all_secrets = YAML.load_file('config/secrets.yml') if File.exist?('config/secrets.yml')
...@@ -46,5 +46,5 @@ if Gitlab::Application.secrets.db_key_base.blank? ...@@ -46,5 +46,5 @@ if Gitlab::Application.secrets.db_key_base.blank?
file.write(YAML.dump(all_secrets)) file.write(YAML.dump(all_secrets))
end end
Gitlab::Application.secrets.db_key_base = env_secrets['db_key_base'] Rails.application.secrets.db_key_base = env_secrets['db_key_base']
end end
...@@ -13,11 +13,11 @@ end ...@@ -13,11 +13,11 @@ end
unless Rails.env.test? unless Rails.env.test?
Gitlab::Application.config.session_store( Gitlab::Application.config.session_store(
:redis_store, # Using the cookie_store would enable session replay attacks. :redis_store, # Using the cookie_store would enable session replay attacks.
servers: Gitlab::Application.config.cache_store[1].merge(namespace: 'session:gitlab'), # re-use the Redis config from the Rails cache store servers: Rails.application.config.cache_store[1].merge(namespace: 'session:gitlab'), # re-use the Redis config from the Rails cache store
key: '_gitlab_session', key: '_gitlab_session',
secure: Gitlab.config.gitlab.https, secure: Gitlab.config.gitlab.https,
httponly: true, httponly: true,
expire_after: Settings.gitlab['session_expire_delay'] * 60, expire_after: Settings.gitlab['session_expire_delay'] * 60,
path: (Gitlab::Application.config.relative_url_root.nil?) ? '/' : Gitlab::Application.config.relative_url_root path: (Rails.application.config.relative_url_root.nil?) ? '/' : Gitlab::Application.config.relative_url_root
) )
end end
if Gitlab::Sherlock.enabled? if Gitlab::Sherlock.enabled?
Gitlab::Application.configure do |config| Rails.application.configure do |config|
config.middleware.use(Gitlab::Sherlock::Middleware) config.middleware.use(Gitlab::Sherlock::Middleware)
end end
end end
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests # If you change this file in a Merge Request, please also create a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests
if Rails.env.production? if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp Rails.application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = { ActionMailer::Base.smtp_settings = {
address: "email.server.com", address: "email.server.com",
......
app = Gitlab::Application app = Rails.application
if app.config.serve_static_assets if app.config.serve_static_files
# The `ActionDispatch::Static` middleware intercepts requests for static files # The `ActionDispatch::Static` middleware intercepts requests for static files
# by checking if they exist in the `/public` directory. # by checking if they exist in the `/public` directory.
# We're replacing it with our `Gitlab::Middleware::Static` that does the same, # We're replacing it with our `Gitlab::Middleware::Static` that does the same,
......
require 'sidekiq/web' require 'sidekiq/web'
require 'api/api' require 'api/api'
Gitlab::Application.routes.draw do Rails.application.routes.draw do
if Gitlab::Sherlock.enabled? if Gitlab::Sherlock.enabled?
namespace :sherlock do namespace :sherlock do
resources :transactions, only: [:index, :show] do resources :transactions, only: [:index, :show] do
......
This diff is collapsed.
...@@ -46,7 +46,7 @@ module Gitlab ...@@ -46,7 +46,7 @@ module Gitlab
end end
def github_options def github_options
OmniAuth::Strategies::GitHub.default_options[:client_options].symbolize_keys OmniAuth::Strategies::GitHub.default_options[:client_options].to_h.symbolize_keys
end end
end end
end end
......
...@@ -75,7 +75,7 @@ module Gitlab ...@@ -75,7 +75,7 @@ module Gitlab
end end
def gitlab_options def gitlab_options
OmniAuth::Strategies::GitLab.default_options[:client_options].symbolize_keys OmniAuth::Strategies::GitLab.default_options[:client_options].to_h.symbolize_keys
end end
end end
end end
......
...@@ -60,8 +60,7 @@ module Gitlab ...@@ -60,8 +60,7 @@ module Gitlab
def url_for_label(project, label) def url_for_label(project, label)
h = Gitlab::Application.routes.url_helpers h = Gitlab::Application.routes.url_helpers
h.namespace_project_issues_path(project.namespace, project, h.namespace_project_issues_path(project.namespace, project,
label_name: label.name, label_name: label.name)
only_path: context[:only_path])
end end
def render_colored_label(label) def render_colored_label(label)
......
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
def self.mute_mailer def self.mute_mailer
code = <<-eos code = <<-eos
def Notify.delay def Notify.deliver_later
self self
end end
eos eos
......
...@@ -18,27 +18,31 @@ describe AbuseReportsController do ...@@ -18,27 +18,31 @@ describe AbuseReportsController do
end end
it "sends a notification email" do it "sends a notification email" do
post :create, perform_enqueued_jobs do
abuse_report: {
user_id: user.id,
message: message
}
email = ActionMailer::Base.deliveries.last
expect(email.to).to eq([admin_email])
expect(email.subject).to include(user.username)
expect(email.text_part.body).to include(message)
end
it "saves the abuse report" do
expect do
post :create, post :create,
abuse_report: { abuse_report: {
user_id: user.id, user_id: user.id,
message: message message: message
} }
end.to change { AbuseReport.count }.by(1)
email = ActionMailer::Base.deliveries.last
expect(email.to).to eq([admin_email])
expect(email.subject).to include(user.username)
expect(email.text_part.body).to include(message)
end
end
it "saves the abuse report" do
perform_enqueued_jobs do
expect do
post :create,
abuse_report: {
user_id: user.id,
message: message
}
end.to change { AbuseReport.count }.by(1)
end
end end
end end
......
...@@ -87,13 +87,16 @@ describe "Admin::Users", feature: true do ...@@ -87,13 +87,16 @@ describe "Admin::Users", feature: true do
end end
it "should call send mail" do it "should call send mail" do
expect(Notify).to receive(:new_user_email) expect_any_instance_of(NotificationService).to receive(:new_user)
click_button "Create user" click_button "Create user"
end end
it "should send valid email to user with email & password" do it "should send valid email to user with email & password" do
click_button "Create user" perform_enqueued_jobs do
click_button "Create user"
end
user = User.find_by(username: 'bang') user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
expect(email.subject).to have_content('Account was created') expect(email.subject).to have_content('Account was created')
......
...@@ -59,7 +59,7 @@ describe ApplicationHelper do ...@@ -59,7 +59,7 @@ describe ApplicationHelper do
avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif" avatar_url = "http://localhost/uploads/project/avatar/#{project.id}/banana_sample.gif"
expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s). expect(helper.project_icon("#{project.namespace.to_param}/#{project.to_param}").to_s).
to eq "<img alt=\"Banana sample\" src=\"#{avatar_url}\" />" to eq "<img src=\"#{avatar_url}\" alt=\"Banana sample\" />"
end end
it 'should give uploaded icon when present' do it 'should give uploaded icon when present' do
......
...@@ -71,7 +71,7 @@ module Gitlab::Markdown ...@@ -71,7 +71,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name) namespace_project_issues_path(project.namespace, project, label_name: label.name)
end end
it 'links with adjacent text' do it 'links with adjacent text' do
...@@ -94,7 +94,7 @@ module Gitlab::Markdown ...@@ -94,7 +94,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name) namespace_project_issues_path(project.namespace, project, label_name: label.name)
expect(doc.text).to eq 'See gfm' expect(doc.text).to eq 'See gfm'
end end
...@@ -118,7 +118,7 @@ module Gitlab::Markdown ...@@ -118,7 +118,7 @@ module Gitlab::Markdown
doc = filter("See #{reference}") doc = filter("See #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls. expect(doc.css('a').first.attr('href')).to eq urls.
namespace_project_issues_url(project.namespace, project, label_name: label.name) namespace_project_issues_path(project.namespace, project, label_name: label.name)
expect(doc.text).to eq 'See gfm references' expect(doc.text).to eq 'See gfm references'
end end
......
...@@ -44,13 +44,10 @@ describe Ci::MailService do ...@@ -44,13 +44,10 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
mail.execute(build) expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end expect(ActionMailer::Base.deliveries.last.to).to eq(["git@example.com"])
end
def should_email(email)
expect(Ci::Notify).to receive(:build_fail_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
end end
end end
...@@ -67,13 +64,10 @@ describe Ci::MailService do ...@@ -67,13 +64,10 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
mail.execute(build) expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(1)
end expect(ActionMailer::Base.deliveries.last.to).to eq(["git@example.com"])
end
def should_email(email)
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
end end
end end
...@@ -95,14 +89,12 @@ describe Ci::MailService do ...@@ -95,14 +89,12 @@ describe Ci::MailService do
end end
it do it do
should_email("git@example.com") perform_enqueued_jobs do
should_email("jeroen@example.com") expect{ mail.execute(build) }.to change{ ActionMailer::Base.deliveries.size }.by(2)
mail.execute(build) expect(
end ActionMailer::Base.deliveries.map(&:to).flatten
).to include("git@example.com", "jeroen@example.com")
def should_email(email) end
expect(Ci::Notify).to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
end end
end end
...@@ -124,14 +116,11 @@ describe Ci::MailService do ...@@ -124,14 +116,11 @@ describe Ci::MailService do
end end
it do it do
should_email(commit.git_author_email) perform_enqueued_jobs do
should_email("jeroen@example.com") expect do
mail.execute(build) if mail.can_execute?(build) mail.execute(build) if mail.can_execute?(build)
end end.to_not change{ ActionMailer::Base.deliveries.size }
end
def should_email(email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
end end
end end
...@@ -177,14 +166,11 @@ describe Ci::MailService do ...@@ -177,14 +166,11 @@ describe Ci::MailService do
it do it do
Ci::Build.retry(build) Ci::Build.retry(build)
should_email(commit.git_author_email) perform_enqueued_jobs do
should_email("jeroen@example.com") expect do
mail.execute(build) if mail.can_execute?(build) mail.execute(build) if mail.can_execute?(build)
end end.to_not change{ ActionMailer::Base.deliveries.size }
end
def should_email(email)
expect(Ci::Notify).not_to receive(:build_success_email).with(build.id, email)
expect(Ci::Notify).not_to receive(:build_fail_email).with(build.id, email)
end end
end end
end end
......
...@@ -94,9 +94,9 @@ describe JiraService do ...@@ -94,9 +94,9 @@ describe JiraService do
end end
it 'should be prepopulated with the settings' do it 'should be prepopulated with the settings' do
expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a') expect(@service.properties["project_url"]).to eq('http://jira.sample/projects/project_a')
expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id") expect(@service.properties["issues_url"]).to eq("http://jira.sample/issues/:id")
expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new") expect(@service.properties["new_issue_url"]).to eq("http://jira.sample/projects/project_a/issues/new")
end end
end end
end end
......
...@@ -14,7 +14,9 @@ describe Issues::CloseService do ...@@ -14,7 +14,9 @@ describe Issues::CloseService do
describe :execute do describe :execute do
context "valid params" do context "valid params" do
before do before do
@issue = Issues::CloseService.new(project, user, {}).execute(issue) perform_enqueued_jobs do
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
end
end end
it { expect(@issue).to be_valid } it { expect(@issue).to be_valid }
......
...@@ -36,7 +36,10 @@ describe Issues::UpdateService do ...@@ -36,7 +36,10 @@ describe Issues::UpdateService do
label_ids: [label.id] label_ids: [label.id]
} }
@issue = Issues::UpdateService.new(project, user, opts).execute(issue) perform_enqueued_jobs do
@issue = Issues::UpdateService.new(project, user, opts).execute(issue)
end
@issue.reload @issue.reload
end end
......
...@@ -18,7 +18,9 @@ describe MergeRequests::CloseService do ...@@ -18,7 +18,9 @@ describe MergeRequests::CloseService do
before do before do
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
@merge_request = service.execute(merge_request) perform_enqueued_jobs do
@merge_request = service.execute(merge_request)
end
end end
it { expect(@merge_request).to be_valid } it { expect(@merge_request).to be_valid }
......
...@@ -17,8 +17,9 @@ describe MergeRequests::MergeService do ...@@ -17,8 +17,9 @@ describe MergeRequests::MergeService do
before do before do
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
perform_enqueued_jobs do
service.execute(merge_request, 'Awesome message') service.execute(merge_request, 'Awesome message')
end
end end
it { expect(merge_request).to be_valid } it { expect(merge_request).to be_valid }
......
...@@ -19,7 +19,9 @@ describe MergeRequests::ReopenService do ...@@ -19,7 +19,9 @@ describe MergeRequests::ReopenService do
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
merge_request.state = :closed merge_request.state = :closed
service.execute(merge_request) perform_enqueued_jobs do
service.execute(merge_request)
end
end end
it { expect(merge_request).to be_valid } it { expect(merge_request).to be_valid }
......
...@@ -42,8 +42,10 @@ describe MergeRequests::UpdateService do ...@@ -42,8 +42,10 @@ describe MergeRequests::UpdateService do
before do before do
allow(service).to receive(:execute_hooks) allow(service).to receive(:execute_hooks)
@merge_request = service.execute(merge_request) perform_enqueued_jobs do
@merge_request.reload @merge_request = service.execute(merge_request)
@merge_request.reload
end
end end
it { expect(@merge_request).to be_valid } it { expect(@merge_request).to be_valid }
......
This diff is collapsed.
...@@ -31,6 +31,7 @@ RSpec.configure do |config| ...@@ -31,6 +31,7 @@ RSpec.configure do |config|
config.include StubConfiguration config.include StubConfiguration
config.include RelativeUrl, type: feature config.include RelativeUrl, type: feature
config.include TestEnv config.include TestEnv
config.include ActiveJob::TestHelper
config.include StubGitlabCalls config.include StubGitlabCalls
config.include StubGitlabData config.include StubGitlabData
config.include BenchmarkMatchers, benchmark: true config.include BenchmarkMatchers, benchmark: true
......
...@@ -21,12 +21,14 @@ describe EmailReceiverWorker do ...@@ -21,12 +21,14 @@ describe EmailReceiverWorker do
end end
it "sends out a rejection email" do it "sends out a rejection email" do
described_class.new.perform(raw_message) perform_enqueued_jobs do
described_class.new.perform(raw_message)
email = ActionMailer::Base.deliveries.last
expect(email).not_to be_nil email = ActionMailer::Base.deliveries.last
expect(email.to).to eq(["jake@adventuretime.ooo"]) expect(email).not_to be_nil
expect(email.subject).to include("Rejected") expect(email.to).to eq(["jake@adventuretime.ooo"])
expect(email.subject).to include("Rejected")
end
end end
end 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