spec/integration/repository_spec.rb in rom-repository-1.3.1 vs spec/integration/repository_spec.rb in rom-repository-1.3.2
- old
+ new
@@ -69,9 +69,20 @@
it 'loads a wrapped relation' do
expect(repo.tag_with_wrapped_task.first).to eql(tag_with_task)
end
+ it 'loads wraps using aliased relation' do
+ author = repo.users.where(name: 'Jane').one
+
+ repo.command(:create, repo.books).(title: 'Hello World', author_id: author.id)
+
+ book = repo.books.wrap(:author).to_a.first
+
+ expect(book.author.id).to eql(author.id)
+ expect(book.author.name).to eql(author.name)
+ end
+
it 'loads multiple wraps' do
post_label = repo.posts_labels.wrap(:post).wrap(:label).to_a.first
expect(post_label.label_id).to be(post_label.label.id)
expect(post_label.post_id).to be(post_label.post.id)