Commit d38cdaa4 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Update from `rubocop -a`

parent 12bc446e
...@@ -31,12 +31,6 @@ Style/MutableConstant: ...@@ -31,12 +31,6 @@ Style/MutableConstant:
- 'ee/db/post_migrate/**/*' - 'ee/db/post_migrate/**/*'
- 'ee/db/geo/migrate/**/*' - 'ee/db/geo/migrate/**/*'
Naming/UncommunicativeMethodParamName:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false
Naming/FileName: Naming/FileName:
ExpectMatchingDefinition: true ExpectMatchingDefinition: true
Exclude: Exclude:
......
...@@ -363,7 +363,7 @@ group :development, :test do ...@@ -363,7 +363,7 @@ group :development, :test do
gem 'spring', '~> 2.0.0' gem 'spring', '~> 2.0.0'
gem 'spring-commands-rspec', '~> 1.0.4' gem 'spring-commands-rspec', '~> 1.0.4'
gem 'gitlab-styles', '~> 2.4', require: false gem 'gitlab-styles', '~> 2.4', git: 'https://gitlab.com/gitlab-org/gitlab-styles.git', branch: '2.4.1-rc', require: false
# Pin these dependencies, otherwise a new rule could break the CI pipelines # Pin these dependencies, otherwise a new rule could break the CI pipelines
gem 'rubocop', '~> 0.54.0' gem 'rubocop', '~> 0.54.0'
gem 'rubocop-rspec', '~> 1.22.1' gem 'rubocop-rspec', '~> 1.22.1'
......
GIT
remote: https://gitlab.com/gitlab-org/gitlab-styles.git
revision: ea26af1601c6341f15b62a71b337208541cf7c1a
branch: 2.4.1-rc
specs:
gitlab-styles (2.4.1)
rubocop (~> 0.54.0)
rubocop-gitlab-security (~> 0.1.0)
rubocop-rspec (~> 1.19)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -337,10 +347,6 @@ GEM ...@@ -337,10 +347,6 @@ GEM
posix-spawn (~> 0.3) posix-spawn (~> 0.3)
gitlab-license (1.0.0) gitlab-license (1.0.0)
gitlab-markup (1.6.4) gitlab-markup (1.6.4)
gitlab-styles (2.4.0)
rubocop (~> 0.54.0)
rubocop-gitlab-security (~> 0.1.0)
rubocop-rspec (~> 1.19)
gitlab_omniauth-ldap (2.0.4) gitlab_omniauth-ldap (2.0.4)
net-ldap (~> 0.16) net-ldap (~> 0.16)
omniauth (~> 1.3) omniauth (~> 1.3)
...@@ -1078,7 +1084,7 @@ DEPENDENCIES ...@@ -1078,7 +1084,7 @@ DEPENDENCIES
gitlab-gollum-rugged_adapter (~> 0.4.4) gitlab-gollum-rugged_adapter (~> 0.4.4)
gitlab-license (~> 1.0) gitlab-license (~> 1.0)
gitlab-markup (~> 1.6.4) gitlab-markup (~> 1.6.4)
gitlab-styles (~> 2.4) gitlab-styles (~> 2.4)!
gitlab_omniauth-ldap (~> 2.0.4) gitlab_omniauth-ldap (~> 2.0.4)
gon (~> 6.2) gon (~> 6.2)
google-api-client (~> 0.19.8) google-api-client (~> 0.19.8)
......
GIT
remote: https://gitlab.com/gitlab-org/gitlab-styles.git
revision: ea26af1601c6341f15b62a71b337208541cf7c1a
branch: 2.4.1-rc
specs:
gitlab-styles (2.4.1)
rubocop (~> 0.54.0)
rubocop-gitlab-security (~> 0.1.0)
rubocop-rspec (~> 1.19)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -340,10 +350,6 @@ GEM ...@@ -340,10 +350,6 @@ GEM
posix-spawn (~> 0.3) posix-spawn (~> 0.3)
gitlab-license (1.0.0) gitlab-license (1.0.0)
gitlab-markup (1.6.4) gitlab-markup (1.6.4)
gitlab-styles (2.4.0)
rubocop (~> 0.54.0)
rubocop-gitlab-security (~> 0.1.0)
rubocop-rspec (~> 1.19)
gitlab_omniauth-ldap (2.0.4) gitlab_omniauth-ldap (2.0.4)
net-ldap (~> 0.16) net-ldap (~> 0.16)
omniauth (~> 1.3) omniauth (~> 1.3)
...@@ -1088,7 +1094,7 @@ DEPENDENCIES ...@@ -1088,7 +1094,7 @@ DEPENDENCIES
gitlab-gollum-rugged_adapter (~> 0.4.4) gitlab-gollum-rugged_adapter (~> 0.4.4)
gitlab-license (~> 1.0) gitlab-license (~> 1.0)
gitlab-markup (~> 1.6.4) gitlab-markup (~> 1.6.4)
gitlab-styles (~> 2.4) gitlab-styles (~> 2.4)!
gitlab_omniauth-ldap (~> 2.0.4) gitlab_omniauth-ldap (~> 2.0.4)
gon (~> 6.2) gon (~> 6.2)
google-api-client (~> 0.19.8) google-api-client (~> 0.19.8)
......
...@@ -12,7 +12,7 @@ class Projects::ImportsController < Projects::ApplicationController ...@@ -12,7 +12,7 @@ class Projects::ImportsController < Projects::ApplicationController
end end
def create def create
if @project.update_attributes(safe_import_params) if @project.update(safe_import_params)
@project.reload.import_schedule @project.reload.import_schedule
end end
......
...@@ -47,7 +47,7 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -47,7 +47,7 @@ class Admin::LicensesController < Admin::ApplicationController
flash[:alert] = "The license was removed. GitLab now no longer has a valid license." flash[:alert] = "The license was removed. GitLab now no longer has a valid license."
end end
redirect_to admin_license_path, status: 302 redirect_to admin_license_path, status: :found
end end
private private
......
...@@ -8,7 +8,7 @@ class Admin::PushRulesController < Admin::ApplicationController ...@@ -8,7 +8,7 @@ class Admin::PushRulesController < Admin::ApplicationController
end end
def update def update
@push_rule.update_attributes(push_rule_params) @push_rule.update(push_rule_params)
if @push_rule.valid? if @push_rule.valid?
redirect_to admin_push_rule_path, notice: 'Push Rule updated successfully.' redirect_to admin_push_rule_path, notice: 'Push Rule updated successfully.'
......
...@@ -48,7 +48,7 @@ module EE ...@@ -48,7 +48,7 @@ module EE
respond_to do |format| respond_to do |format|
format.json { head :ok } format.json { head :ok }
format.html { redirect_to boards_path, status: 302 } format.html { redirect_to boards_path, status: :found }
end end
end end
......
...@@ -44,7 +44,7 @@ module EE ...@@ -44,7 +44,7 @@ module EE
end end
def render_bad_geo_auth(message) def render_bad_geo_auth(message)
render plain: "Geo JWT authentication failed: #{message}", status: 401 render plain: "Geo JWT authentication failed: #{message}", status: :unauthorized
end end
end end
end end
......
...@@ -48,7 +48,6 @@ module EE ...@@ -48,7 +48,6 @@ module EE
.find_by!(iid: params[:id]) .find_by!(iid: params[:id])
super super
end end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def define_edit_vars def define_edit_vars
super super
......
...@@ -13,20 +13,20 @@ module EE ...@@ -13,20 +13,20 @@ module EE
if lookup.error.present? if lookup.error.present?
# Failed to read keys # Failed to read keys
render json: { message: lookup.error }, status: 400 render json: { message: lookup.error }, status: :bad_request
elsif lookup.known_hosts.nil? elsif lookup.known_hosts.nil?
# Still working, come back later # Still working, come back later
render body: nil, status: 204 render body: nil, status: :no_content
else else
render json: lookup render json: lookup
end end
rescue ArgumentError => err rescue ArgumentError => err
render json: { message: err.message }, status: 400 render json: { message: err.message }, status: :bad_request
end end
override :update override :update
def update def update
if project.update_attributes(safe_mirror_params) if project.update(safe_mirror_params)
if project.mirror? if project.mirror?
project.force_import_job! project.force_import_job!
......
...@@ -67,7 +67,7 @@ module EE ...@@ -67,7 +67,7 @@ module EE
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to edit_project_service_path(project, ::PrometheusService), status: 303 redirect_to edit_project_service_path(project, ::PrometheusService), status: :see_other
end end
format.json do format.json do
head :ok head :ok
......
...@@ -17,7 +17,7 @@ class Groups::AnalyticsController < Groups::ApplicationController ...@@ -17,7 +17,7 @@ class Groups::AnalyticsController < Groups::ApplicationController
format.json do format.json do
render json: GroupAnalyticsSerializer render json: GroupAnalyticsSerializer
.new(events: event_totals) .new(events: event_totals)
.represent(users), status: 200 .represent(users), status: :ok
end end
end end
end end
......
...@@ -44,7 +44,7 @@ class Groups::HooksController < Groups::ApplicationController ...@@ -44,7 +44,7 @@ class Groups::HooksController < Groups::ApplicationController
def destroy def destroy
hook.destroy hook.destroy
redirect_to group_hooks_path(@group), status: 302 redirect_to group_hooks_path(@group), status: :found
end end
private private
......
...@@ -25,7 +25,7 @@ class Projects::PathLocksController < Projects::ApplicationController ...@@ -25,7 +25,7 @@ class Projects::PathLocksController < Projects::ApplicationController
head :ok head :ok
rescue PathLocks::UnlockService::AccessDenied, PathLocks::LockService::AccessDenied rescue PathLocks::UnlockService::AccessDenied, PathLocks::LockService::AccessDenied
return access_denied! access_denied!
end end
def destroy def destroy
...@@ -39,7 +39,7 @@ class Projects::PathLocksController < Projects::ApplicationController ...@@ -39,7 +39,7 @@ class Projects::PathLocksController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to project_locks_path(@project), status: 302 redirect_to project_locks_path(@project), status: :found
end end
format.js format.js
end end
......
...@@ -11,7 +11,7 @@ class Projects::PushRulesController < Projects::ApplicationController ...@@ -11,7 +11,7 @@ class Projects::PushRulesController < Projects::ApplicationController
def update def update
@push_rule = project.push_rule @push_rule = project.push_rule
@push_rule.update_attributes(push_rule_params) @push_rule.update(push_rule_params)
if @push_rule.valid? if @push_rule.valid?
flash[:notice] = 'Push Rules updated successfully.' flash[:notice] = 'Push Rules updated successfully.'
......
...@@ -19,7 +19,7 @@ module PushRulesHelper ...@@ -19,7 +19,7 @@ module PushRulesHelper
if push_rule.global? if push_rule.global?
messages << s_("ProjectSettings|This setting will be applied to all projects unless overridden by an admin.") messages << s_("ProjectSettings|This setting will be applied to all projects unless overridden by an admin.")
else else
enabled_globally = PushRule.global&.public_send(rule) # rubocop:disable GitlabSecurity/PublicSend enabled_globally = PushRule.global&.public_send(rule)
enabled_in_project = push_rule.public_send(rule) # rubocop:disable GitlabSecurity/PublicSend enabled_in_project = push_rule.public_send(rule) # rubocop:disable GitlabSecurity/PublicSend
if enabled_globally if enabled_globally
......
...@@ -88,7 +88,7 @@ class Burndown ...@@ -88,7 +88,7 @@ class Burndown
# reopened. # reopened.
internal_clause = internal_clause =
::Issue ::Issue
.joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue' AND e.action = #{Event::CLOSED}") # rubocop:disable GitlabSecurity/SqlInjection .joins("LEFT OUTER JOIN events e ON issues.id = e.target_id AND e.target_type = 'Issue' AND e.action = #{Event::CLOSED}")
.where(milestone: @milestone) .where(milestone: @milestone)
.where("state = 'closed' OR (state = 'opened' AND e.action = #{Event::CLOSED})") # rubocop:disable GitlabSecurity/SqlInjection .where("state = 'closed' OR (state = 'opened' AND e.action = #{Event::CLOSED})") # rubocop:disable GitlabSecurity/SqlInjection
......
...@@ -11,7 +11,7 @@ module EE ...@@ -11,7 +11,7 @@ module EE
# If we don't `protected_branch` or `protected_tag` would be empty and # If we don't `protected_branch` or `protected_tag` would be empty and
# `project` cannot be delegated to it, which in turn would cause validations # `project` cannot be delegated to it, which in turn would cause validations
# to fail. # to fail.
has_many :"#{type}_access_levels", inverse_of: self.model_name.singular # rubocop:disable Cop/ActiveRecordDependent has_many :"#{type}_access_levels", inverse_of: self.model_name.singular
accepts_nested_attributes_for :"#{type}_access_levels", allow_destroy: true accepts_nested_attributes_for :"#{type}_access_levels", allow_destroy: true
......
...@@ -11,7 +11,7 @@ module CiCd ...@@ -11,7 +11,7 @@ module CiCd
private private
def update_project def update_project
project.update_attributes( project.update(
mirror: true, mirror: true,
mirror_trigger_builds: true, mirror_trigger_builds: true,
mirror_overwrites_diverged_branches: true, mirror_overwrites_diverged_branches: true,
...@@ -21,7 +21,7 @@ module CiCd ...@@ -21,7 +21,7 @@ module CiCd
end end
def disable_project_features def disable_project_features
project.project_feature.update_attributes( project.project_feature.update(
issues_access_level: ProjectFeature::DISABLED, issues_access_level: ProjectFeature::DISABLED,
merge_requests_access_level: ProjectFeature::DISABLED, merge_requests_access_level: ProjectFeature::DISABLED,
wiki_access_level: ProjectFeature::DISABLED, wiki_access_level: ProjectFeature::DISABLED,
......
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
user_mirrors.find_each do |mirror| user_mirrors.find_each do |mirror|
new_mirror_user = first_mirror_owner(user, mirror) new_mirror_user = first_mirror_owner(user, mirror)
mirror.update_attributes(mirror_user: new_mirror_user) mirror.update(mirror_user: new_mirror_user)
::NotificationService.new.project_mirror_user_changed(new_mirror_user, user.name, mirror) ::NotificationService.new.project_mirror_user_changed(new_mirror_user, user.name, mirror)
end end
end end
......
...@@ -13,7 +13,7 @@ module EpicIssues ...@@ -13,7 +13,7 @@ module EpicIssues
epic_issue.save! epic_issue.save!
success success
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
return error('Epic issue not found for given params', 404) error('Epic issue not found for given params', 404)
end end
private private
......
...@@ -10,16 +10,16 @@ module Geo ...@@ -10,16 +10,16 @@ module Geo
return false return false
end end
return true true
rescue Gitlab::Geo::GeoNodeNotFoundError => e rescue Gitlab::Geo::GeoNodeNotFoundError => e
log_error(e.to_s) log_error(e.to_s)
return false false
rescue OpenSSL::Cipher::CipherError => e rescue OpenSSL::Cipher::CipherError => e
log_error('Error decrypting the Geo secret from the database. Check that the primary uses the correct db_key_base.', e) log_error('Error decrypting the Geo secret from the database. Check that the primary uses the correct db_key_base.', e)
return false false
rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, SystemCallError, OpenSSL::SSL::SSLError => e rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, SystemCallError, OpenSSL::SSL::SSLError => e
log_error('Failed to post status data to primary', e) log_error('Failed to post status data to primary', e)
return false false
end end
private private
......
...@@ -10,7 +10,7 @@ module Projects ...@@ -10,7 +10,7 @@ module Projects
private private
def update_project def update_project
project.update_attributes( project.update(
container_registry_enabled: false, container_registry_enabled: false,
mirror: true, mirror: true,
mirror_trigger_builds: true, mirror_trigger_builds: true,
...@@ -21,7 +21,7 @@ module Projects ...@@ -21,7 +21,7 @@ module Projects
end end
def disable_project_features def disable_project_features
project.project_feature.update_attributes( project.project_feature.update(
issues_access_level: ProjectFeature::DISABLED, issues_access_level: ProjectFeature::DISABLED,
merge_requests_access_level: ProjectFeature::DISABLED, merge_requests_access_level: ProjectFeature::DISABLED,
wiki_access_level: ProjectFeature::DISABLED, wiki_access_level: ProjectFeature::DISABLED,
......
...@@ -143,7 +143,7 @@ module API ...@@ -143,7 +143,7 @@ module API
if geo_node.primary? if geo_node.primary?
forbidden!('Primary node cannot be edited') forbidden!('Primary node cannot be edited')
elsif geo_node.update_attributes(update_params) elsif geo_node.update(update_params)
present geo_node, with: EE::API::Entities::GeoNode present geo_node, with: EE::API::Entities::GeoNode
else else
render_validation_error!(geo_node) render_validation_error!(geo_node)
......
...@@ -58,7 +58,7 @@ module API ...@@ -58,7 +58,7 @@ module API
push_rule = user_project.push_rule push_rule = user_project.push_rule
not_found!('Push Rule') unless push_rule not_found!('Push Rule') unless push_rule
if push_rule.update_attributes(declared_params(include_missing: false)) if push_rule.update(declared_params(include_missing: false))
present push_rule, with: EE::API::Entities::ProjectPushRule present push_rule, with: EE::API::Entities::ProjectPushRule
else else
render_validation_error!(push_rule) render_validation_error!(push_rule)
......
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Metrics/LineLength
# rubocop:disable Style/Documentation
module Gitlab module Gitlab
module BackgroundMigration module BackgroundMigration
......
...@@ -33,7 +33,7 @@ module Gitlab ...@@ -33,7 +33,7 @@ module Gitlab
def use_primary(&blk) def use_primary(&blk)
used_primary = @use_primary used_primary = @use_primary
@use_primary = true @use_primary = true
return yield yield
ensure ensure
@use_primary = used_primary || @performed_write @use_primary = used_primary || @performed_write
end end
......
...@@ -85,7 +85,7 @@ module Gitlab ...@@ -85,7 +85,7 @@ module Gitlab
sha = head_commit.try(:sha) sha = head_commit.try(:sha)
sha ||= Gitlab::Git::BLANK_SHA sha ||= Gitlab::Git::BLANK_SHA
index_status.update_attributes(last_commit: sha, indexed_at: Time.now) index_status.update(last_commit: sha, indexed_at: Time.now)
project.index_status(true) project.index_status(true)
end end
end end
......
...@@ -87,7 +87,6 @@ module Gitlab ...@@ -87,7 +87,6 @@ module Gitlab
end end
end end
# rubocop: disable Rails/Output
def status def status
Gitlab::Geo::DatabaseTasks.with_geo_db do Gitlab::Geo::DatabaseTasks.with_geo_db do
unless ActiveRecord::SchemaMigration.table_exists? unless ActiveRecord::SchemaMigration.table_exists?
......
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
end end
end end
return '' ''
rescue => e rescue => e
e.message e.message
end end
......
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
encrypted = cipher.update(access_token) + cipher.final encrypted = cipher.update(access_token) + cipher.final
self.state = "#{oauth_salt}:#{Base64.urlsafe_encode64(encrypted)}" self.state = "#{oauth_salt}:#{Base64.urlsafe_encode64(encrypted)}"
rescue OpenSSL::OpenSSLError rescue OpenSSL::OpenSSLError
return false false
end end
def extract_logout_token def extract_logout_token
...@@ -41,7 +41,7 @@ module Gitlab ...@@ -41,7 +41,7 @@ module Gitlab
decipher = logout_token_cipher(salt, :decrypt) decipher = logout_token_cipher(salt, :decrypt)
decipher.update(Base64.urlsafe_decode64(encrypted)) + decipher.final decipher.update(Base64.urlsafe_decode64(encrypted)) + decipher.final
rescue OpenSSL::OpenSSLError rescue OpenSSL::OpenSSLError
return false false
end end
def get_oauth_state_return_to def get_oauth_state_return_to
......
...@@ -81,7 +81,7 @@ module Gitlab ...@@ -81,7 +81,7 @@ module Gitlab
end end
if dryrun if dryrun
puts "Sidekiq command: #{cmd}" # rubocop:disable Rails/Output puts "Sidekiq command: #{cmd}"
return return
end end
......
...@@ -30,7 +30,7 @@ describe Projects::MergeRequests::CreationsController do ...@@ -30,7 +30,7 @@ describe Projects::MergeRequests::CreationsController do
let(:created_merge_request) { assigns(:merge_request) } let(:created_merge_request) { assigns(:merge_request) }
before do before do
project.update_attributes(approvals_before_merge: 2) project.update(approvals_before_merge: 2)
end end
context 'when it is less than the one in the target project' do context 'when it is less than the one in the target project' do
...@@ -81,8 +81,8 @@ describe Projects::MergeRequests::CreationsController do ...@@ -81,8 +81,8 @@ describe Projects::MergeRequests::CreationsController do
context 'when the target project is a fork of a deleted project' do context 'when the target project is a fork of a deleted project' do
before do before do
original_project = create(:project) original_project = create(:project)
project.update_attributes(forked_from_project: original_project, approvals_before_merge: 4) project.update(forked_from_project: original_project, approvals_before_merge: 4)
original_project.update_attributes(pending_delete: true) original_project.update(pending_delete: true)
create_merge_request(approvals_before_merge: 3) create_merge_request(approvals_before_merge: 3)
end end
......
...@@ -99,7 +99,7 @@ describe Projects::MergeRequestsController do ...@@ -99,7 +99,7 @@ describe Projects::MergeRequestsController do
describe 'PUT update' do describe 'PUT update' do
before do before do
project.update_attributes(approvals_before_merge: 2) project.update(approvals_before_merge: 2)
end end
def update_merge_request(params = {}) def update_merge_request(params = {})
...@@ -112,7 +112,7 @@ describe Projects::MergeRequestsController do ...@@ -112,7 +112,7 @@ describe Projects::MergeRequestsController do
context 'when the merge request requires approval' do context 'when the merge request requires approval' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
end end
it_behaves_like 'update invalid issuable', MergeRequest it_behaves_like 'update invalid issuable', MergeRequest
...@@ -120,12 +120,12 @@ describe Projects::MergeRequestsController do ...@@ -120,12 +120,12 @@ describe Projects::MergeRequestsController do
context 'overriding approvers per MR' do context 'overriding approvers per MR' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
end end
context 'enabled' do context 'enabled' do
before do before do
project.update_attributes(disable_overriding_approvers_per_merge_request: false) project.update(disable_overriding_approvers_per_merge_request: false)
end end
it 'updates approvals' do it 'updates approvals' do
...@@ -141,7 +141,7 @@ describe Projects::MergeRequestsController do ...@@ -141,7 +141,7 @@ describe Projects::MergeRequestsController do
before do before do
project.add_developer(new_approver) project.add_developer(new_approver)
project.update_attributes(disable_overriding_approvers_per_merge_request: true) project.update(disable_overriding_approvers_per_merge_request: true)
end end
it 'does not update approvals_before_merge' do it 'does not update approvals_before_merge' do
...@@ -166,7 +166,7 @@ describe Projects::MergeRequestsController do ...@@ -166,7 +166,7 @@ describe Projects::MergeRequestsController do
shared_examples 'approvals_before_merge param' do shared_examples 'approvals_before_merge param' do
before do before do
project.update_attributes(approvals_before_merge: 2) project.update(approvals_before_merge: 2)
end end
context 'approvals_before_merge not set for the existing MR' do context 'approvals_before_merge not set for the existing MR' do
...@@ -296,7 +296,7 @@ describe Projects::MergeRequestsController do ...@@ -296,7 +296,7 @@ describe Projects::MergeRequestsController do
before do before do
upstream.add_developer(user) upstream.add_developer(user)
upstream.update_attributes(approvals_before_merge: 2) upstream.update(approvals_before_merge: 2)
end end
it_behaves_like 'approvals_before_merge param' it_behaves_like 'approvals_before_merge param'
...@@ -307,7 +307,7 @@ describe Projects::MergeRequestsController do ...@@ -307,7 +307,7 @@ describe Projects::MergeRequestsController do
before do before do
project.add_developer(user) project.add_developer(user)
project.update_attributes(approvals_before_merge: 0) project.update(approvals_before_merge: 0)
end end
it_behaves_like 'approvals_before_merge param' it_behaves_like 'approvals_before_merge param'
......
...@@ -10,7 +10,7 @@ FactoryBot.define do ...@@ -10,7 +10,7 @@ FactoryBot.define do
end end
after(:create) do |epic, evaluator| after(:create) do |epic, evaluator|
epic.update_attributes(labels: evaluator.labels) epic.update(labels: evaluator.labels)
end end
end end
end end
......
...@@ -17,7 +17,7 @@ describe 'Merge request > User selects branches for new MR', :js do ...@@ -17,7 +17,7 @@ describe 'Merge request > User selects branches for new MR', :js do
context 'when approvals are zero for the target project' do context 'when approvals are zero for the target project' do
before do before do
project.update_attributes(approvals_before_merge: 0) project.update(approvals_before_merge: 0)
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' }) visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' })
end end
......
...@@ -17,12 +17,12 @@ describe 'Project mirror', :js do ...@@ -17,12 +17,12 @@ describe 'Project mirror', :js do
let(:timestamp) { Time.now } let(:timestamp) { Time.now }
before do before do
import_state.update_attributes(next_execution_timestamp: timestamp + 10.minutes) import_state.update(next_execution_timestamp: timestamp + 10.minutes)
end end
context 'when able to force update' do context 'when able to force update' do
it 'forces import' do it 'forces import' do
import_state.update_attributes(last_update_at: timestamp - 8.minutes) import_state.update(last_update_at: timestamp - 8.minutes)
expect_any_instance_of(EE::Project).to receive(:force_import_job!) expect_any_instance_of(EE::Project).to receive(:force_import_job!)
...@@ -36,7 +36,7 @@ describe 'Project mirror', :js do ...@@ -36,7 +36,7 @@ describe 'Project mirror', :js do
context 'when unable to force update' do context 'when unable to force update' do
it 'does not force import' do it 'does not force import' do
import_state.update_attributes(last_update_at: timestamp - 3.minutes) import_state.update(last_update_at: timestamp - 3.minutes)
expect_any_instance_of(EE::Project).not_to receive(:force_import_job!) expect_any_instance_of(EE::Project).not_to receive(:force_import_job!)
......
...@@ -11,7 +11,7 @@ describe "User manages members" do ...@@ -11,7 +11,7 @@ describe "User manages members" do
shared_examples "when group membership is unlocked" do shared_examples "when group membership is unlocked" do
before do before do
group.update_attributes(membership_lock: false) group.update(membership_lock: false)
visit(project_project_members_path(project)) visit(project_project_members_path(project))
end end
...@@ -21,7 +21,7 @@ describe "User manages members" do ...@@ -21,7 +21,7 @@ describe "User manages members" do
shared_examples "when group membership is locked" do shared_examples "when group membership is locked" do
before do before do
group.update_attributes(membership_lock: true) group.update(membership_lock: true)
visit(project_project_members_path(project)) visit(project_project_members_path(project))
end end
......
...@@ -44,7 +44,7 @@ describe MigrateCiJobArtifactsToSeparateRegistry, :geo, :migration do ...@@ -44,7 +44,7 @@ describe MigrateCiJobArtifactsToSeparateRegistry, :geo, :migration do
expect(job_artifact_registry.all.count).to eq(3) expect(job_artifact_registry.all.count).to eq(3)
entry = file_registry.find_by(file_id: 1) entry = file_registry.find_by(file_id: 1)
entry.update_attributes(success: false, bytes: 10240, sha256: '10' * 64) entry.update(success: false, bytes: 10240, sha256: '10' * 64)
expect(job_artifact_registry.where(artifact_id: 1, success: false, bytes: 10240, sha256: '10' * 64).count).to eq(1) expect(job_artifact_registry.where(artifact_id: 1, success: false, bytes: 10240, sha256: '10' * 64).count).to eq(1)
# Ensure that *only* the correct job artifact is updated # Ensure that *only* the correct job artifact is updated
......
...@@ -71,7 +71,7 @@ describe Project do ...@@ -71,7 +71,7 @@ describe Project do
Timecop.freeze do Timecop.freeze do
expect do expect do
project.update_attributes(mirror: true, mirror_user_id: project.creator.id, import_url: generate(:url)) project.update(mirror: true, mirror_user_id: project.creator.id, import_url: generate(:url))
end.to change { ProjectImportState.count }.by(1) end.to change { ProjectImportState.count }.by(1)
expect(project.import_state.next_execution_timestamp).to eq(Time.now) expect(project.import_state.next_execution_timestamp).to eq(Time.now)
...@@ -85,7 +85,7 @@ describe Project do ...@@ -85,7 +85,7 @@ describe Project do
Timecop.freeze do Timecop.freeze do
expect do expect do
project.update_attributes(mirror: true, mirror_user_id: project.creator.id) project.update(mirror: true, mirror_user_id: project.creator.id)
end.not_to change { ProjectImportState.count } end.not_to change { ProjectImportState.count }
expect(project.import_state.next_execution_timestamp).to eq(Time.now) expect(project.import_state.next_execution_timestamp).to eq(Time.now)
...@@ -123,7 +123,7 @@ describe Project do ...@@ -123,7 +123,7 @@ describe Project do
end end
it 'returns empty if next_execution_timestamp is in the future' do it 'returns empty if next_execution_timestamp is in the future' do
import_state.update_attributes(next_execution_timestamp: timestamp + 2.minutes) import_state.update(next_execution_timestamp: timestamp + 2.minutes)
expect(described_class.mirrors_to_sync(timestamp)).to be_empty expect(described_class.mirrors_to_sync(timestamp)).to be_empty
end end
...@@ -137,7 +137,7 @@ describe Project do ...@@ -137,7 +137,7 @@ describe Project do
end end
it 'returns empty if next_execution_timestamp is in the future' do it 'returns empty if next_execution_timestamp is in the future' do
project.import_state.update_attributes(next_execution_timestamp: timestamp + 2.minutes) project.import_state.update(next_execution_timestamp: timestamp + 2.minutes)
expect(described_class.mirrors_to_sync(timestamp)).to be_empty expect(described_class.mirrors_to_sync(timestamp)).to be_empty
end end
...@@ -167,7 +167,7 @@ describe Project do ...@@ -167,7 +167,7 @@ describe Project do
describe 'hard failing a mirror' do describe 'hard failing a mirror' do
it 'sends a notification' do it 'sends a notification' do
project = create(:project, :mirror, :import_started) project = create(:project, :mirror, :import_started)
project.import_state.update_attributes(retry_count: Gitlab::Mirror::MAX_RETRY) project.import_state.update(retry_count: Gitlab::Mirror::MAX_RETRY)
expect_any_instance_of(EE::NotificationService).to receive(:mirror_was_hard_failed).with(project) expect_any_instance_of(EE::NotificationService).to receive(:mirror_was_hard_failed).with(project)
...@@ -407,7 +407,7 @@ describe Project do ...@@ -407,7 +407,7 @@ describe Project do
expect(RepositoryRemoveRemoteWorker).to receive(:perform_async).with(project.id, ::Repository::MIRROR_REMOTE).and_call_original expect(RepositoryRemoveRemoteWorker).to receive(:perform_async).with(project.id, ::Repository::MIRROR_REMOTE).and_call_original
project.update_attributes(import_url: "http://test.com") project.update(import_url: "http://test.com")
end end
end end
...@@ -416,7 +416,7 @@ describe Project do ...@@ -416,7 +416,7 @@ describe Project do
project = create(:project, :mirror, :import_scheduled) project = create(:project, :mirror, :import_scheduled)
import_state = project.import_state import_state = project.import_state
import_state.update_attributes(last_update_started_at: import_state.last_update_scheduled_at + 5.minutes) import_state.update(last_update_started_at: import_state.last_update_scheduled_at + 5.minutes)
expect(project.mirror_waiting_duration).to eq(300) expect(project.mirror_waiting_duration).to eq(300)
end end
...@@ -426,7 +426,7 @@ describe Project do ...@@ -426,7 +426,7 @@ describe Project do
it 'returns in seconds the time spent updating' do it 'returns in seconds the time spent updating' do
project = create(:project, :mirror, :import_started) project = create(:project, :mirror, :import_started)
project.update_attributes(mirror_last_update_at: project.import_state.last_update_started_at + 5.minutes) project.update(mirror_last_update_at: project.import_state.last_update_started_at + 5.minutes)
expect(project.mirror_update_duration).to eq(300) expect(project.mirror_update_duration).to eq(300)
end end
...@@ -734,7 +734,7 @@ describe Project do ...@@ -734,7 +734,7 @@ describe Project do
context 'when repository_size_limit is configured' do context 'when repository_size_limit is configured' do
before do before do
project.update_attributes(repository_size_limit: 1024) project.update(repository_size_limit: 1024)
end end
context 'with an EES license' do context 'with an EES license' do
......
...@@ -139,7 +139,7 @@ describe PushRule do ...@@ -139,7 +139,7 @@ describe PushRule do
it 'raises a MatchError when the regex is invalid' do it 'raises a MatchError when the regex is invalid' do
push_rule[regex_attr] = '+' push_rule[regex_attr] = '+'
expect { push_rule.public_send(method_name, 'foo') } # rubocop:disable GitlabSecurity/PublicSend expect { push_rule.public_send(method_name, 'foo') }
.to raise_error(PushRule::MatchError, /\ARegular expression '\+' is invalid/) .to raise_error(PushRule::MatchError, /\ARegular expression '\+' is invalid/)
end end
end end
......
...@@ -46,7 +46,7 @@ describe API::MergeRequests do ...@@ -46,7 +46,7 @@ describe API::MergeRequests do
context 'the approvals_before_merge param' do context 'the approvals_before_merge param' do
context 'when the target project has disable_overriding_approvers_per_merge_request set to true' do context 'when the target project has disable_overriding_approvers_per_merge_request set to true' do
before do before do
project.update_attributes(disable_overriding_approvers_per_merge_request: true) project.update(disable_overriding_approvers_per_merge_request: true)
create_merge_request(approvals_before_merge: 1) create_merge_request(approvals_before_merge: 1)
end end
...@@ -57,7 +57,7 @@ describe API::MergeRequests do ...@@ -57,7 +57,7 @@ describe API::MergeRequests do
context 'when the target project has approvals_before_merge set to zero' do context 'when the target project has approvals_before_merge set to zero' do
before do before do
project.update_attributes(approvals_before_merge: 0) project.update(approvals_before_merge: 0)
create_merge_request(approvals_before_merge: 1) create_merge_request(approvals_before_merge: 1)
end end
...@@ -73,7 +73,7 @@ describe API::MergeRequests do ...@@ -73,7 +73,7 @@ describe API::MergeRequests do
context 'when the target project has a non-zero approvals_before_merge' do context 'when the target project has a non-zero approvals_before_merge' do
context 'when the approvals_before_merge param is less than or equal to the value in the target project' do context 'when the approvals_before_merge param is less than or equal to the value in the target project' do
before do before do
project.update_attributes(approvals_before_merge: 2) project.update(approvals_before_merge: 2)
create_merge_request(approvals_before_merge: 1) create_merge_request(approvals_before_merge: 1)
end end
...@@ -88,7 +88,7 @@ describe API::MergeRequests do ...@@ -88,7 +88,7 @@ describe API::MergeRequests do
context 'when the approvals_before_merge param is greater than the value in the target project' do context 'when the approvals_before_merge param is greater than the value in the target project' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
create_merge_request(approvals_before_merge: 2) create_merge_request(approvals_before_merge: 2)
end end
......
...@@ -26,7 +26,7 @@ describe API::ProjectMirror do ...@@ -26,7 +26,7 @@ describe API::ProjectMirror do
def project_in_state(state) def project_in_state(state)
project = create(:project, :repository, namespace: user.namespace) project = create(:project, :repository, namespace: user.namespace)
import_state = create(:import_state, :mirror, state, project: project) import_state = create(:import_state, :mirror, state, project: project)
import_state.update_attributes(next_execution_timestamp: 10.minutes.from_now) import_state.update(next_execution_timestamp: 10.minutes.from_now)
project project
end end
......
...@@ -60,7 +60,7 @@ describe Projects::UpdateMirrorService do ...@@ -60,7 +60,7 @@ describe Projects::UpdateMirrorService do
let(:protected_branch_name) { 'existing-branch' } let(:protected_branch_name) { 'existing-branch' }
before do before do
project.update_attributes(only_mirror_protected_branches: true) project.update(only_mirror_protected_branches: true)
end end
it 'creates a new protected branch' do it 'creates a new protected branch' do
......
...@@ -74,7 +74,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea ...@@ -74,7 +74,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name) subject.perform(shard_name)
reg1.update_attributes!(repository_verification_checksum_sha: project1_repo_verified.repository_state.repository_verification_checksum) reg1.update!(repository_verification_checksum_sha: project1_repo_verified.repository_state.repository_verification_checksum)
expect(secondary_singleworker).to receive(:perform_async).with(reg2.id).once expect(secondary_singleworker).to receive(:perform_async).with(reg2.id).once
...@@ -93,19 +93,19 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea ...@@ -93,19 +93,19 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name) subject.perform(shard_name)
reg1.update_attributes!(repository_verification_checksum_sha: project1_repo_verified.repository_state.repository_verification_checksum) reg1.update!(repository_verification_checksum_sha: project1_repo_verified.repository_state.repository_verification_checksum)
expect(secondary_singleworker).to receive(:perform_async).with(reg2.id).once expect(secondary_singleworker).to receive(:perform_async).with(reg2.id).once
subject.perform(shard_name) subject.perform(shard_name)
reg2.update_attributes!(repository_verification_checksum_sha: project2_repo_verified.repository_state.repository_verification_checksum) reg2.update!(repository_verification_checksum_sha: project2_repo_verified.repository_state.repository_verification_checksum)
expect(secondary_singleworker).to receive(:perform_async).with(reg4.id).once expect(secondary_singleworker).to receive(:perform_async).with(reg4.id).once
subject.perform(shard_name) subject.perform(shard_name)
reg4.update_attributes!(last_wiki_verification_failure: 'Failed!') reg4.update!(last_wiki_verification_failure: 'Failed!')
expect(secondary_singleworker).to receive(:perform_async).with(reg6.id).once expect(secondary_singleworker).to receive(:perform_async).with(reg6.id).once
......
...@@ -88,7 +88,7 @@ describe 'Merge request > User selects branches for new MR', :js do ...@@ -88,7 +88,7 @@ describe 'Merge request > User selects branches for new MR', :js do
context 'when approvals are enabled for the target project' do context 'when approvals are enabled for the target project' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' }) visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'feature_conflict' })
end end
......
...@@ -96,7 +96,7 @@ describe 'Project > Members > Share with Group', :js do ...@@ -96,7 +96,7 @@ describe 'Project > Members > Share with Group', :js do
context 'when the group has membership lock and "Share with group lock" enabled' do context 'when the group has membership lock and "Share with group lock" enabled' do
before do before do
project.namespace.update_attributes(share_with_group_lock: true, membership_lock: true) project.namespace.update(share_with_group_lock: true, membership_lock: true)
end end
it_behaves_like 'the project cannot be shared with groups and members' it_behaves_like 'the project cannot be shared with groups and members'
...@@ -136,7 +136,7 @@ describe 'Project > Members > Share with Group', :js do ...@@ -136,7 +136,7 @@ describe 'Project > Members > Share with Group', :js do
context 'when the group has membership lock and "Share with group lock" enabled' do context 'when the group has membership lock and "Share with group lock" enabled' do
before do before do
subgroup.update_attributes(share_with_group_lock: true, membership_lock: true) subgroup.update(share_with_group_lock: true, membership_lock: true)
end end
it_behaves_like 'the project cannot be shared with groups and members' it_behaves_like 'the project cannot be shared with groups and members'
...@@ -145,7 +145,7 @@ describe 'Project > Members > Share with Group', :js do ...@@ -145,7 +145,7 @@ describe 'Project > Members > Share with Group', :js do
context 'when the root_group has "Share with group lock" and membership lock enabled' do context 'when the root_group has "Share with group lock" and membership lock enabled' do
before do before do
root_group.update_attributes(share_with_group_lock: true, membership_lock: true) root_group.update(share_with_group_lock: true, membership_lock: true)
subgroup.reload subgroup.reload
end end
...@@ -155,7 +155,7 @@ describe 'Project > Members > Share with Group', :js do ...@@ -155,7 +155,7 @@ describe 'Project > Members > Share with Group', :js do
context 'when the subgroup has "Share with group lock" and membership lock disabled (parent overridden)' do context 'when the subgroup has "Share with group lock" and membership lock disabled (parent overridden)' do
before do before do
subgroup.update_attributes(share_with_group_lock: false, membership_lock: false) subgroup.update(share_with_group_lock: false, membership_lock: false)
end end
it_behaves_like 'the project can be shared with groups and members' it_behaves_like 'the project can be shared with groups and members'
...@@ -181,7 +181,7 @@ describe 'Project > Members > Share with Group', :js do ...@@ -181,7 +181,7 @@ describe 'Project > Members > Share with Group', :js do
context 'when the subgroup has "Share with group lock" and membership lock enabled' do context 'when the subgroup has "Share with group lock" and membership lock enabled' do
before do before do
subgroup.update_attributes(membership_lock: true, share_with_group_lock: true) subgroup.update(membership_lock: true, share_with_group_lock: true)
end end
it_behaves_like 'the project cannot be shared with groups and members' it_behaves_like 'the project cannot be shared with groups and members'
......
...@@ -280,7 +280,7 @@ describe Ci::Build do ...@@ -280,7 +280,7 @@ describe Ci::Build do
context 'artifacts metadata does not exist' do context 'artifacts metadata does not exist' do
before do before do
build.update_attributes(legacy_artifacts_metadata: nil) build.update(legacy_artifacts_metadata: nil)
end end
it { is_expected.to be_falsy } it { is_expected.to be_falsy }
......
...@@ -826,7 +826,7 @@ describe MergeRequest do ...@@ -826,7 +826,7 @@ describe MergeRequest do
let(:group) { create(:group) } let(:group) { create(:group) }
before do before do
project.update_attributes(group: group) project.update(group: group)
end end
it "includes group members with developer access and up" do it "includes group members with developer access and up" do
...@@ -913,12 +913,12 @@ describe MergeRequest do ...@@ -913,12 +913,12 @@ describe MergeRequest do
let(:merge_request) { build(:merge_request) } let(:merge_request) { build(:merge_request) }
before do before do
merge_request.target_project.update_attributes(approvals_before_merge: 3) merge_request.target_project.update(approvals_before_merge: 3)
end end
context "when the MR has approvals_before_merge set" do context "when the MR has approvals_before_merge set" do
before do before do
merge_request.update_attributes(approvals_before_merge: 1) merge_request.update(approvals_before_merge: 1)
end end
it "uses the approvals_before_merge from the MR" do it "uses the approvals_before_merge from the MR" do
...@@ -1597,7 +1597,7 @@ describe MergeRequest do ...@@ -1597,7 +1597,7 @@ describe MergeRequest do
before do before do
allow(subject).to receive(:mergeable_state?).and_return(true) allow(subject).to receive(:mergeable_state?).and_return(true)
subject.target_project.update_attributes(approvals_before_merge: 1) subject.target_project.update(approvals_before_merge: 1)
project.add_developer(user) project.add_developer(user)
end end
...@@ -1954,7 +1954,7 @@ describe MergeRequest do ...@@ -1954,7 +1954,7 @@ describe MergeRequest do
context 'when there is one approver' do context 'when there is one approver' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
end end
context 'when that approver is the MR author' do context 'when that approver is the MR author' do
...@@ -1995,7 +1995,7 @@ describe MergeRequest do ...@@ -1995,7 +1995,7 @@ describe MergeRequest do
context 'when there is one approver required' do context 'when there is one approver required' do
before do before do
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
end end
context 'when that approver is the MR author' do context 'when that approver is the MR author' do
...@@ -2046,7 +2046,7 @@ describe MergeRequest do ...@@ -2046,7 +2046,7 @@ describe MergeRequest do
context 'when there are multiple approvers required' do context 'when there are multiple approvers required' do
before do before do
project.update_attributes(approvals_before_merge: 3) project.update(approvals_before_merge: 3)
end end
context 'when one of those approvers is the MR author' do context 'when one of those approvers is the MR author' do
...@@ -2476,7 +2476,7 @@ describe MergeRequest do ...@@ -2476,7 +2476,7 @@ describe MergeRequest do
context 'with approvals' do context 'with approvals' do
before do before do
merge_request.target_project.update_attributes(approvals_before_merge: 1) merge_request.target_project.update(approvals_before_merge: 1)
end end
it 'is not mergeable when not approved' do it 'is not mergeable when not approved' do
......
...@@ -217,7 +217,7 @@ describe Project do ...@@ -217,7 +217,7 @@ describe Project do
it 'fails stuck remote mirrors' do it 'fails stuck remote mirrors' do
project = create(:project, :repository, :remote_mirror) project = create(:project, :repository, :remote_mirror)
project.remote_mirrors.first.update_attributes( project.remote_mirrors.first.update(
update_status: :started, update_status: :started,
last_update_at: 2.days.ago last_update_at: 2.days.ago
) )
...@@ -290,7 +290,7 @@ describe Project do ...@@ -290,7 +290,7 @@ describe Project do
project2 = create(:project) project2 = create(:project)
expect do expect do
project2.update_attributes(mirror: true, import_url: generate(:url), mirror_user: project.creator) project2.update(mirror: true, import_url: generate(:url), mirror_user: project.creator)
end.to change { ProjectImportState.where(project: project2).count }.from(0).to(1) end.to change { ProjectImportState.where(project: project2).count }.from(0).to(1)
end end
......
...@@ -796,7 +796,7 @@ describe API::MergeRequests do ...@@ -796,7 +796,7 @@ describe API::MergeRequests do
it 'returns 405 if merge request was not approved' do it 'returns 405 if merge request was not approved' do
project.add_developer(create(:user)) project.add_developer(create(:user))
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user) put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
...@@ -807,7 +807,7 @@ describe API::MergeRequests do ...@@ -807,7 +807,7 @@ describe API::MergeRequests do
it 'returns 200 if merge request was approved' do it 'returns 200 if merge request was approved' do
approver = create(:user) approver = create(:user)
project.add_developer(approver) project.add_developer(approver)
project.update_attributes(approvals_before_merge: 1) project.update(approvals_before_merge: 1)
merge_request.approvals.create(user: approver) merge_request.approvals.create(user: approver)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user) put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
......
...@@ -260,7 +260,7 @@ describe MergeRequests::UpdateService, :mailer do ...@@ -260,7 +260,7 @@ describe MergeRequests::UpdateService, :mailer do
context 'when not approved' do context 'when not approved' do
before do before do
merge_request.update_attributes(approvals_before_merge: 1) merge_request.update(approvals_before_merge: 1)
perform_enqueued_jobs do perform_enqueued_jobs do
service.execute(merge_request) service.execute(merge_request)
...@@ -274,7 +274,7 @@ describe MergeRequests::UpdateService, :mailer do ...@@ -274,7 +274,7 @@ describe MergeRequests::UpdateService, :mailer do
context 'when approved' do context 'when approved' do
before do before do
merge_request.update_attributes(approvals_before_merge: 1) merge_request.update(approvals_before_merge: 1)
merge_request.approvals.create(user: user) merge_request.approvals.create(user: user)
perform_enqueued_jobs do perform_enqueued_jobs do
......
...@@ -1170,7 +1170,7 @@ describe NotificationService, :mailer do ...@@ -1170,7 +1170,7 @@ describe NotificationService, :mailer do
let(:project_approvers) { create_list(:user, 3) } let(:project_approvers) { create_list(:user, 3) }
before do before do
merge_request.target_project.update_attributes(approvals_before_merge: 1) merge_request.target_project.update(approvals_before_merge: 1)
project_approvers.each { |approver| create(:approver, user: approver, target: merge_request.target_project) } project_approvers.each { |approver| create(:approver, user: approver, target: merge_request.target_project) }
end end
...@@ -1181,7 +1181,7 @@ describe NotificationService, :mailer do ...@@ -1181,7 +1181,7 @@ describe NotificationService, :mailer do
end end
it 'does not email the approvers when approval is not necessary' do it 'does not email the approvers when approval is not necessary' do
merge_request.target_project.update_attributes(approvals_before_merge: 0) merge_request.target_project.update(approvals_before_merge: 0)
notification.new_merge_request(merge_request, @u_disabled) notification.new_merge_request(merge_request, @u_disabled)
project_approvers.each { |approver| should_not_email(approver) } project_approvers.each { |approver| should_not_email(approver) }
......
...@@ -447,7 +447,7 @@ describe QuickActions::InterpretService do ...@@ -447,7 +447,7 @@ describe QuickActions::InterpretService do
context 'not approved merge request can not be merged' do context 'not approved merge request can not be merged' do
before do before do
merge_request.target_project.update_attributes(approvals_before_merge: 1) merge_request.target_project.update(approvals_before_merge: 1)
end end
it_behaves_like 'empty command' do it_behaves_like 'empty command' do
...@@ -458,7 +458,7 @@ describe QuickActions::InterpretService do ...@@ -458,7 +458,7 @@ describe QuickActions::InterpretService do
context 'approved merge request can be merged' do context 'approved merge request can be merged' do
before do before do
merge_request.update_attributes(approvals_before_merge: 1) merge_request.update(approvals_before_merge: 1)
merge_request.approvals.create(user: developer) merge_request.approvals.create(user: developer)
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