The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
use strict;
use warnings;
use Test::More;

use lib 't/lib';
use MongooseT;

package Bar;
use Moose;
with 'Mongoose::Document';
has 'stuff' => (is => 'rw', isa => 'Str', required => 1 );
1;

package Foo;
use Moose;
with 'Mongoose::Document';
has 'other_stuff' => (is => 'rw', isa => 'Str' );
has 'bars' => (is => 'rw', isa => 'Mongoose::Join[Bar]' );
1;

package main;

my $b = Bar->new( stuff => 'foo has bars' );
$b->save();

my $foo = Foo->new( other_stuff => 'sadasd' );
$foo->save();
$foo->bars( Mongoose::Join->new( with_class => "Bar" ) );
$foo->bars->add( $b );
$foo->save();
is $foo->bars->find_one->stuff => 'foo has bars', 'bars joined';

done_testing;