/test/unit/update_test.rb

http://github.com/rstacruz/ion · Ruby · 42 lines · 27 code · 10 blank · 5 comment · 0 complexity · 82a2704f49e44f8346ccc874ba3054f5 MD5 · raw file

  1. require_relative '../test_helper'
  2. class UpdateTest < Test::Unit::TestCase
  3. setup do
  4. # Fake entries that should NOT be returned
  5. 5.times { Album.create title: lorem, body: '' }
  6. end
  7. test "Deleting records" do
  8. item = Album.create title: "Shobeh"
  9. search = Album.ion.search { text :title, "Shobeh" }
  10. id = item.id
  11. # Search should see it
  12. assert_equal [id], search.ids
  13. item.delete
  14. assert Album[id].nil?
  15. search = Album.ion.search { text :title, "Shobeh" }
  16. assert_equal [], search.ids
  17. end
  18. test "Editing records" do
  19. item = Album.create title: "Heshela"
  20. search = Album.ion.search { text :title, "Heshela" }
  21. # Search should see it
  22. assert_equal [item.id], search.ids
  23. # Edit
  24. item.title = "Mathroux"
  25. item.save
  26. # Now search should not see it
  27. search = Album.ion.search { text :title, "Heshela" }
  28. assert_equal [], search.ids
  29. search = Album.ion.search { text :title, "mathroux" }
  30. assert_equal [item.id], search.ids
  31. end
  32. end