diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-06-26 23:41:49 -0700 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-06-26 23:41:49 -0700 |
| commit | 4c1f435ab78e5d4da3d6aaaf20579be13b662d02 (patch) | |
| tree | 5d4fc65ea20c161c9add85c822d3fd177378ed78 /spec/models | |
| parent | 1c8008c154ac4ca60790910a413a42d65c5881bb (diff) | |
| parent | 5ab1856291d845b27f68c41f23ca76c78afcbce1 (diff) | |
| download | gitlab-ce-4c1f435ab78e5d4da3d6aaaf20579be13b662d02.tar.gz | |
Merge pull request #971 from gingko/master
Automatic password creation..
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/user_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c2721dd1d6c..91771ca903b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -22,6 +22,24 @@ describe User do user.identifier.should == "test_mail_com" end + it "should execute callback when force_random_password specified" do + user = User.new(:email => "test@mail.com", :force_random_password => true) + user.should_receive(:generate_password) + user.save + end + + it "should not generate password by default" do + user = Factory(:user, :password => 'abcdefg', :password_confirmation => 'abcdefg') + user.password.should == 'abcdefg' + end + + it "should generate password when forcing random password" do + Devise.stub(:friendly_token).and_return('123456789') + user = User.create(:email => "test1@mail.com", :force_random_password => true) + user.password.should == user.password_confirmation + user.password.should == '12345678' + end + it "should have authentication token" do user = Factory(:user) user.authentication_token.should_not == "" |
