Factor out bindattr resolver and tighten code a bit
[dbsrgits/DBIx-Class.git] / t / relationship / after_update.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 plan tests => 2;
11
12 my $bookmark = $schema->resultset("Bookmark")->find(1);
13 my $link = $bookmark->link;
14 my $link_id = $link->id;
15
16 my $new_link = $schema->resultset("Link")->new({
17     id      => 42,
18     url     => "http://monstersarereal.com",
19     title   => "monstersarereal.com"
20 });
21
22 # Changing a relationship by id rather than by object would cause
23 # old related_resultsets to be used.
24 $bookmark->link($new_link->id);
25 is $bookmark->link->id, $new_link->id;
26
27 $bookmark->update;
28 is $bookmark->link->id, $new_link->id;