|
31 | 31 | it { should respond_to(:private_token) }
|
32 | 32 | end
|
33 | 33 |
|
34 |
| - it "should return valid identifier" do |
35 |
| - user = User.new(email: "[email protected]") |
36 |
| - user.identifier.should == "test_mail_com" |
37 |
| - end |
| 34 | + describe '#identifier' do |
| 35 | + it "should return valid identifier" do |
| 36 | + user = build(:user, email: "[email protected]") |
| 37 | + user.identifier.should == "test_mail_com" |
| 38 | + end |
38 | 39 |
|
39 |
| - it "should return identifier without + sign" do |
40 |
| - user = User.new(email: "[email protected]") |
41 |
| - user.identifier.should == "test_foo_mail_com" |
42 |
| - end |
| 40 | + it "should return identifier without + sign" do |
| 41 | + user = build(:user, email: "[email protected]") |
| 42 | + user.identifier.should == "test_foo_mail_com" |
| 43 | + end |
43 | 44 |
|
44 |
| - it "should execute callback when force_random_password specified" do |
45 |
| - user = User.new(email: "test@mail.com", force_random_password: true) |
46 |
| - user.should_receive(:generate_password) |
47 |
| - user.save |
| 45 | + it "should conform to Gitolite's required identifier pattern" do |
| 46 | + user = build(:user, email: "_test@example.com") |
| 47 | + user.identifier.should == 'test_example_com' |
| 48 | + end |
48 | 49 | end
|
49 | 50 |
|
50 |
| - it "should not generate password by default" do |
51 |
| - user = Factory(:user, password: 'abcdefg', password_confirmation: 'abcdefg') |
52 |
| - user.password.should == 'abcdefg' |
53 |
| - end |
| 51 | + describe '#generate_password' do |
| 52 | + it "should execute callback when force_random_password specified" do |
| 53 | + user = build(:user, force_random_password: true) |
| 54 | + user.should_receive(:generate_password) |
| 55 | + user.save |
| 56 | + end |
| 57 | + |
| 58 | + it "should not generate password by default" do |
| 59 | + user = create(:user, password: 'abcdefg') |
| 60 | + user.password.should == 'abcdefg' |
| 61 | + end |
54 | 62 |
|
55 |
| - it "should generate password when forcing random password" do |
56 |
| - Devise.stub(:friendly_token).and_return('123456789') |
57 |
| - user = User.create(email: "[email protected]", force_random_password: true) |
58 |
| - user.password.should == user.password_confirmation |
59 |
| - user.password.should == '12345678' |
| 63 | + it "should generate password when forcing random password" do |
| 64 | + Devise.stub(:friendly_token).and_return('123456789') |
| 65 | + user = create(:user, password: 'abcdefg', force_random_password: true) |
| 66 | + user.password.should == '12345678' |
| 67 | + end |
60 | 68 | end
|
61 | 69 |
|
62 |
| - it "should have authentication token" do |
63 |
| - user = Factory(:user) |
64 |
| - user.authentication_token.should_not == "" |
| 70 | + describe 'authentication token' do |
| 71 | + it "should have authentication token" do |
| 72 | + user = Factory(:user) |
| 73 | + user.authentication_token.should_not be_blank |
| 74 | + end |
65 | 75 | end
|
66 | 76 | end
|
0 commit comments