App-SD

 view release on metacpan or  search on metacpan

t/03-update-ticket-with-editor.t  view on Meta::CPAN

#!/usr/bin/perl -w
use strict;

use Prophet::Test tests => 17;
use App::SD::Test;

BEGIN {
    require File::Temp;
    $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 1 ) . '/_svb';
    diag 'export SD_REPO=' . $ENV{'PROPHET_REPO'} . "\n";
}
run_script( 'sd', [ 'init', '--non-interactive']);

my $replica_uuid = replica_uuid;

diag('changing settings to enable different behaviour with --verbose arg');
run_output_matches( 'sd', [ 'settings', '--set', '--', 'common_ticket_props',
    '["id","summary","status","milestone","owner","created","due","creator","reporter","original_replica"]' ],
    [
        'Trying to change common_ticket_props from ["id","summary","status","milestone","component","owner","created","due","creator","reporter","original_replica"] to ["id","summary","status","milestone","owner","created","due","creator","reporter",...
        ' -> Changed.',
    ]
);

# create ticket
my ($ticket_id, $ticket_uuid) = create_ticket_ok( '--summary', 'zomg!',
    '--owner', 'foo@bar.com');

# verify that it's correct
run_output_matches( 'sd', [ 'ticket', 'basics', '--batch', '--id', $ticket_id ],
    [
        "id: $ticket_id ($ticket_uuid)",
        'summary: zomg!',
        'status: new',
        'milestone: alpha',
        'owner: foo@bar.com',
        qr/^created: \d{4}-\d{2}-\d{2}.+$/,
        qr/^creator: /,
        'reporter: ' . $ENV{PROPHET_EMAIL},
        "original_replica: $replica_uuid",
    ]
);

Prophet::Test->set_editor_script(
    "ticket-update-editor.pl --no-args $replica_uuid $ticket_uuid");

# update it
my ($comment_id, $comment_uuid)
    = App::SD::Test->update_ticket_with_editor_ok($ticket_id, $ticket_uuid);

# check output -- component && foobar should be hidden by common_ticket_props
run_output_matches( 'sd',
    [ 'ticket', 'show', '--skip-history', '--batch', '--id', $ticket_id ],
    [
        '', '= METADATA', '',
        "id: $ticket_id ($ticket_uuid)",
        'summary: summary changed',
        'status: new',
        'milestone: alpha',
        qr/^created: \d{4}-\d{2}-\d{2}.+$/,
        'due: 2050-01-25 23:11:42',
        qr/^creator: /,
        'reporter: ' . $ENV{PROPHET_EMAIL},
        "original_replica: $replica_uuid",
    ]
);

# check output with --all-props, need to use show instead of basics
run_output_matches( 'sd',
    [ 'ticket', 'show', '--batch', '--skip-history',
        '--all-props', '--id', $ticket_id ],
    [
        '', '= METADATA', '',
        "id: $ticket_id ($ticket_uuid)",
        'summary: summary changed',
        'status: new',
        'milestone: alpha',
        qr/^created: \d{4}-\d{2}-\d{2}.+$/,
        'due: 2050-01-25 23:11:42',
        qr/^creator: /,
        'reporter: ' . $ENV{PROPHET_EMAIL},
        "original_replica: $replica_uuid",
        qr/foobar: testing|component: core/, # no guaranteed ordering on props
        qr/foobar: testing|component: core/, # not in common_ticket_props
    ]
);

sub check_comment_ok {
    # comment output verifies that the template presented to the user for



( run in 0.983 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )