ngsankha / rbsyn

Program synthesis for Ruby
BSD 3-Clause "New" or "Revised" License
94 stars 4 forks source link

Full username_available? method #3

Closed ngsankha closed 4 years ago

ngsankha commented 5 years ago

Finally get to synthesis of something like:

  def self.username_available?(username, email = nil)
    lower = username.downcase
    return false if reserved_username?(lower)
    return true  if !User.exists?(username_lower: lower)
    # staged users can use the same username since they will take over the account
    email.present? && User.joins(:user_emails).exists?(staged: true, username_lower: lower, user_emails: { primary: true, email: email })
  end

Blockers:

ngsankha commented 5 years ago

We are basically there. The tests in the Discourse app are underspecified - so the synthesizer gives some other program. Need to come up with a good test.