File obs-server-2.10-0126-Replace-update_attributes-by-update-in-specs.patch of Package obs-server

From a43a42f15955caa9be0a1eb4795af322b36bdf7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Saray=20Cabrera=20Padr=C3=B3n?= <scabrerapadron@suse.de>
Date: Wed, 6 May 2020 18:34:32 +0200
Subject: [PATCH] Replace update_attributes by update in specs

Method update_attributes is deprecated and will be removed from Rails
6.1.
---
 .../bootstrap/features/webui/requests_spec.rb    |  6 +++---
 .../status/reports_controller_spec.rb            |  4 ++--
 .../controllers/webui/request_controller_spec.rb |  2 +-
 .../controllers/webui/user_controller_spec.rb    |  2 +-
 .../controllers/webui/webui_controller_spec.rb   |  8 ++++----
 src/api/spec/factories/bs_requests.rb            |  2 +-
 src/api/spec/features/webui/requests_spec.rb     |  6 +++---
 src/api/spec/helpers/webui/user_helper_spec.rb   |  4 ++--
 .../bs_request_action_webui_infos_job_spec.rb    |  2 +-
 src/api/spec/lib/statistics_calculations_spec.rb |  2 +-
 src/api/spec/models/download_repository_spec.rb  |  2 +-
 src/api/spec/models/owner_search_spec.rb         | 16 ++++++++--------
 src/api/spec/models/user_spec.rb                 |  2 +-
 13 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/api/spec/bootstrap/features/webui/requests_spec.rb b/src/api/spec/bootstrap/features/webui/requests_spec.rb
index ae415f1d8a..bd6d704025 100644
--- a/src/api/spec/bootstrap/features/webui/requests_spec.rb
+++ b/src/api/spec/bootstrap/features/webui/requests_spec.rb
@@ -241,11 +241,11 @@ RSpec.feature 'Bootstrap_Requests', type: :feature, js: true, vcr: true do
 
   describe 'shows the correct auto accepted message' do
     before do
-      bs_request.update_attributes(accept_at: Time.now)
+      bs_request.update(accept_at: Time.now)
     end
 
     scenario 'when request is in a final state' do
-      bs_request.update_attributes(state: :accepted)
+      bs_request.update(state: :accepted)
       visit request_show_path(bs_request)
       expect(page).to have_text("Auto-accept was set to #{I18n.localize bs_request.accept_at, format: :only_date}.")
     end
@@ -256,7 +256,7 @@ RSpec.feature 'Bootstrap_Requests', type: :feature, js: true, vcr: true do
     end
 
     scenario 'when request auto_accept is in the future and not in a final state' do
-      bs_request.update_attributes(accept_at: Time.now + 1.day)
+      bs_request.update(accept_at: Time.now + 1.day)
       visit request_show_path(bs_request)
       expect(page).
         to have_text("This request will be automatically accepted in #{ApplicationController.helpers.time_ago_in_words(bs_request.accept_at)}.")
diff --git a/src/api/spec/controllers/status/reports_controller_spec.rb b/src/api/spec/controllers/status/reports_controller_spec.rb
index 743830eff3..f1686d3324 100644
--- a/src/api/spec/controllers/status/reports_controller_spec.rb
+++ b/src/api/spec/controllers/status/reports_controller_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Status::ReportsController, type: :controller do
       let!(:check) { create(:check, status_report: status_report, name: 'ExampleCI') }
 
       before do
-        repository.update_attributes!(required_checks: ['openQA'])
+        repository.update!(required_checks: ['openQA'])
       end
 
       subject! { get :show, params: { project_name: project.name, repository_name: repository.name, report_uuid: status_report.uuid }, format: :xml }
@@ -50,7 +50,7 @@ RSpec.describe Status::ReportsController, type: :controller do
       let!(:check) { create(:check, status_report: status_report, name: 'ExampleCI') }
 
       before do
-        repository_architecture.update_attributes!(required_checks: ['openQA'])
+        repository_architecture.update!(required_checks: ['openQA'])
       end
 
       subject! do
diff --git a/src/api/spec/controllers/webui/request_controller_spec.rb b/src/api/spec/controllers/webui/request_controller_spec.rb
index 0ac94030bf..cb814322f0 100644
--- a/src/api/spec/controllers/webui/request_controller_spec.rb
+++ b/src/api/spec/controllers/webui/request_controller_spec.rb
@@ -294,7 +294,7 @@ RSpec.describe Webui::RequestController, vcr: true do
       end
 
       it 'with invalid transition' do
-        request_with_review.update_attributes(state: 'declined')
+        request_with_review.update(state: 'declined')
         post :modify_review, params: { comment: 'yeah',
                                        request_number: request_with_review.number,
                                        by_user: reviewer,
diff --git a/src/api/spec/controllers/webui/user_controller_spec.rb b/src/api/spec/controllers/webui/user_controller_spec.rb
index 831394fe60..f918fa119d 100644
--- a/src/api/spec/controllers/webui/user_controller_spec.rb
+++ b/src/api/spec/controllers/webui/user_controller_spec.rb
@@ -313,7 +313,7 @@ RSpec.describe Webui::UserController do
       end
 
       it 'handles validation errors' do
-        user.update_attributes(email: 'invalid')
+        user.update(email: 'invalid')
         user.save!(validate: false)
         delete :delete, params: { user: { login: user.login } }
         expect(user.reload.state).to eq('confirmed')
diff --git a/src/api/spec/controllers/webui/webui_controller_spec.rb b/src/api/spec/controllers/webui/webui_controller_spec.rb
index fb1e5cadeb..c04fd70fa1 100644
--- a/src/api/spec/controllers/webui/webui_controller_spec.rb
+++ b/src/api/spec/controllers/webui/webui_controller_spec.rb
@@ -30,14 +30,14 @@ RSpec.describe Webui::WebuiController do
 
   describe 'GET index as nobody' do
     it 'is allowed when Configuration.anonymous is true' do
-      Configuration.update_attributes(anonymous: true)
+      Configuration.update(anonymous: true)
 
       get :index
       expect(response).to have_http_status(:success)
     end
 
     it 'is not allowed when Configuration.anonymous is false' do
-      Configuration.update_attributes(anonymous: false)
+      Configuration.update(anonymous: false)
 
       get :index
       expect(response).to redirect_to(root_path)
@@ -47,12 +47,12 @@ RSpec.describe Webui::WebuiController do
   describe 'GET index as a user' do
     it 'is always allowed' do
       login(create(:confirmed_user))
-      Configuration.update_attributes(anonymous: true)
+      Configuration.update(anonymous: true)
 
       get :index
       expect(response).to have_http_status(:success)
 
-      Configuration.update_attributes(anonymous: false)
+      Configuration.update(anonymous: false)
 
       get :index
       expect(response).to have_http_status(:success)
diff --git a/src/api/spec/factories/bs_requests.rb b/src/api/spec/factories/bs_requests.rb
index 5df2d89d68..28109eb737 100644
--- a/src/api/spec/factories/bs_requests.rb
+++ b/src/api/spec/factories/bs_requests.rb
@@ -111,7 +111,7 @@ FactoryBot.define do
       state = evaluator.state
       state ||= :review if evaluator.reviews.present?
       if state
-        request.update_attributes(state: state)
+        request.update(state: state)
         request.reload
       end
     end
diff --git a/src/api/spec/features/webui/requests_spec.rb b/src/api/spec/features/webui/requests_spec.rb
index 224062111b..2ebc6d264b 100644
--- a/src/api/spec/features/webui/requests_spec.rb
+++ b/src/api/spec/features/webui/requests_spec.rb
@@ -231,11 +231,11 @@ RSpec.feature 'Requests', type: :feature, js: true do
 
   describe 'shows the correct auto accepted message' do
     before do
-      bs_request.update_attributes(accept_at: Time.now)
+      bs_request.update(accept_at: Time.now)
     end
 
     scenario 'when request is in a final state' do
-      bs_request.update_attributes(state: :accepted)
+      bs_request.update(state: :accepted)
       visit request_show_path(bs_request)
       expect(page).to have_text("Auto-accept was set to #{I18n.localize bs_request.accept_at, format: :only_date}.")
     end
@@ -246,7 +246,7 @@ RSpec.feature 'Requests', type: :feature, js: true do
     end
 
     scenario 'when request auto_accept is in the future and not in a final state' do
-      bs_request.update_attributes(accept_at: Time.now + 1.day)
+      bs_request.update(accept_at: Time.now + 1.day)
       visit request_show_path(bs_request)
       expect(page).
         to have_text("This request will be automatically accepted in #{ApplicationController.helpers.time_ago_in_words(bs_request.accept_at)}.")
diff --git a/src/api/spec/helpers/webui/user_helper_spec.rb b/src/api/spec/helpers/webui/user_helper_spec.rb
index f6d823e918..d1403ad257 100644
--- a/src/api/spec/helpers/webui/user_helper_spec.rb
+++ b/src/api/spec/helpers/webui/user_helper_spec.rb
@@ -17,12 +17,12 @@ RSpec.describe Webui::UserHelper do
       end
 
       it 'falls back to users login if realname is empty' do
-        user.update_attributes(realname: '')
+        user.update(realname: '')
         expect(user_and_role(user.login)).to include(link_to(user.login, user_show_path(user: user)))
       end
 
       it 'shows user login and role if realname is empty and role is given' do
-        user.update_attributes(realname: '')
+        user.update(realname: '')
         expect(user_and_role(user.login, role)).to include(link_to("#{user.login} as bugowner", user_show_path(user: user)))
       end
 
diff --git a/src/api/spec/jobs/bs_request_action_webui_infos_job_spec.rb b/src/api/spec/jobs/bs_request_action_webui_infos_job_spec.rb
index 4f8cac890e..65f59ca935 100644
--- a/src/api/spec/jobs/bs_request_action_webui_infos_job_spec.rb
+++ b/src/api/spec/jobs/bs_request_action_webui_infos_job_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe BsRequestActionWebuiInfosJob, type: :job, vcr: true do
 
       let(:path) { "#{CONFIG['source_url']}/source/#{another_source_project}/#{another_source_package}?#{params.to_param}" }
       before do
-        request.update_attributes(superseded_by: superseding_request.number, state: :superseded)
+        request.update(superseded_by: superseding_request.number, state: :superseded)
       end
 
       subject! { BsRequestActionWebuiInfosJob.new.perform(superseding_request_action) }
diff --git a/src/api/spec/lib/statistics_calculations_spec.rb b/src/api/spec/lib/statistics_calculations_spec.rb
index 93b1253f8d..c5b4c68f1c 100644
--- a/src/api/spec/lib/statistics_calculations_spec.rb
+++ b/src/api/spec/lib/statistics_calculations_spec.rb
@@ -74,7 +74,7 @@ RSpec.describe StatisticsCalculations do
 
       before do
         # We need to be able to identify the project
-        package_3.project.update_attributes!(name: 'my_project')
+        package_3.project.update!(name: 'my_project')
       end
 
       it { expect(subject.length).to eq(2) }
diff --git a/src/api/spec/models/download_repository_spec.rb b/src/api/spec/models/download_repository_spec.rb
index 6ad802f4b5..35d6bca51d 100644
--- a/src/api/spec/models/download_repository_spec.rb
+++ b/src/api/spec/models/download_repository_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe DownloadRepository do
     describe 'architecture_inclusion validation' do
       subject(:download_repository) { create(:download_repository) }
       it {
-        expect { download_repository.update_attributes!(arch: 's390x') }.to raise_error(
+        expect { download_repository.update!(arch: 's390x') }.to raise_error(
           ActiveRecord::RecordInvalid, 'Validation failed: Architecture has to be available via repository association'
         )
       }
diff --git a/src/api/spec/models/owner_search_spec.rb b/src/api/spec/models/owner_search_spec.rb
index ddbe009296..a394f9aaaf 100644
--- a/src/api/spec/models/owner_search_spec.rb
+++ b/src/api/spec/models/owner_search_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe OwnerSearch do
       # the User.owner is only interesting for locked accounts
       it 'does not respect User.owner' do
         create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
-        user.update_attributes(owner: develuser)
+        user.update(owner: develuser)
 
         subject = OwnerSearch::Container.new(devel: false, filter: 'bugowner').for(package).first
         expect(subject.users['bugowner']).to eq([user])
@@ -39,7 +39,7 @@ RSpec.describe OwnerSearch do
 
       it 'respects User.state' do
         create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
-        user.update_attributes(state: :locked)
+        user.update(state: :locked)
 
         subject = OwnerSearch::Container.new(devel: false, filter: 'bugowner').for(package)
         expect(subject).to eq([])
@@ -68,7 +68,7 @@ RSpec.describe OwnerSearch do
 
       it 'respects User.state' do
         create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
-        user.update_attributes(state: :locked)
+        user.update(state: :locked)
 
         subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find.first
         expect(subject.rootproject).to eq('home:Iggy')
@@ -79,12 +79,12 @@ RSpec.describe OwnerSearch do
 
       it 'respects User.owner' do
         create(:relationship_package_user, package: package, user: user, role: Role.find_by_title('bugowner'))
-        user.update_attributes(owner: develuser)
+        user.update(owner: develuser)
 
         subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find
         expect(subject).to eq([])
 
-        develuser.update_attributes(state: :locked)
+        develuser.update(state: :locked)
 
         subject = OwnerSearch::Missing.new(devel: false, filter: 'bugowner').find.first
         expect(subject.rootproject).to eq('home:Iggy')
@@ -95,7 +95,7 @@ RSpec.describe OwnerSearch do
 
     context 'in maintenance projects' do
       let(:project) { Project.find_by(name: 'home:Iggy') }
-      let!(:project_kind) { project.update_attributes(kind: 'maintenance_release') }
+      let!(:project_kind) { project.update(kind: 'maintenance_release') }
       let(:other_user) { create(:confirmed_user, login: 'hans') }
 
       # A package with bugowner develuser
@@ -106,7 +106,7 @@ RSpec.describe OwnerSearch do
       # A local link to package.42 with bugowner other_user
       let(:package) { create(:package, name: 'package', project: project) }
       # FIXME: package link should be a transitive argument to the package factory
-      let!(:package_link) { package.build_backend_package.update_attributes(links_to_id: package_42) }
+      let!(:package_link) { package.build_backend_package.update(links_to_id: package_42) }
       let!(:other_bugowner) { create(:relationship_package_user_as_bugowner, user: other_user, package: package) }
 
       # A patchinfo with bugowner maintenance_user
@@ -130,7 +130,7 @@ RSpec.describe OwnerSearch do
       context 'with owned user' do
         let(:owning) { create(:confirmed_user) }
         before do
-          other_user.update_attributes(owner: owning, state: :subaccount)
+          other_user.update(owner: owning, state: :subaccount)
         end
 
         it 'still returns the owned user as bugowner' do
diff --git a/src/api/spec/models/user_spec.rb b/src/api/spec/models/user_spec.rb
index 2afccdc3b3..d08025c845 100644
--- a/src/api/spec/models/user_spec.rb
+++ b/src/api/spec/models/user_spec.rb
@@ -418,7 +418,7 @@ RSpec.describe User do
 
   describe '.mark_login!' do
     before do
-      user.update_attributes!(login_failure_count: 7, last_logged_in_at: 3.hours.ago)
+      user.update!(login_failure_count: 7, last_logged_in_at: 3.hours.ago)
       user.mark_login!
     end
 
-- 
2.31.1