Skip to content

Instantly share code, notes, and snippets.

Avatar

John Baylor jbaylor-rpx

View GitHub Profile
View salesforce_id_spec.rb
#
# Specs for salesforce_id.rb (https://gist.github.com/2691624)
#
require 'spec_helper'
describe SalesforceId do
describe 'convert' do
before do
@sf15 = 'a0D30000001n7Pi'
@sf18 = 'a0D30000001n7PiEAC'
@jbaylor-rpx
jbaylor-rpx / salesforce_id.rb
Created May 14, 2012
Convert Salesforce IDs from 15 character to 18 characters (and back)
View salesforce_id.rb
# Salesforce originally used case-sensitive 15-character IDs.
# Later they added three error-correcting characters to make their 18-character ID.
# This class converts from one to the other and back
#
# Usage:
# SalesforceId.convert('a0D30000001n7Pi') => 'a0D30000001n7PiEAC'
# OR
# SalesforceId.convert('a0D30000001n7PiEAC') => 'a0D30000001n7Pi'
# SalesforceId.convert('A0d30000001N7pIeAc') => 'a0D30000001n7Pi'
#