Guest User

Untitled

a guest
Feb 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. #app/models/season_storage.rb
  2.  
  3. before_validation :sanitize_inputs
  4. ...
  5. validates :storage_id, uniqueness: { scope: :epoch }
  6. validates :epoch, presence: true
  7. validates :epoch, format: /A20[0-9]{2}-(spring|autumn)Z/
  8. ...
  9. def sanitize_inputs
  10. storage_id.upcase!
  11. end
  12.  
  13.  
  14.  
  15. #spec/models/season_storage.rb
  16.  
  17. it { is_expected.to validate_uniqueness_of(:storage_id).ignoring_case_sensitivity.scoped_to(:epoch) }
  18.  
  19. Failure/Error: it { is_expected.to validate_uniqueness_of(:storage_id).ignoring_case_sensitivity.scoped_to(:epoch) }
  20.  
  21. Expected SeasonStorage to validate that :storage_id is unique within the
  22. scope of :epoch, but this could not be proved.
  23. After taking the given SeasonStorage, setting its :storage_id to
  24. ‹"dummy value"›, and saving it as the existing record, then making a
  25. new SeasonStorage and setting its :storage_id to ‹"dummy value"› (read
  26. back as ‹"DUMMY VALUE"›) as well e its :epoch to a different value,
  27. ‹nil›, the matcher expected the new SeasonStorage to be invalid, but
  28. it was valid instead.
  29.  
  30. As indicated in the message above, :storage_id seems to be changing
  31. certain values as they are set, and this could have something to do
  32. with why this test is failing. If you or something else has overridden
  33. the writer method for this attribute to normalize values by changing
  34. their case in any way (for instance, ensuring that the attribute is
  35. always downcased), then try adding `ignoring_case_sensitivity` onto
  36. the end of the uniqueness matcher. Otherwise, you may need to write
  37. the test yourself, or do something different altogether.
  38.  
  39. as well e its :epoch to a different value,
  40. ‹nil›, the matcher expected the new SeasonStorage to be invalid, but
  41. it was valid instead
Add Comment
Please, Sign In to add comment