user_credential_spec.rb 734 B

123456789101112131415161718192021
  1. require 'rails_helper'
  2. describe UserCredential do
  3. describe "validation" do
  4. it { should validate_uniqueness_of(:credential_name).scoped_to(:user_id) }
  5. it { should validate_presence_of(:credential_name) }
  6. it { should validate_presence_of(:credential_value) }
  7. it { should validate_presence_of(:user_id) }
  8. end
  9. describe "cleaning fields" do
  10. it "should trim whitespace" do
  11. user_credential = user_credentials(:bob_aws_key)
  12. user_credential.credential_name = " new name "
  13. user_credential.credential_value = " new value "
  14. user_credential.save!
  15. expect(user_credential.credential_name).to eq("new name")
  16. expect(user_credential.credential_value).to eq("new value")
  17. end
  18. end
  19. end