* fix broken tests

This commit is contained in:
Seth Call 2014-01-31 09:32:18 -06:00
parent edebf42e73
commit 3d6069bdb3
2 changed files with 20 additions and 1 deletions

View File

@ -47,11 +47,17 @@ module JamRuby
end
end
def remove_non_alpha_num(token)
token.gsub(/[^0-9A-Za-z]/, '')
end
private
def generate_share_token
self.share_token = loop do
token = SecureRandom.urlsafe_base64(SHARE_TOKEN_LENGTH, false)
token.gsub!(/[^0-9A-Za-z]/, '').upcase!
token = remove_non_alpha_num(token)
token.upcase!
break token unless MusicSessionHistory.exists?(share_token: token)
end
end

View File

@ -112,4 +112,17 @@ describe ClaimedRecording do
duplicate.errors[:recording_id].should == ['has already been taken']
end
end
describe "remove_non_alpha_num" do
let(:instance) { ClaimedRecording.new }
it "removes hyphen" do
instance.remove_non_alpha_num("abc-").should == 'abc'
end
it "leaves good alone" do
instance.remove_non_alpha_num("JDnfHsimMQ").should == 'JDnfHsimMQ'
end
end
end