Commit a51562d6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix setting default values for user

parent 3fe2558a
...@@ -200,17 +200,18 @@ class User < ActiveRecord::Base ...@@ -200,17 +200,18 @@ class User < ActiveRecord::Base
end end
def build_user(attrs = {}, options= {}) def build_user(attrs = {}, options= {})
user = User.new(defaults.merge(attrs), options) if options[:as] == :admin
# if not as: :admin force default settings User.new(defaults.merge(attrs.symbolize_keys), options)
user.with_defaults unless options[:as] == :admin else
user User.new(attrs, options).with_defaults
end
end end
def defaults def defaults
{ {
projects_limit: Gitlab.config.gitlab.default_projects_limit, projects_limit: Gitlab.config.gitlab.default_projects_limit,
can_create_group: Gitlab.config.gitlab.default_can_create_group, can_create_group: Gitlab.config.gitlab.default_can_create_group,
theme_id: Gitlab::Theme::BASIC theme_id: Gitlab::Theme::MARS
} }
end end
end end
...@@ -384,8 +385,10 @@ class User < ActiveRecord::Base ...@@ -384,8 +385,10 @@ class User < ActiveRecord::Base
end end
def with_defaults def with_defaults
User.defaults.each do |k,v| User.defaults.each do |k, v|
self.send("#{k}=",v) self.send("#{k}=", v)
end end
self
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment