зеркало из https://github.com/mozilla/pjs.git
Cleared up some inconsistencies with caserun editing
This commit is contained in:
Родитель
145b082757
Коммит
eabb19cef3
|
@ -10,11 +10,11 @@
|
|||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Bugzilla Test Runner System.
|
||||
# The Original Code is the Bugzilla Testopia System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Maciej Maczynski.
|
||||
# Portions created by Maciej Maczynski are Copyright (C) 2001
|
||||
# Maciej Maczynski. All Rights Reserved.
|
||||
# The Initial Developer of the Original Code is Greg Hendricks.
|
||||
# Portions created by Greg Hendricks are Copyright (C) 2006
|
||||
# Novell. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Greg Hendricks <ghendricks@novell.com>
|
||||
=head1 NAME
|
||||
|
@ -69,6 +69,7 @@ use Date::Format;
|
|||
case_run_status_id
|
||||
case_text_version
|
||||
build_id
|
||||
environment_id
|
||||
notes
|
||||
close_date
|
||||
iscurrent
|
||||
|
@ -77,19 +78,19 @@ use Date::Format;
|
|||
=cut
|
||||
|
||||
use constant DB_COLUMNS => qw(
|
||||
test_case_runs.case_run_id
|
||||
test_case_runs.run_id
|
||||
test_case_runs.case_id
|
||||
test_case_runs.assignee
|
||||
test_case_runs.testedby
|
||||
test_case_runs.case_run_status_id
|
||||
test_case_runs.case_text_version
|
||||
test_case_runs.build_id
|
||||
test_case_runs.environment_id
|
||||
test_case_runs.notes
|
||||
test_case_runs.close_date
|
||||
test_case_runs.iscurrent
|
||||
test_case_runs.sortkey
|
||||
case_run_id
|
||||
run_id
|
||||
case_id
|
||||
assignee
|
||||
testedby
|
||||
case_run_status_id
|
||||
case_text_version
|
||||
build_id
|
||||
environment_id
|
||||
notes
|
||||
close_date
|
||||
iscurrent
|
||||
sortkey
|
||||
);
|
||||
|
||||
our $columns = join(", ", DB_COLUMNS);
|
||||
|
@ -207,48 +208,39 @@ Creates a copy of this caserun and sets it as the current record
|
|||
|
||||
sub clone {
|
||||
my $self = shift;
|
||||
my ($fields) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
if ($fields->{'build_id'} && $self->{'build_id'} != $fields->{'build_id'}){
|
||||
my $build = Bugzilla::Testopia::Build->new($fields->{'build_id'});
|
||||
my $note = "Build Changed by ". Bugzilla->user->login;
|
||||
$note .= ". Old build: '". $self->build->name;
|
||||
$note .= "' New build: '". $build->name;
|
||||
$note .= "'. Resetting to IDLE.";
|
||||
$self->{'build_id'} = $fields->{'build_id'};
|
||||
$self->{'build'} = $build;
|
||||
$self->append_note($note);
|
||||
}
|
||||
if ($fields->{'environment_id'} && $self->{'environment_id'} != $fields->{'environment_id'}){
|
||||
my $environment = Bugzilla::Testopia::Environment->new($fields->{'environment_id'});
|
||||
my $note = "Environment Changed by ". Bugzilla->user->login;
|
||||
$note .= ". Old environment: '". $self->environment->name;
|
||||
$note .= "' New environment: '". $environment->name;
|
||||
$note .= "'. Resetting to IDLE.";
|
||||
$self->{'environment_id'} = $fields->{'environment_id'};
|
||||
$self->{'environment'} = $environment;
|
||||
$self->append_note($note);
|
||||
}
|
||||
my $entry = $self->store;
|
||||
$self->set_as_current($entry);
|
||||
return $entry;
|
||||
my ($build_id, $env_id ,$run_id, $case_id) = @_;
|
||||
$run_id ||= $self->{'run_id'};
|
||||
$case_id ||= $self->{'case_id'};
|
||||
|
||||
my $dbh = Bugzilla->dbh;
|
||||
$dbh->do("INSERT INTO test_case_runs ($columns)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", undef,
|
||||
(undef, $run_id, $case_id, $self->{'assignee'},
|
||||
undef, IDLE, $self->{'case_text_version'},
|
||||
$build_id, $env_id,
|
||||
undef, undef, 1, 0));
|
||||
|
||||
my $key = $dbh->bz_last_key( 'test_case_runs', 'case_run_id' );
|
||||
|
||||
$self->set_as_current($key);
|
||||
return $key;
|
||||
}
|
||||
|
||||
=head2 check_exists
|
||||
|
||||
Checks for an existing entry with the same build and environment for this
|
||||
case and run and returns the id if it is found
|
||||
case and run and switches self to that object.
|
||||
|
||||
=cut
|
||||
|
||||
sub check_exists {
|
||||
sub switch {
|
||||
my $self = shift;
|
||||
my ($run_id, $case_id, $build_id, $env_id) = @_;
|
||||
my ($build_id, $env_id ,$run_id, $case_id) = @_;
|
||||
|
||||
$run_id ||= $self->{'run_id'};
|
||||
$case_id ||= $self->{'case_id'};
|
||||
$run_id ||= $self->{'run_id'};
|
||||
$case_id ||= $self->{'case_id'};
|
||||
$build_id ||= $self->{'build_id'};
|
||||
$env_id ||= $self->{'environment_id'};
|
||||
$env_id ||= $self->{'environment_id'};
|
||||
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my ($is) = $dbh->selectrow_array(
|
||||
|
@ -260,58 +252,34 @@ sub check_exists {
|
|||
AND environment_id = ?",
|
||||
undef, ($run_id, $case_id, $build_id, $env_id));
|
||||
|
||||
return $is;
|
||||
|
||||
}
|
||||
|
||||
=head2 lookup_case_run_id
|
||||
|
||||
Checks for an existing entry based on run, case, and build,
|
||||
and returns the id if it is found
|
||||
|
||||
=cut
|
||||
|
||||
sub lookup_case_run_id
|
||||
{
|
||||
my ($run_id, $case_id, $build_id) = @_;
|
||||
|
||||
my $dbh = Bugzilla->dbh;
|
||||
|
||||
my ($case_run_id) = $dbh->selectrow_array(
|
||||
"SELECT case_run_id
|
||||
FROM test_case_runs
|
||||
WHERE run_id = ? AND case_id = ? AND build_id = ?",
|
||||
undef, ($run_id, $case_id, $build_id));
|
||||
|
||||
return $case_run_id;
|
||||
}
|
||||
|
||||
=head2 update
|
||||
|
||||
Update this case-run in the database. This method checks which
|
||||
fields have been changed and either creates a clone of the case-run
|
||||
or updates the existing one.
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my ($fields) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
if ($self->is_closed_status($fields->{'case_run_status_id'})){
|
||||
$fields->{'close_date'} = Bugzilla::Testopia::Util::get_time_stamp();
|
||||
}
|
||||
my ($is) = $self->check_exists($self->run_id, $self->case_id, $fields->{'build_id'}, $fields->{'environment_id'});
|
||||
|
||||
if ($fields->{'build_id'} != $self->{'build_id'} || $fields->{'environment_id'} != $self->{'environment_id'}){
|
||||
if ($is){
|
||||
return $is;
|
||||
}
|
||||
if ($self->{'case_run_status_id'} != IDLE){
|
||||
return $self->clone($fields);
|
||||
}
|
||||
}
|
||||
return $self->_update_fields($fields);
|
||||
if ($is){
|
||||
$self = Bugzilla::Testopia::TestCaseRun->new($is);
|
||||
}
|
||||
else {
|
||||
my $oldbuild = $self->{'build_id'};
|
||||
my $oldenv = $self->{'environment_id'};
|
||||
|
||||
$self = Bugzilla::Testopia::TestCaseRun->new($self->clone($build_id,$env_id));
|
||||
|
||||
if ($oldbuild != $build_id){
|
||||
my $build = Bugzilla::Testopia::Build->new($build_id);
|
||||
my $note = "Build Changed by ". Bugzilla->user->login;
|
||||
$note .= ". Old build: '". $self->build->name;
|
||||
$note .= "' New build: '". $build->name;
|
||||
$note .= "'. Resetting to IDLE.";
|
||||
$self->append_note($note);
|
||||
}
|
||||
if ($oldenv != $env_id){
|
||||
my $environment = Bugzilla::Testopia::Environment->new($env_id);
|
||||
my $note = "Environment Changed by ". Bugzilla->user->login;
|
||||
$note .= ". Old environment: '". $self->environment->name;
|
||||
$note .= "' New environment: '". $environment->name;
|
||||
$note .= "'. Resetting to IDLE.";
|
||||
$self->append_note($note);
|
||||
}
|
||||
}
|
||||
$self->set_as_current;
|
||||
return $self;
|
||||
}
|
||||
|
||||
=head2 _update_fields
|
||||
|
@ -408,6 +376,10 @@ if the status is a closed status.
|
|||
sub set_status {
|
||||
my $self = shift;
|
||||
my ($status_id) = @_;
|
||||
|
||||
my $oldstatus = $self->status;
|
||||
my $newstatus = $self->lookup_status($status_id);
|
||||
|
||||
$self->_update_fields({'case_run_status_id' => $status_id});
|
||||
if ($status_id == IDLE){
|
||||
$self->_update_fields({'close_date' => undef});
|
||||
|
@ -428,42 +400,14 @@ sub set_status {
|
|||
$self->update_bugs('REOPENED') if ($status_id == FAILED);
|
||||
$self->update_bugs('VERIFIED') if ($status_id == PASSED);
|
||||
}
|
||||
|
||||
|
||||
my $note = "Status changed from $oldstatus to $newstatus by ". Bugzilla->user->login;
|
||||
$note .= " for build '". $self->build->name ."' and environment '". $self->environment->name;
|
||||
$self->append_note($note);
|
||||
$self->{'case_run_status_id'} = $status_id;
|
||||
$self->{'status'} = undef;
|
||||
}
|
||||
|
||||
sub update_bugs {
|
||||
my $self = shift;
|
||||
my ($status) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $timestamp = Bugzilla::Testopia::Util::get_time_stamp();
|
||||
foreach my $bug (@{$self->bugs}){
|
||||
my $oldstatus = $bug->bug_status;
|
||||
|
||||
return if ($status eq 'VERIFIED' && $oldstatus ne 'RESOLVED');
|
||||
return if ($status eq 'REOPENED' && $oldstatus !~ /(RESOLVED|VERIFIED|CLOSED)/);
|
||||
|
||||
my $comment = "Status updated by Testopia: ". Param('urlbase');
|
||||
$comment .= "tr_show_caserun.cgi?caserun_id=" . $self->id;
|
||||
|
||||
$dbh->bz_lock_tables("bugs WRITE, fielddefs READ, longdescs WRITE, bugs_activity WRITE");
|
||||
$dbh->do("UPDATE bugs
|
||||
SET bug_status = ?,
|
||||
delta_ts = ?
|
||||
WHERE bug_id = ?",
|
||||
undef,($status, $timestamp, $bug->bug_id));
|
||||
LogActivityEntry($bug->bug_id, 'bug_status', $oldstatus,
|
||||
$status, Bugzilla->user->id, $timestamp);
|
||||
LogActivityEntry($bug->bug_id, 'resolution', $bug->resolution, '',
|
||||
Bugzilla->user->id, $timestamp) if ($status eq 'REOPENED');
|
||||
AppendComment($bug->bug_id, Bugzilla->user->id, $comment,
|
||||
!Bugzilla->user->in_group(Param('insidergroup')), $timestamp);
|
||||
|
||||
$dbh->bz_unlock_tables();
|
||||
}
|
||||
}
|
||||
|
||||
=head2 set_assignee
|
||||
|
||||
Sets the assigned tester for the case-run
|
||||
|
@ -473,7 +417,18 @@ Sets the assigned tester for the case-run
|
|||
sub set_assignee {
|
||||
my $self = shift;
|
||||
my ($user_id) = @_;
|
||||
|
||||
my $oldassignee = $self->assignee->login;
|
||||
my $newassignee = Bugzilla::User->new($user_id);
|
||||
|
||||
$self->_update_fields({'assignee' => $user_id});
|
||||
$self->{'assignee'} = $newassignee;
|
||||
|
||||
my $note = "Assignee changed from $oldassignee to ". $newassignee->login;
|
||||
$note .= " by ". Bugzilla->user->login;
|
||||
$note .= " for build '". $self->build->name;
|
||||
$note .= "' and environment '". $self->environment->name;
|
||||
$self->append_note($note);
|
||||
}
|
||||
|
||||
=head2 lookup_status
|
||||
|
@ -665,23 +620,62 @@ sub detach_bug {
|
|||
|
||||
}
|
||||
|
||||
=head2 get_buglist
|
||||
=head2 update_bugs
|
||||
|
||||
Returns a comma separated string off bug ids associated with
|
||||
this case-run
|
||||
Updates bug status depending on whether the case passed or failed. If
|
||||
the case failed it will reopen any attached bugs that are closed. If it
|
||||
passed it will mark RESOLVED bugs VERIFIED.
|
||||
|
||||
=cut
|
||||
|
||||
sub get_buglist {
|
||||
sub update_bugs {
|
||||
my $self = shift;
|
||||
my ($status) = @_;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $timestamp = Bugzilla::Testopia::Util::get_time_stamp();
|
||||
foreach my $bug (@{$self->bugs}){
|
||||
my $oldstatus = $bug->bug_status;
|
||||
|
||||
return if ($status eq 'VERIFIED' && $oldstatus ne 'RESOLVED');
|
||||
return if ($status eq 'REOPENED' && $oldstatus !~ /(RESOLVED|VERIFIED|CLOSED)/);
|
||||
|
||||
my $comment = "Status updated by Testopia: ". Param('urlbase');
|
||||
$comment .= "tr_show_caserun.cgi?caserun_id=" . $self->id;
|
||||
|
||||
$dbh->bz_lock_tables("bugs WRITE, fielddefs READ, longdescs WRITE, bugs_activity WRITE");
|
||||
$dbh->do("UPDATE bugs
|
||||
SET bug_status = ?,
|
||||
delta_ts = ?
|
||||
WHERE bug_id = ?",
|
||||
undef,($status, $timestamp, $bug->bug_id));
|
||||
LogActivityEntry($bug->bug_id, 'bug_status', $oldstatus,
|
||||
$status, Bugzilla->user->id, $timestamp);
|
||||
LogActivityEntry($bug->bug_id, 'resolution', $bug->resolution, '',
|
||||
Bugzilla->user->id, $timestamp) if ($status eq 'REOPENED');
|
||||
AppendComment($bug->bug_id, Bugzilla->user->id, $comment,
|
||||
!Bugzilla->user->in_group(Param('insidergroup')), $timestamp);
|
||||
|
||||
$dbh->bz_unlock_tables();
|
||||
}
|
||||
}
|
||||
|
||||
=head2 obliterate
|
||||
|
||||
Removes this caserun, its history, and all things that reference it.
|
||||
|
||||
=cut
|
||||
|
||||
sub obliterate {
|
||||
my $self = shift;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $bugids = $dbh->selectcol_arrayref("SELECT bug_id
|
||||
FROM test_case_bugs
|
||||
WHERE case_run_id=?",
|
||||
undef, $self->{'case_run_id'});
|
||||
return join(',', @{$bugids});
|
||||
}
|
||||
|
||||
$dbh->do("DELETE FROM test_case_bugs WHERE case_run_id IN (" .
|
||||
join(",", @{$self->get_case_run_list}) . ")", undef, $self->id);
|
||||
$dbh->do("DELETE FROM test_case_runs WHERE case_id = ? AND run_id = ?",
|
||||
undef, ($self->case_id, $self->run_id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
###############################
|
||||
#### Accessors ####
|
||||
###############################
|
||||
|
@ -918,6 +912,23 @@ sub bug_count{
|
|||
return $self->{'bug_count'};
|
||||
}
|
||||
|
||||
=head2 get_buglist
|
||||
|
||||
Returns a comma separated string off bug ids associated with
|
||||
this case-run
|
||||
|
||||
=cut
|
||||
|
||||
sub get_buglist {
|
||||
my $self = shift;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $bugids = $dbh->selectcol_arrayref("SELECT bug_id
|
||||
FROM test_case_bugs
|
||||
WHERE case_run_id=?",
|
||||
undef, $self->{'case_run_id'});
|
||||
return join(',', @{$bugids});
|
||||
}
|
||||
|
||||
=head2 is_open_status
|
||||
|
||||
Returns true if the status of this case-run is an open status
|
||||
|
@ -1041,23 +1052,6 @@ sub candelete {
|
|||
return 0;
|
||||
}
|
||||
|
||||
=head2 obliterate
|
||||
|
||||
Removes this caserun, its history, and all things that reference it.
|
||||
|
||||
=cut
|
||||
|
||||
sub obliterate {
|
||||
my $self = shift;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
|
||||
$dbh->do("DELETE FROM test_case_bugs WHERE case_run_id IN (" .
|
||||
join(",", @{$self->get_case_run_list}) . ")", undef, $self->id);
|
||||
$dbh->do("DELETE FROM test_case_runs WHERE case_id = ? AND run_id = ?",
|
||||
undef, ($self->case_id, $self->run_id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
TestCase TestRun
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<a id="st1_[% index %]">
|
||||
<img id="im[% loop.count %]_[% index %]" src="testopia/img/[% status.name FILTER none %]_gray.gif" width="23" height="23" alt="[% status.name FILTER none %] (disabled)" title="[% status.name FILTER none %](disabled)" border="0" /></a>
|
||||
[% ELSE %]
|
||||
<a id="st1_[% index %]" href="javascript:chStat([% index %], [% status.id FILTER none %], [% caserun.id FILTER none %]); chNote([% index %], [% caserun.id FILTER none %], document.getElementById('notes[% index %]').value);">
|
||||
<a id="st1_[% index %]" href="javascript:chNote([% index %], [% caserun.id FILTER none %], document.getElementById('notes[% index %]').value); chStat([% index %], [% status.id FILTER none %], [% caserun.id FILTER none %]);">
|
||||
<img id="im1_[% index %]" src="testopia/img/[% status.name FILTER none %].gif" width="23" height="23" alt="[% status.name FILTER none %]" title="[% status.name FILTER none %]" border="0" /></a>
|
||||
[% END %]
|
||||
</div>
|
||||
|
@ -126,7 +126,7 @@
|
|||
<div style="float:left;"><input type="text" size="6" value="" id="mbg[% index %]" [% enabled %]/></div>
|
||||
<div class="cc_i"><input type="button" value="Attach Bug" id="sk[% index %]" onclick="attch([% index %], [% caserun.id FILTER none %], document.getElementById('mbg[% index %]').value);"/></div>
|
||||
[%##### Assignee #####%]
|
||||
<div class="cc_i"><input value="[% user.login FILTER html %]" id="assignee_[% index %]" /><input type="button" value="Assign" onclick="chOwn([% index %], [% caserun.id FILTER none %], document.getElementById('assignee_[% index %]').value)">
|
||||
<div class="cc_i"><input value="[% user.login FILTER html %]" id="assignee_[% index %]" /><input type="button" value="Assign" onclick="chNote([% index %], [% caserun.id FILTER none %], document.getElementById('notes[% index %]').value); chOwn([% index %], [% caserun.id FILTER none %], document.getElementById('assignee_[% index %]').value)">
|
||||
<a href="javascript:userLookup('document.Create.assigned_to', document.Create.assigned_to.value);">
|
||||
<image src="images/users.png" border="0" alt="Lookup User" title="Lookup User"></a>
|
||||
<a id="aw_[% index %]" href="javascript:aws([% index %], [% caserun.id FILTER none %])">
|
||||
|
|
|
@ -57,6 +57,18 @@ function fillrow(data, idx){
|
|||
return;
|
||||
}
|
||||
}
|
||||
function getNote(idx,cid){
|
||||
disableAllButtons(true);
|
||||
dojo.io.bind({
|
||||
url: "tr_show_caserun.cgi",
|
||||
content: { caserun_id: cid, index: idx, action: 'get_notes'},
|
||||
load: function(type, data, evt){
|
||||
dojo.byId('old_notes' + idx).innerHTML = data;
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
});
|
||||
}
|
||||
//chBld Updates the caserun build
|
||||
function chBld(idx, bid, sid, cid){
|
||||
disableAllButtons(true);
|
||||
|
@ -73,6 +85,7 @@ function chBld(idx, bid, sid, cid){
|
|||
displayMsg('pp'+ idx, 1, MSG_TESTLOG_UPDATED);
|
||||
setTimeout("clearMsg('pp"+ idx +"')",OK_TIMEOUT);
|
||||
disableAllButtons(false);
|
||||
getNote(idx,cid);
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
|
@ -96,6 +109,7 @@ function chEnv(idx, eid, sid, cid, oldid){
|
|||
displayMsg('pp'+ idx, 1, MSG_TESTLOG_UPDATED);
|
||||
setTimeout("clearMsg('pp"+ idx +"')",OK_TIMEOUT);
|
||||
disableAllButtons(false);
|
||||
getNote(idx,cid);
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
|
@ -130,6 +144,7 @@ function chStat(idx, sid, cid){
|
|||
displayMsg('pp'+ idx, 1, MSG_TESTLOG_UPDATED);
|
||||
setTimeout("clearMsg('pp"+ idx +"')",OK_TIMEOUT);
|
||||
disableAllButtons(false);
|
||||
getNote(idx,cid);
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
|
@ -149,6 +164,7 @@ function chNote(idx, cid, note){
|
|||
displayMsg('pp'+ idx, 1, MSG_TESTLOG_UPDATED);
|
||||
setTimeout("clearMsg('pp"+ idx +"')",OK_TIMEOUT);
|
||||
disableAllButtons(false);
|
||||
getNote(idx,cid);
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
|
@ -171,6 +187,7 @@ function chOwn(idx, cid, owner){
|
|||
displayMsg('pp'+ idx, 1, MSG_TESTLOG_UPDATED);
|
||||
setTimeout("clearMsg('pp"+ idx +"')",OK_TIMEOUT);
|
||||
disableAllButtons(false);
|
||||
getNote(idx,cid);
|
||||
},
|
||||
error: function(type, error){ alert(error.message);},
|
||||
mimetype: "text/plain"
|
||||
|
|
|
@ -122,29 +122,20 @@ if ($action eq 'Commit'){
|
|||
print $cgi->multipart_end if $serverpush;
|
||||
ThrowUserError("testopia-read-only", {'object' => 'Case Run', 'id' => $caserun->id});
|
||||
}
|
||||
|
||||
|
||||
# Switch to the record representing this build and environment combo.
|
||||
# If there is not one, it will create it and switch to that.
|
||||
$caserun = $caserun->switch($build,$env);
|
||||
|
||||
$caserun->set_status($status) if ($caserun->status_id != $status);
|
||||
$caserun->set_assignee($assignee) if ($caserun->assignee->id != $assignee);
|
||||
$caserun->append_note($notes);
|
||||
|
||||
foreach my $bug (@buglist){
|
||||
$caserun->attach_bug($bug);
|
||||
}
|
||||
|
||||
my $testedby;
|
||||
my $close_date;
|
||||
if ($caserun->is_closed_status($status)){
|
||||
$testedby = Bugzilla->user->id;
|
||||
$close_date = get_time_stamp();
|
||||
$caserun->update_bugs('REOPENED') if ($status == FAILED);
|
||||
$caserun->update_bugs('VERIFIED') if ($status == PASSED);
|
||||
}
|
||||
my %newfields = (
|
||||
'assignee' => $assignee,
|
||||
'testedby' => $testedby,
|
||||
'close_date' => $close_date,
|
||||
'case_run_status_id' => $status,
|
||||
'build_id' => $build,
|
||||
'environment_id' => $env,
|
||||
);
|
||||
$caserun->update(\%newfields);
|
||||
$caserun->append_note($notes);
|
||||
|
||||
}
|
||||
$vars->{'title'} = "Update Successful";
|
||||
$vars->{'tr_message'} = "$i Test Case-Runs Updated";
|
||||
|
|
|
@ -66,7 +66,6 @@ if ($action eq 'Commit'){
|
|||
my $notes = $cgi->param('notes');
|
||||
my $build = $cgi->param('caserun_build');
|
||||
my $env = $cgi->param('caserun_env');
|
||||
my $confirm = $cgi->param('confirm');
|
||||
my $assignee = DBNameToIdAndCheck(trim($cgi->param('assignee')));
|
||||
|
||||
validate_test_id($build, 'build');
|
||||
|
@ -81,65 +80,19 @@ if ($action eq 'Commit'){
|
|||
detaint_natural($build);
|
||||
detaint_natural($status);
|
||||
trick_taint($notes);
|
||||
|
||||
my %newfields = (
|
||||
'assignee' => $assignee,
|
||||
'testedby' => Bugzilla->user->id,
|
||||
'case_run_status_id' => $status,
|
||||
'build_id' => $build,
|
||||
'environment_id' => $env,
|
||||
);
|
||||
|
||||
my $is = $caserun->check_exists($caserun->run_id, $caserun->case_id, $build, $env);
|
||||
my $existing = Bugzilla::Testopia::TestCaseRun->new($is) if $is;
|
||||
if (($build != $caserun->build->id || $env != $caserun->environment->id)
|
||||
&& $is
|
||||
&& $existing->status ne 'IDLE'
|
||||
&& !$confirm){
|
||||
my $statuslist = $caserun->get_status_list;
|
||||
my $status;
|
||||
foreach my $stat (@$statuslist){
|
||||
if ($stat->{'id'} == $cgi->param('status')){
|
||||
$status = $stat->{'name'};
|
||||
last;
|
||||
}
|
||||
}
|
||||
$vars->{'existing'} = $existing;
|
||||
$vars->{'assignee'} = $cgi->param('assignee');
|
||||
$vars->{'status_name'} = $status;
|
||||
$vars->{'status'} = $cgi->param('status');
|
||||
$vars->{'notes'} = $notes;
|
||||
if ($caserun->is_closed_status($cgi->param('status'))){
|
||||
$vars->{'close_date'} = get_time_stamp();
|
||||
$vars->{'testedby'} = Bugzilla->user->login;
|
||||
}
|
||||
$vars->{'bugs'} = $cgi->param('bugs');
|
||||
$template->process("testopia/caserun/confirm.html.tmpl", $vars) ||
|
||||
ThrowTemplateError($template->error());
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($notes){
|
||||
$caserun->append_note($notes);
|
||||
}
|
||||
# Switch to the record representing this build and environment combo.
|
||||
# If there is not one, it will create it and switch to that.
|
||||
$caserun = $caserun->switch($build,$env);
|
||||
|
||||
$caserun->set_status($status) if ($caserun->status_id != $status);
|
||||
$caserun->set_assignee($assignee) if ($caserun->assignee->id != $assignee);
|
||||
$caserun->append_note($notes) if ($notes && $caserun->notes !~ /$notes/);
|
||||
|
||||
foreach my $bug (@buglist){
|
||||
$caserun->attach_bug($bug);
|
||||
}
|
||||
|
||||
my $oldstatus_id = $caserun->status_id;
|
||||
if ($status != $oldstatus_id){
|
||||
my $newstatus = $caserun->lookup_status($status);
|
||||
my $oldstatus = $caserun->status();
|
||||
$caserun->update_bugs('REOPENED') if ($newstatus eq 'FAILED');
|
||||
$caserun->update_bugs('VERIFIED') if ($newstatus eq 'PASSED');
|
||||
|
||||
my $note = "Status changed from $oldstatus to $newstatus by ". Bugzilla->user->login;
|
||||
$caserun->append_note($note);
|
||||
}
|
||||
|
||||
$caserun = Bugzilla::Testopia::TestCaseRun->new($caserun->update(\%newfields));
|
||||
$vars->{'tr_message'} = "Case-run updated.";
|
||||
display($caserun);
|
||||
}
|
||||
|
@ -192,25 +145,20 @@ elsif ($action eq 'update_build'){
|
|||
my $build_id = $cgi->param('build_id');
|
||||
detaint_natural($build_id);
|
||||
validate_test_id($build_id, 'build');
|
||||
my $is = $caserun->check_exists($caserun->run_id, $caserun->case_id, $build_id, $caserun->environment->id);
|
||||
if ($is){
|
||||
$caserun = Bugzilla::Testopia::TestCaseRun->new($is);
|
||||
}
|
||||
elsif ($caserun->status ne 'IDLE'){
|
||||
my $cid = $caserun->clone({'build_id' => $build_id });
|
||||
$caserun = Bugzilla::Testopia::TestCaseRun->new($cid);
|
||||
}
|
||||
else {
|
||||
$caserun->set_build($build_id );
|
||||
}
|
||||
|
||||
$caserun = $caserun->switch($build_id, $caserun->environment->id);
|
||||
|
||||
my $body_data;
|
||||
my $head_data;
|
||||
|
||||
$vars->{'caserun'} = $caserun;
|
||||
$vars->{'index'} = $cgi->param('index');
|
||||
|
||||
$template->process("testopia/caserun/short-form-header.html.tmpl", $vars, \$head_data) ||
|
||||
ThrowTemplateError($template->error());
|
||||
$template->process("testopia/caserun/short-form.html.tmpl", $vars, \$body_data) ||
|
||||
ThrowTemplateError($template->error());
|
||||
|
||||
print $head_data . "|~+" . $body_data;
|
||||
}
|
||||
elsif ($action eq 'update_environment'){
|
||||
|
@ -223,17 +171,9 @@ elsif ($action eq 'update_environment'){
|
|||
my $environment_id = $cgi->param('caserun_env');
|
||||
detaint_natural($environment_id);
|
||||
validate_test_id($environment_id, 'environment');
|
||||
my $is = $caserun->check_exists($caserun->run_id, $caserun->case_id, $caserun->build->id, $environment_id);
|
||||
if ($is){
|
||||
$caserun = Bugzilla::Testopia::TestCaseRun->new($is);
|
||||
}
|
||||
elsif ($caserun->status ne 'IDLE'){
|
||||
my $cid = $caserun->clone({'environment_id' => $environment_id });
|
||||
$caserun = Bugzilla::Testopia::TestCaseRun->new($cid);
|
||||
}
|
||||
else {
|
||||
$caserun->set_environment($environment_id );
|
||||
}
|
||||
|
||||
$caserun = $caserun->switch($caserun->build->id, $environment_id);
|
||||
|
||||
my $body_data;
|
||||
my $head_data;
|
||||
$vars->{'caserun'} = $caserun;
|
||||
|
@ -253,15 +193,9 @@ elsif ($action eq 'update_status'){
|
|||
}
|
||||
my $status_id = $cgi->param('status_id');
|
||||
detaint_natural($status_id);
|
||||
if ($status_id != $caserun->status_id){
|
||||
my $oldstatus = $caserun->status();
|
||||
$caserun->set_status($status_id);
|
||||
my $newstatus = $caserun->status();
|
||||
my $note = "Status changed from $oldstatus to $newstatus by ". Bugzilla->user->login;
|
||||
$note .= " for build: '". $caserun->build->name;
|
||||
$note .= "' and environment: '". $caserun->environment->name ."'.";
|
||||
$caserun->append_note($note);
|
||||
}
|
||||
|
||||
$caserun->set_status($status_id);
|
||||
|
||||
print $caserun->status ."|". $caserun->close_date ."|". $caserun->testedby->login;
|
||||
if ($caserun->updated_deps) {
|
||||
print "|". join(',', @{$caserun->updated_deps});
|
||||
|
@ -276,8 +210,7 @@ elsif ($action eq 'update_note'){
|
|||
}
|
||||
my $note = $cgi->param('note');
|
||||
trick_taint($note);
|
||||
$caserun->append_note($note);
|
||||
print '<pre>' . $caserun->notes . '</pre>';
|
||||
$caserun->append_note($note);
|
||||
}
|
||||
elsif ($action eq 'update_assignee'){
|
||||
Bugzilla->login(LOGIN_REQUIRED);
|
||||
|
@ -293,6 +226,15 @@ elsif ($action eq 'update_assignee'){
|
|||
}
|
||||
$caserun->set_assignee($assignee_id);
|
||||
}
|
||||
elsif ($action eq 'get_notes'){
|
||||
Bugzilla->login(LOGIN_REQUIRED);
|
||||
my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id);
|
||||
if (!$caserun->canedit){
|
||||
print "Error - You don't have permission";
|
||||
exit;
|
||||
}
|
||||
print '<pre>' . $caserun->notes . '</pre>';
|
||||
}
|
||||
elsif ($action eq 'attach_bug'){
|
||||
Bugzilla->login(LOGIN_REQUIRED);
|
||||
my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id);
|
||||
|
|
Загрузка…
Ссылка в новой задаче