Refactor user controller, create action, mostly.

The gist of the commit are a few improvements in the
create action, where:

* long boolean statemenst have been wrapped in smaller more readable
  methods.
* the 3rd party user info creation has been extracted (still in controller)
* a small helper method for creating a new user from params (to reduce
  visual clutter)
* specs have been added where I came across untested methods/branches

Other changes are more trivial like formatting and whitespace fixes.
Hope this helps. Regards.
This commit is contained in:
Philipp Weissensteiner
2013-04-13 00:46:55 +02:00
parent 4413d2a92b
commit 3dcb1905e3
3 changed files with 178 additions and 63 deletions

View File

@@ -102,6 +102,15 @@ class User < ActiveRecord::Base
find_available_username_based_on(name)
end
def self.new_from_params(params)
user = User.new
user.name = params[:name]
user.email = params[:email]
user.password = params[:password]
user.username = params[:username]
user
end
def self.create_for_email(email, opts={})
username = suggest_username(email)