From a9e4b4ce99c1552c50a723e880d1028c96af8a07 Mon Sep 17 00:00:00 2001 From: alda519 <galda519@gmail.com> Date: Wed, 14 Sep 2011 20:46:52 +0200 Subject: [PATCH] fixed broken test, spec added --- app/models/user.rb | 2 ++ spec/models/user_spec.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 02915fadc3..9c1f3d7cc9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -360,6 +360,8 @@ class User < ActiveRecord::Base def setup(opts) self.username = opts[:username] self.email = opts[:email] + self.language = opts[:language] + self.language ||= I18n.locale.to_s self.valid? errors = self.errors errors.delete :person diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bf4bb386f4..d564ddc5fd 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -203,9 +203,14 @@ describe User do it "should save with current language if blank" do I18n.locale = :fr user = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password') - user.save! user.language.should == 'fr' end + + it "should save with language what is set" do + I18n.locale = :fr + user = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password', :language => 'de') + user.language.should == 'de' + end end end -- GitLab