Skip to content

Commit

Permalink
Remove compatibility patch for Rails upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
philippthun committed Feb 4, 2025
1 parent 4d363c2 commit 466bc72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 126 deletions.
8 changes: 0 additions & 8 deletions lib/cloud_controller/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,3 @@ def self.logger
end
end
end

if Rails::VERSION::MAJOR < 8
module ActiveModel
# rubocop:disable Lint/EmptyClass
class ValidationContext; end
# rubocop:enable Lint/EmptyClass
end
end
121 changes: 3 additions & 118 deletions spec/unit/jobs/deserialization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,119 +118,7 @@ module Jobs

subject(:job) { SpaceApplyManifestActionJob.new(space, app_guid_message_hash, apply_manifest_action, user_audit_info) }

let(:serialized_job_rails_7) do
<<~EOS
--- !ruby/object:VCAP::CloudController::Jobs::LoggingContextJob
handler: !ruby/object:VCAP::CloudController::Jobs::TimeoutJob
handler: !ruby/object:VCAP::CloudController::Jobs::SpaceApplyManifestActionJob
space: !ruby/object:VCAP::CloudController::Space
values:
:id: #{space.id}
:guid: space-guid
:created_at: #{space.created_at.strftime('%F %H:%M:%S.%9N Z')}
:updated_at: #{space.updated_at.strftime('%F %H:%M:%S.%9N Z')}
:name: space-name
:organization_id: #{org.id}
:space_quota_definition_id:#{' '}
:allow_ssh: true
:isolation_segment_guid:#{' '}
app_guid_message_hash:
app-guid: &1 !ruby/object:VCAP::CloudController::AppManifestMessage
requested_keys:
- :name
- :instances
- :routes
- :buildpack
- :stack
extra_keys: []
buildpack: ruby
instances: 4
name: app-name
routes:
- :route: app.bommel
stack: cflinuxfs4
original_yaml:
:name: app-name
:instances: 4
:routes:
- :route: app.bommel
:buildpack: ruby
:stack: cflinuxfs4
validation_context:#{' '}
errors: !ruby/object:ActiveModel::Errors
base: *1
errors: []
manifest_process_scale_messages:
- &2 !ruby/object:VCAP::CloudController::ManifestProcessScaleMessage
requested_keys:
- :instances
- :type
extra_keys: []
instances: 4
type: web
validation_context:#{' '}
errors: !ruby/object:ActiveModel::Errors
base: *2
errors: []
manifest_process_update_messages: []
app_update_message: &3 !ruby/object:VCAP::CloudController::AppUpdateMessage
requested_keys:
- :lifecycle
extra_keys: []
lifecycle:
:data:
:buildpacks:
- ruby
:stack: cflinuxfs4
validation_context:#{' '}
errors: !ruby/object:ActiveModel::Errors
base: *3
errors: []
manifest_buildpack_message: &4 !ruby/object:VCAP::CloudController::ManifestBuildpackMessage
requested_keys:
- :buildpack
extra_keys: []
buildpack: ruby
validation_context:#{' '}
errors: !ruby/object:ActiveModel::Errors
base: *4
errors: []
manifest_routes_update_message: &5 !ruby/object:VCAP::CloudController::ManifestRoutesUpdateMessage
requested_keys:
- :routes
extra_keys: []
routes:
- :route: app.bommel
validation_context:#{' '}
errors: !ruby/object:ActiveModel::Errors
base: *5
errors: []
manifest_route_mappings:
- :route: !ruby/object:VCAP::CloudController::ManifestRoute
attrs:
:scheme: unspecified
:user:#{' '}
:password:#{' '}
:host: app.bommel
:port:#{' '}
:path: ''
:query:#{' '}
:fragment:#{' '}
:full_route: app.bommel
:options: {}
:protocol:#{' '}
apply_manifest_action: !ruby/object:VCAP::CloudController::AppApplyManifest
user_audit_info: &6 !ruby/object:VCAP::CloudController::UserAuditInfo
user_email: [email protected]
user_name: user-name
user_guid: user-guid
user_audit_info: *6
timeout: 14400
request_id:#{' '}
EOS
end

let(:serialized_job_rails_8) do
let(:serialized_job) do
<<~EOS
--- !ruby/object:VCAP::CloudController::Jobs::LoggingContextJob
handler: !ruby/object:VCAP::CloudController::Jobs::TimeoutJob
Expand Down Expand Up @@ -357,15 +245,12 @@ module Jobs
ManifestBuildpackMessage, AppUpdateMessage, ManifestProcessScaleMessage, AppManifestMessage, Space, SpaceApplyManifestActionJob, TimeoutJob,
LoggingContextJob]
db_job = YAML.safe_load(jobs_in_db[0][:handler], permitted_classes: permitted_classes, aliases: true).as_json
dumped_job = YAML.safe_load(Rails::VERSION::MAJOR >= 8 ? serialized_job_rails_8 : serialized_job_rails_7, permitted_classes: permitted_classes, aliases: true).as_json
dumped_job = YAML.safe_load(serialized_job, permitted_classes: permitted_classes, aliases: true).as_json
expect(db_job).to eq(dumped_job)
end

it 'can be deserialized' do
object = YAML.load_dj(serialized_job_rails_7)
expect(object).not_to be_nil

object = YAML.load_dj(serialized_job_rails_8)
object = YAML.load_dj(serialized_job)
expect(object).not_to be_nil
end
end
Expand Down

0 comments on commit 466bc72

Please sign in to comment.