View | Details | Raw Unified | Return to bug 32607
Collapse All | Expand All

(-)a/Koha/Biblio/Metadata.pm (+16 lines)
Lines 170-175 sub record_strip_nonxml { Link Here
170
    return $self->record( { %$params, record => $record } );
170
    return $self->record( { %$params, record => $record } );
171
}
171
}
172
172
173
=head3 can_be_edited
174
175
    if ( $metadata->can_be_edited ) { ... }
176
177
Returns a boolean denoting whether the metadata record can be edited.
178
179
=cut
180
181
sub can_be_edited {
182
    my ($self) = @_;
183
184
    my $rs = $self->_result->record_source;
185
    return 1 unless $rs;
186
    return $rs->can_be_edited;
187
}
188
173
=head2 Internal methods
189
=head2 Internal methods
174
190
175
=head3 _embed_items
191
=head3 _embed_items
(-)a/t/cypress/integration/RecordSources_spec.ts (-1 / +1 lines)
Lines 41-47 describe("Record sources CRUD tests", () => { Link Here
41
        // Submit the form, get 500
41
        // Submit the form, get 500
42
        cy.intercept("POST", "/api/v1/record_sources", {
42
        cy.intercept("POST", "/api/v1/record_sources", {
43
            statusCode: 201,
43
            statusCode: 201,
44
            body: {}
44
            body: {},
45
        });
45
        });
46
        cy.get("#record_source_edit").contains("Submit").click();
46
        cy.get("#record_source_edit").contains("Submit").click();
47
    });
47
    });
(-)a/t/db_dependent/Koha/Biblio/Metadata.t (-2 / +26 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 4;
20
use Test::More tests => 5;
21
use Test::Exception;
21
use Test::Exception;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 266-268 subtest '_embed_items' => sub { Link Here
266
266
267
    $schema->storage->txn_rollback;
267
    $schema->storage->txn_rollback;
268
};
268
};
269
- 
269
270
subtest 'can_be_edited() tests' => sub {
271
272
    plan tests => 4;
273
274
    $schema->storage->txn_begin;
275
276
    my $biblio = $builder->build_sample_biblio;
277
278
    my $metadata = $biblio->metadata;
279
    is( $metadata->record_source_id, undef, 'No record source defined for metatada object' );
280
    ok( $metadata->can_be_edited, 'No record source, can be edited' );
281
282
    my $source = $builder->build_object( { class => 'Koha::RecordSources', value => { can_be_edited => 1 } } );
283
    $metadata->record_source_id( $source->id )->store();
284
285
    ok( $metadata->can_be_edited, 'Record source allows, can be edited' );
286
287
    $source->can_be_edited(0)->store();
288
    $metadata->discard_changes;
289
290
    ok( !$metadata->can_be_edited, 'Record source does not allow, cannot be edited' );
291
292
    $schema->storage->txn_rollback;
293
};

Return to bug 32607