Skip to content

Instantly share code, notes, and snippets.

@avidas
Last active December 28, 2017 19:19
Show Gist options
  • Save avidas/d1cb9f3e79545ca899ed01ddb48d350b to your computer and use it in GitHub Desktop.
Save avidas/d1cb9f3e79545ca899ed01ddb48d350b to your computer and use it in GitHub Desktop.
begin
ActiveRecord::Base.transaction do
TenantService.switch_to_rest_of_world_tenant
office_of_baby_uuid = '8083d9a1-ec36-480f-b257-31fd67cd0001'
office_of_baby = Account.find_by_uuid office_of_baby_uuid
oob_primary_res = office_of_baby.primary_reservations.active.last
oob_conf_allotment = oob_primary_res.conference_room_allotments.active.last
oob_conf_allotment.started_on = oob_primary_res.started_on
oob_conf_allotment.save!
oob_change_request = ChangeRequest.where(account_uuid: office_of_baby_uuid).last
oob_membership_agreement = oob_change_request.membership_agreement
ExecuteService.new(oob_membership_agreement).perform!
oob_primary_res.reload
raise ActiveRecord::Rollback, "Failed to move out #{office_of_baby_uuid}" unless
oob_primary_res.ended_on == oob_change_request.reservation_ended_on
end
end
@RonaTross
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment