Sha256: b2129e44185d5773ed7e319b3e5c805c0bc19e9476c79c8c05cdb48ff99334d3
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
RSpec.shared_context('repo') do include_context 'models' include_context 'mappers' let(:repo) { repo_class.new(rom) } let(:repo_class) do Class.new(ROM::Repository[:users]) do relations :tasks, :tags, :posts, :labels, :posts_labels def find_users(criteria) users.find(criteria) end def all_users users.all end def all_users_as_users users.as(:user).all end def users_with_tasks aggregate(many: { all_tasks: tasks.for_users }) end def users_with_tasks_and_tags aggregate(many: { all_tasks: tasks_with_tags(tasks.for_users) }) end def users_with_task aggregate(one: tasks) end def users_with_task_by_title(title) aggregate(one: tasks.find(title: title)) end def users_with_posts_and_their_labels users.combine(posts: [:labels]) end def posts_with_labels posts.combine_children(many: labels) end def label_with_posts labels.combine_children(one: posts) end def tasks_for_users(users) tasks.for_users(users) end def task_with_user tasks.find(id: 2).combine_parents(one: users) end def task_with_owner tasks.find(id: 2).combine_parents(one: { owner: users }) end def tasks_with_tags(tasks = self.tasks) tasks.combine_children(many: tags) end def tag_with_wrapped_task tags.wrap_parent(task: tasks) end end end let(:comments_repo) do Class.new(ROM::Repository[:comments]) do relations :likes def comments_with_likes aggregate(many: { likes: likes }) end def comments_with_emotions root.combine(:emotions) end end.new(rom) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-repository-1.0.0.beta1 | spec/shared/repo.rb |