ASF::Person[userName] will return nil if the person does not exist, otherwise it will return the ASF::Person object associated with this person.
- Sam Ruby On Sat, Jan 27, 2018 at 7:11 PM, Craig Russell <[email protected]> wrote: > Hi, > > I'm allowing users of project/icla to pretend to be another user for the > purpose of testing. > > I have this code that doesn't quite work: > > def getUser(userName) > user = ASF::Person.find(userName) > mockName = params['mock'] > if mockName != '' and ASF::Person.find(mockName).id == mockName > # if mock is set, set member to mock value > return mockName > else > return userName > end > end > > What I'm trying to do is to see if the mocked user actually exists. > > The code returns the mock name even if the mock name does not exist. > > What is the correct test for user exists? > > Thanks, > > Craig > > Craig L Russell > Secretary, Apache Software Foundation > [email protected] http://db.apache.org/jdo >
