Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. describe User do
  2. context 'User db columns' do
  3. it { should have_db_column(:email).of_type(:string)}
  4. it { should have_db_column(:encrypted_password).of_type(:string)}
  5. it { should have_db_column(:reset_password_token).of_type(:string)}
  6. it { should have_db_column(:reset_password_sent_at).of_type(:datetime)}
  7. it { should have_db_column(:remember_created_at).of_type(:datetime)}
  8. it { should have_db_column(:sign_in_count).of_type(:integer)}
  9. it { should have_db_column(:current_sign_in_at).of_type(:datetime)}
  10. it { should have_db_column(:last_sign_in_at).of_type(:datetime) }
  11. it { should have_db_column(:current_sign_in_ip).of_type(:string)}
  12. it { should have_db_column(:last_sign_in_ip).of_type(:string)}
  13. it { should have_db_column(:created_at).of_type(:datetime) }
  14. it { should have_db_column(:updated_at).of_type(:datetime)}
  15. it { should have_db_column(:first_name).of_type(:string)}
  16. it { should have_db_column(:last_name).of_type(:string)}
  17. it { should have_db_column(:office_id).of_type(:integer)}
  18. it { should have_db_column(:rank_id).of_type(:integer)}
  19. it { should have_db_column(:avatar).of_type(:string)}
  20. end
  21. describe 'validates' do
  22. before(:each) do
  23. FactoryGirl.create(:office)
  24. FactoryGirl.create(:developer)
  25. @user = FactoryGirl.create(:user)
  26. end
  27.  
  28. it 'is valid with valid attr' do
  29. @user.should be_valid
  30. end
  31.  
  32. it 'is not valid without email' do
  33. @user.email = nil
  34. @user.should_not be_valid
  35. end
  36.  
  37. it 'is not valid with wrong email' do
  38. @user.email = 'email'
  39. @user.should_not be_valid
  40. end
  41.  
  42. it 'is not valid without office' do
  43. @user.office_id = nil
  44. @user.should_not be_valid
  45. end
  46.  
  47. it 'is not valid without first name' do
  48. @user.first_name = nil
  49. @user.should_not be_valid
  50. end
  51.  
  52. it 'is not valid without last_name' do
  53. @user.last_name = nil
  54. @user.should_not be_valid
  55. end
  56.  
  57. it 'is not valid without rank' do
  58. @user.rank_id = nil
  59. @user.should_not be_valid
  60. end
  61.  
  62.  
  63. end
  64.  
  65. context 'associations' do
  66. it 'belong to rank' do
  67. should belong_to(:rank)
  68. end
  69.  
  70. it 'belong to office' do
  71. should belong_to(:office)
  72. end
  73.  
  74. it 'have many ideas' do
  75. should have_many(:ideas)
  76. end
  77.  
  78. it 'have many comments' do
  79. should have_many(:comments)
  80. end
  81.  
  82. it 'have many ratings' do
  83. should have_many(:ratings)
  84. end
  85.  
  86. it 'have many tags' do
  87. should have_many(:tags)
  88. end
  89.  
  90. end
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement