test/shoden_test.rb in shoden-0.2.0 vs test/shoden_test.rb in shoden-0.3.0

- old
+ new

@@ -76,5 +76,31 @@ a = A.create(n: 1) a_prime = A[a.id] assert_equal a_prime.n, 1 end + +test 'indices' do + class Person < Shoden::Model + attribute :email + attribute :origin + + index :origin + unique :email + end + + person = Person.create(email: 'elcuervo@elcuervo.net', origin: 'The internerd') + + assert person.id + + assert_raise Shoden::UniqueIndexViolation do + Person.create(email: 'elcuervo@elcuervo.net', origin: 'Montevideo City') + end +end + +test 'basic querying' do + 5.times { User.create } + + assert_equal User.all.size, 5 + assert_equal User.first.id, 1 + assert_equal User.last.id, 5 +end