File obs-server-2.10-0120-Increase-compatability-with-rails-6.patch of Package obs-server

From f347483eed196ab0cf183803d4407146ccd3d8c2 Mon Sep 17 00:00:00 2001
From: Stephan Kulow <coolo@suse.de>
Date: Sat, 23 Nov 2019 09:06:29 +0100
Subject: [PATCH] Increase compatability with rails 6

nested where clauses need the column name, not the relation
(they still map objects to their ID)

response doesn't react to be_success
---
 .../controllers/cloud/upload_jobs_controller_spec.rb | 12 ++++++------
 .../controllers/services/webhooks_controller_spec.rb |  2 +-
 .../controllers/source_attribute_controller_spec.rb  |  9 +++++----
 .../source_project_config_controller_spec.rb         |  6 +++---
 .../source_project_meta_controller_spec.rb           |  4 ++--
 .../source_project_package_meta_controller_spec.rb   |  6 +++---
 .../webui/cloud/azure/upload_jobs_controller_spec.rb |  3 ++-
 .../webui/cloud/ec2/upload_jobs_controller_spec.rb   |  3 ++-
 .../webui/cloud/upload_job/logs_controller_spec.rb   |  4 ++--
 .../webui/cloud/upload_jobs_controller_spec.rb       |  4 ++--
 .../webui/groups/users_controller_spec.rb            | 10 +++++-----
 11 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb b/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb
index d75500ba07..2173bf0d30 100644
--- a/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb
+++ b/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
         it 'returns an xml response with all cloud upload jobs listed' do
           expect(Xmlhash.parse(response.body)).to eq(Xmlhash.parse(xml_response_list))
         end
-        it { expect(response).to be_success }
+        it { expect(response).to have_http_status(:success) }
       end
     end
 
@@ -81,7 +81,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
         end
       end
 
-      it { expect(response).to be_not_found }
+      it { expect(response).to have_http_status(:success) }
     end
   end
 
@@ -111,7 +111,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
         it 'returns an xml response with all cloud upload jobs listed' do
           expect(Xmlhash.parse(response.body)).to eq(Xmlhash.parse(xml_response_list))
         end
-        it { expect(response).to be_success }
+        it { expect(response).to have_http_status(:success) }
       end
     end
 
@@ -122,7 +122,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
         end
       end
 
-      it { expect(response).to be_not_found }
+      it { expect(response).to have_http_status(:not_found) }
     end
   end
 
@@ -172,7 +172,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
 
       it { expect(Cloud::User::UploadJob.last.job_id).to eq(6) }
       it { expect(Cloud::User::UploadJob.last.user).to eq(user_with_ec2_configuration) }
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
       it { expect(Xmlhash.parse(response.body)).to eq(Xmlhash.parse(xml_response_list)) }
     end
   end
@@ -189,7 +189,7 @@ RSpec.describe Cloud::UploadJobsController, vcr: true do
         end
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
     end
 
     context 'of a not existing upload job' do
diff --git a/src/api/spec/controllers/services/webhooks_controller_spec.rb b/src/api/spec/controllers/services/webhooks_controller_spec.rb
index b79b2bf5de..b796b2735d 100644
--- a/src/api/spec/controllers/services/webhooks_controller_spec.rb
+++ b/src/api/spec/controllers/services/webhooks_controller_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe Services::WebhooksController, type: :controller, vcr: true do
           post :create, body: body, params: { id: service_token.id, project: project.name, package: package.name, format: :xml }
         end
 
-        it { expect(response).to be_success }
+        it { expect(response).to have_http_status(:success) }
       end
 
       context 'when token is invalid' do
diff --git a/src/api/spec/controllers/source_attribute_controller_spec.rb b/src/api/spec/controllers/source_attribute_controller_spec.rb
index d2fe2a83f6..5419c3efb9 100644
--- a/src/api/spec/controllers/source_attribute_controller_spec.rb
+++ b/src/api/spec/controllers/source_attribute_controller_spec.rb
@@ -68,7 +68,7 @@ RSpec.describe SourceAttributeController, vcr: true do
                      body: xml_attrib
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
     end
 
     context 'update invalid attribute' do
@@ -91,7 +91,8 @@ RSpec.describe SourceAttributeController, vcr: true do
                      body: wrong_xml_attrib
       end
 
-      it { expect(response).not_to be_success }
+      it { expect(response).not_to have_http_status(:success) }
+
       it 'gives the right status code' do
         resp = Xmlhash.parse(response.body)
         expect(resp.elements('code')).to include('unknown_attribute_type')
@@ -109,7 +110,7 @@ RSpec.describe SourceAttributeController, vcr: true do
                                   format: :xml }
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
       it { expect(project.reload.attribs).to be_empty }
     end
 
@@ -123,7 +124,7 @@ RSpec.describe SourceAttributeController, vcr: true do
                                   format: :xml }
       end
 
-      it { expect(response).not_to be_success }
+      it { expect(response).not_to have_http_status(:success) }
       it { expect(project.attribs).not_to be_empty }
       it 'gives the right status code' do
         resp = Xmlhash.parse(response.body)
diff --git a/src/api/spec/controllers/source_project_config_controller_spec.rb b/src/api/spec/controllers/source_project_config_controller_spec.rb
index c17ceb3961..5cf9ae1cd3 100644
--- a/src/api/spec/controllers/source_project_config_controller_spec.rb
+++ b/src/api/spec/controllers/source_project_config_controller_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe SourceProjectConfigController, vcr: true do
         get :show, params: { project: project }
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
     end
 
     context 'when the project doesnt exist' do
@@ -44,7 +44,7 @@ RSpec.describe SourceProjectConfigController, vcr: true do
         put :update, params: { project: project, comment: 'Updated by test' }
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
       it { expect(project.config.content).to include('Updated', 'by', 'test') }
     end
 
@@ -56,7 +56,7 @@ RSpec.describe SourceProjectConfigController, vcr: true do
         put :update, params: { project: project, comment: 'add preinstall' }, body: config
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
       it { expect(project.config.content).to include('Preinstall') }
     end
   end
diff --git a/src/api/spec/controllers/source_project_meta_controller_spec.rb b/src/api/spec/controllers/source_project_meta_controller_spec.rb
index 80fad71890..75e1400270 100644
--- a/src/api/spec/controllers/source_project_meta_controller_spec.rb
+++ b/src/api/spec/controllers/source_project_meta_controller_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe SourceProjectMetaController, vcr: true do
       get :show, params: { project: project }
     end
 
-    it { expect(response).to be_success }
+    it { expect(response).to have_http_status(:success) }
     it { expect(Xmlhash.parse(response.body)['name']).to eq(project.name) }
   end
 
@@ -33,7 +33,7 @@ RSpec.describe SourceProjectMetaController, vcr: true do
       put :update, params: { project: project }, body: meta, format: :xml
     end
 
-    it { expect(response).to be_success }
+    it { expect(response).to have_http_status(:success) }
     it { expect(project.meta.content).to eq(meta) }
   end
 end
diff --git a/src/api/spec/controllers/source_project_package_meta_controller_spec.rb b/src/api/spec/controllers/source_project_package_meta_controller_spec.rb
index 38d6329554..ceaa9e7c01 100644
--- a/src/api/spec/controllers/source_project_package_meta_controller_spec.rb
+++ b/src/api/spec/controllers/source_project_package_meta_controller_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe SourceProjectPackageMetaController, vcr: true do
                              package: 'foo', format: :xml }
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
     end
 
     context 'package do not exist' do
@@ -29,7 +29,7 @@ RSpec.describe SourceProjectPackageMetaController, vcr: true do
                              package: 'bar', format: :xml }
       end
 
-      it { expect(response).not_to be_success }
+      it { expect(response).not_to have_http_status(:success) }
     end
   end
 
@@ -54,7 +54,7 @@ RSpec.describe SourceProjectPackageMetaController, vcr: true do
                      body: meta, format: :xml
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
     end
 
     context 'bad XML' do
diff --git a/src/api/spec/controllers/webui/cloud/azure/upload_jobs_controller_spec.rb b/src/api/spec/controllers/webui/cloud/azure/upload_jobs_controller_spec.rb
index 010dee5f96..581b1222bd 100644
--- a/src/api/spec/controllers/webui/cloud/azure/upload_jobs_controller_spec.rb
+++ b/src/api/spec/controllers/webui/cloud/azure/upload_jobs_controller_spec.rb
@@ -39,7 +39,8 @@ RSpec.describe Webui::Cloud::Azure::UploadJobsController, type: :controller, vcr
         end
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
+
       it {
         expect(assigns(:upload_job)).
           to have_attributes(project: 'AzureImages', package: 'MyAzureImage', repository: 'standard', arch: 'x86_64', filename: 'appliance.raw.xz')
diff --git a/src/api/spec/controllers/webui/cloud/ec2/upload_jobs_controller_spec.rb b/src/api/spec/controllers/webui/cloud/ec2/upload_jobs_controller_spec.rb
index 405281d327..5af4deb32b 100644
--- a/src/api/spec/controllers/webui/cloud/ec2/upload_jobs_controller_spec.rb
+++ b/src/api/spec/controllers/webui/cloud/ec2/upload_jobs_controller_spec.rb
@@ -37,7 +37,8 @@ RSpec.describe Webui::Cloud::Ec2::UploadJobsController, type: :controller, vcr:
         end
       end
 
-      it { expect(response).to be_success }
+      it { expect(response).to have_http_status(:success) }
+
       it {
         expect(assigns(:upload_job)).
           to have_attributes(project: 'EC2Images', package: 'MyEC2Image', repository: 'standard', arch: 'x86_64', filename: 'appliance.raw.xz')
diff --git a/src/api/spec/controllers/webui/cloud/upload_job/logs_controller_spec.rb b/src/api/spec/controllers/webui/cloud/upload_job/logs_controller_spec.rb
index 61dc518227..53de8ef7db 100644
--- a/src/api/spec/controllers/webui/cloud/upload_job/logs_controller_spec.rb
+++ b/src/api/spec/controllers/webui/cloud/upload_job/logs_controller_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe Webui::Cloud::UploadJob::LogsController, type: :controller, vcr:
             end
           end
 
-          it { expect(response).to be_success }
+          it { expect(response).to have_http_status(:success) }
           it { expect(response.body).to eq(log) }
         end
 
@@ -64,7 +64,7 @@ RSpec.describe Webui::Cloud::UploadJob::LogsController, type: :controller, vcr:
         end
       end
 
-      it { expect(response).to be_not_found }
+      it { expect(response).to have_http_status(:not_found) }
     end
   end
 end
diff --git a/src/api/spec/controllers/webui/cloud/upload_jobs_controller_spec.rb b/src/api/spec/controllers/webui/cloud/upload_jobs_controller_spec.rb
index f6b182b570..daeaa34820 100644
--- a/src/api/spec/controllers/webui/cloud/upload_jobs_controller_spec.rb
+++ b/src/api/spec/controllers/webui/cloud/upload_jobs_controller_spec.rb
@@ -66,7 +66,7 @@ RSpec.describe Webui::Cloud::UploadJobsController, type: :controller, vcr: true
 
         it { expect(assigns(:upload_jobs).length).to eq(1) }
         it { expect(assigns(:upload_jobs).first.id).to eq('6') }
-        it { expect(response).to be_success }
+        it { expect(response).to have_http_status(:success) }
       end
     end
 
@@ -77,7 +77,7 @@ RSpec.describe Webui::Cloud::UploadJobsController, type: :controller, vcr: true
         end
       end
 
-      it { expect(response).to be_not_found }
+      it { expect(response).to have_http_status(:not_found) }
     end
   end
 
diff --git a/src/api/spec/controllers/webui/groups/users_controller_spec.rb b/src/api/spec/controllers/webui/groups/users_controller_spec.rb
index 98067caa50..99e3463f8b 100644
--- a/src/api/spec/controllers/webui/groups/users_controller_spec.rb
+++ b/src/api/spec/controllers/webui/groups/users_controller_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Webui::Groups::UsersController do
       it 'adds the user to the group' do
         expect(response).to redirect_to(group_show_path(title: group.title))
         expect(flash[:success]).to eq("Added user '#{user}' to group '#{group}'")
-        expect(group.users.where(groups_users: { user: user })).to exist
+        expect(group.users.where(groups_users: { user_id: user })).to exist
       end
     end
 
@@ -28,7 +28,7 @@ RSpec.describe Webui::Groups::UsersController do
       end
 
       it { expect(flash[:error]).to eq("User 'unknown_user' not found") }
-      it { expect(group.users.where(groups_users: { user: user })).not_to exist }
+      it { expect(group.users.where(groups_users: { user_id: user })).not_to exist }
     end
 
     context 'when the group does not exist' do
@@ -78,7 +78,7 @@ RSpec.describe Webui::Groups::UsersController do
       it 'removes the user from the group' do
         expect(response).to have_http_status(:success)
         expect(flash[:success]).to eq("Removed user from group '#{group}'")
-        expect(group.users.where(groups_users: { user: user })).not_to exist
+        expect(group.users.where(groups_users: { user_id: user })).not_to exist
       end
     end
 
@@ -89,7 +89,7 @@ RSpec.describe Webui::Groups::UsersController do
 
       it { expect(response).to have_http_status(:not_found) }
       it { expect(flash[:error]).to eq("User 'unknown_user' not found in group '#{group}'") }
-      it { expect(group.users.where(groups_users: { user: user })).not_to exist }
+      it { expect(group.users.where(groups_users: { user_id: user })).not_to exist }
     end
 
     context 'when the group does not exist' do
@@ -154,7 +154,7 @@ RSpec.describe Webui::Groups::UsersController do
 
       it { expect(response).to have_http_status(:not_found) }
       it { expect(flash[:error]).to eq("User 'unknown_user' not found in group '#{group}'") }
-      it { expect(group.users.where(groups_users: { user: user })).not_to exist }
+      it { expect(group.users.where(groups_users: { user_id: user })).not_to exist }
     end
 
     context 'when the group does not exist' do
-- 
2.31.1