Bug 27857: Get the right column
This patch makes the search for mandatory attribute types actually use 'code' instead of 'class' for comparisson. Tests are added to cover this behavior. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Patron.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> https://bugs.koha-community.org/show_bug.cgi?id=27587 Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
881b610db6
commit
0d59e57508
2 changed files with 14 additions and 4 deletions
|
@ -1576,7 +1576,7 @@ sub extended_attributes {
|
||||||
undef
|
undef
|
||||||
},
|
},
|
||||||
{ join => 'borrower_attribute_types_branches' }
|
{ join => 'borrower_attribute_types_branches' }
|
||||||
)->get_column('class');
|
)->get_column('code');
|
||||||
for my $type ( @required_attribute_types ) {
|
for my $type ( @required_attribute_types ) {
|
||||||
Koha::Exceptions::Object::FKConstraint->throw(
|
Koha::Exceptions::Object::FKConstraint->throw(
|
||||||
broken_fk => "$type",
|
broken_fk => "$type",
|
||||||
|
|
|
@ -616,21 +616,21 @@ subtest 'extended_attributes' => sub {
|
||||||
|
|
||||||
subtest 'globally mandatory attributes tests' => sub {
|
subtest 'globally mandatory attributes tests' => sub {
|
||||||
|
|
||||||
plan tests => 3;
|
plan tests => 5;
|
||||||
|
|
||||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||||
|
|
||||||
my $attribute_type_1 = $builder->build_object(
|
my $attribute_type_1 = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Patron::Attribute::Types',
|
class => 'Koha::Patron::Attribute::Types',
|
||||||
value => { mandatory => 1 }
|
value => { mandatory => 1, class => 'a' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
my $attribute_type_2 = $builder->build_object(
|
my $attribute_type_2 = $builder->build_object(
|
||||||
{
|
{
|
||||||
class => 'Koha::Patron::Attribute::Types',
|
class => 'Koha::Patron::Attribute::Types',
|
||||||
value => { mandatory => 0 }
|
value => { mandatory => 0, class => 'a' }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -647,7 +647,17 @@ subtest 'extended_attributes' => sub {
|
||||||
'Koha::Exceptions::Object::FKConstraint',
|
'Koha::Exceptions::Object::FKConstraint',
|
||||||
'Exception thrown on missing mandatory attribute type';
|
'Exception thrown on missing mandatory attribute type';
|
||||||
|
|
||||||
|
is( $@->value, $attribute_type_1->code, 'Exception parameters are correct' );
|
||||||
|
|
||||||
is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
|
is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
|
||||||
|
|
||||||
|
$patron->extended_attributes(
|
||||||
|
[
|
||||||
|
{ code => $attribute_type_1->code, attribute => 'b' }
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
is( $patron->extended_attributes->count, 1, 'Extended attributes succeeded' );
|
||||||
};
|
};
|
||||||
|
|
||||||
$schema->storage->txn_rollback;
|
$schema->storage->txn_rollback;
|
||||||
|
|
Loading…
Reference in a new issue