require'spec_helper'describeGitlab::Database::ShaAttributedolet(:sha)do'9a573a369a5bfbb9a4a36e98852c21af8a44ea8b'endlet(:binary_sha)do[sha].pack('H*')endlet(:binary_from_db)doifGitlab::Database.postgresql?"\\x#{sha}"elsebinary_shaendendlet(:attribute){described_class.new}describe'#type_cast_from_database'doit'converts the binary SHA to a String'doexpect(attribute.type_cast_from_database(binary_from_db)).toeq(sha)endenddescribe'#type_cast_for_database'doit'converts a SHA String to binary data'doexpect(attribute.type_cast_for_database(sha).to_s).toeq(binary_sha)endendend