From a0c543ee3e81e099e9a369afc5838ba9d6376bc6 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sat, 23 Nov 2019 09:18:06 +0100 Subject: [PATCH 1/2] Pass the view paths as array to ActionView::Base.new Rails 6 can't handle Rails::Root::Path itself --- src/api/app/mixins/can_render_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/app/mixins/can_render_model.rb b/src/api/app/mixins/can_render_model.rb index 400329b7c2f..ffc94223d1f 100644 --- a/src/api/app/mixins/can_render_model.rb +++ b/src/api/app/mixins/can_render_model.rb @@ -3,7 +3,7 @@ # and use my_model to access the model instead of self module CanRenderModel def render_xml(locals = {}) - action_view = ActionView::Base.new(Rails.configuration.paths['app/views']) + action_view = ActionView::Base.new(Rails.configuration.paths['app/views'].to_ary) locals[:my_model] = self action_view.render partial: "models/#{self.class.name.underscore}", formats: [:xml], locals: locals From 1db9c3277cf02f4eb1375a66f9bb744a8b9e163e Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sat, 23 Nov 2019 09:06:29 +0100 Subject: [PATCH 2/2] 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 | 8 ++++---- .../controllers/services/webhooks_controller_spec.rb | 2 +- .../controllers/source_attribute_controller_spec.rb | 8 ++++---- .../source_project_config_controller_spec.rb | 6 +++--- .../controllers/source_project_meta_controller_spec.rb | 4 ++-- .../source_project_package_meta_controller_spec.rb | 6 +++--- .../webui/cloud/azure/upload_jobs_controller_spec.rb | 2 +- .../webui/cloud/ec2/upload_jobs_controller_spec.rb | 2 +- .../webui/cloud/upload_job/logs_controller_spec.rb | 2 +- .../webui/cloud/upload_jobs_controller_spec.rb | 2 +- .../controllers/webui/groups/users_controller_spec.rb | 10 +++++----- 11 files changed, 26 insertions(+), 26 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 211b9fb41c3..34ab2ea747e 100644 --- a/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb +++ b/src/api/spec/controllers/cloud/upload_jobs_controller_spec.rb @@ -68,7 +68,7 @@ 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 @@ -96,7 +96,7 @@ 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 @@ -146,7 +146,7 @@ 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 @@ -161,7 +161,7 @@ delete :destroy, params: { id: upload_job.job_id }, format: 'xml' 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 b79b2bf5de3..b796b2735d4 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 @@ 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 d88bc71bc9d..bc6656e61fc 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 @@ 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,7 @@ 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) @@ -110,7 +110,7 @@ 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 @@ -124,7 +124,7 @@ 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 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 c17ceb3961d..5cf9ae1cd38 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 @@ 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 @@ 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 @@ 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 80fad718906..75e1400270d 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 @@ 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 @@ 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 38d6329554a..ceaa9e7c016 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 @@ 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 @@ 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 @@ 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 72894e71372..b65092167e2 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 @@ -37,7 +37,7 @@ get :new, params: { project: 'AzureImages', package: 'MyAzureImage', repository: 'standard', arch: 'x86_64', filename: 'appliance.raw.xz' } end - it { expect(response).to be_success } + it { expect(response).to have_http_status(:success) } it { expect(assigns(:upload_job)). 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 0cd4f909c52..8cdc4167ff1 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 @@ -35,7 +35,7 @@ get :new, params: { project: 'EC2Images', package: 'MyEC2Image', repository: 'standard', arch: 'x86_64', filename: 'appliance.raw.xz' } end - it { expect(response).to be_success } + it { expect(response).to have_http_status(:success) } it { expect(assigns(:upload_job)). 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 4b449fc5eba..c0f6e2da928 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 @@ -34,7 +34,7 @@ get :show, params: { upload_id: upload_job.job_id } end - it { expect(response).to be_success } + it { expect(response).to have_http_status(:success) } it { expect(response.body).to eq(log) } 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 df19277730e..1c98732b76e 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 @@ -61,7 +61,7 @@ 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 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 98067caa50d..99e3463f8b6 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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