my $unsent_messages = _get_unsent_messages();
MESSAGE: foreach my $message ( @$unsent_messages ) {
my $message_object = Koha::Notice::Messages->find( $message->{message_id} );
- $message_object->status('processing');
# If this fails the database is unwritable and we won't manage to send a message that continues to be marked 'pending'
- return unless $message_object->store();
+ $message_object->make_column_dirty('status');
+ return unless $message_object->store;
# warn Data::Dumper->Dump( [ $message ], [ 'message' ] );
warn sprintf( 'sending %s message to patron: %s',
}
}
- my @known_methods = qw( is_changed id in_storage get_column discard_changes update );
+ my @known_methods = qw( is_changed id in_storage get_column discard_changes update make_column_dirty );
+
Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods;
my $r = eval { $self->_result->$method(@_) };
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new();
-subtest 'is_changed' => sub {
- plan tests => 6;
+subtest 'is_changed / make_column_dirty' => sub {
+ plan tests => 9;
$schema->storage->txn_begin;
$object->store();
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
+ # Test make_column_dirty
+ $object->make_column_dirty('firstname');
+ is( $object->is_changed, 1, "Object is changed after make dirty" );
+ $object->store;
+ is( $object->is_changed, 0, "Store clears dirty mark" );
+ $object->make_column_dirty('firstname');
+ $object->discard_changes;
+ is( $object->is_changed, 0, "Discard clears dirty mark too" );
+
$schema->storage->txn_rollback;
};