Help language development. Donate to The Perl Foundation

ORM::ActiveRecord cpan:GDONALD last updated on 2019-10-24

t/004-model-is-dirty.t6
use v6.d;
use lib 'lib';
use ORM::ActiveRecord::Model;
use Test;

class User is Model {
  submethod BUILD {
    self.validate: 'fname', { :presence }
  }
}

plan 8;

%*ENV<DISABLE-SQL-LOG> = True;

my $user;
my $user2;

$user = User.create({fname => 'Fred'});
nok $user.is-dirty;

$user.fname = 'John';
ok $user.is-dirty;
ok $user.save;
nok $user.is-dirty;
ok $user.fname eq 'John';

$user2 = User.create({fname => 'Bob'});
nok $user2.is-dirty;

$user2.fname = 'Jim';
ok $user2.is-dirty;

nok $user.is-dirty;

User.destroy-all;