PageRenderTime 26ms CodeModel.GetById 20ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

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