user_credential_spec.rb 941 B

1234567891011121314151617181920212223242526272829
  1. require 'spec_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 "mass assignment" do
  10. it { should allow_mass_assignment_of :credential_name }
  11. it { should allow_mass_assignment_of :credential_value }
  12. it { should_not allow_mass_assignment_of :user_id }
  13. end
  14. describe "cleaning fields" do
  15. it "should trim whitespace" do
  16. user_credential = user_credentials(:bob_aws_key)
  17. user_credential.credential_name = " new name "
  18. user_credential.credential_value = " new value "
  19. user_credential.save!
  20. user_credential.credential_name.should == "new name"
  21. user_credential.credential_value.should == "new value"
  22. end
  23. end
  24. end