Bug 69481 - Tests/debug

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1050 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-11-11 13:36:23 +00:00
parent 12eaef65b2
commit bbe6aa42b1
14 changed files with 49 additions and 46 deletions

View File

@ -31,6 +31,8 @@ use base qw(Bugzilla::Field::Choice);
###############################
use constant DB_TABLE => 'classifications';
use constant FIELD_NAME => 'classification';
use constant NAME_FIELD => 'name';
use constant LIST_ORDER => 'sortkey, name';

View File

@ -36,6 +36,7 @@ use Bugzilla::Series;
###############################
use constant DB_TABLE => 'components';
use constant FIELD_NAME => 'component';
use constant LIST_ORDER => 'product_id, name';

View File

@ -54,11 +54,11 @@ our $sortkey = 600;
sub set_useclassification
{
my ($value, $param) = @_;
$_[0] = $value = $value ? 1 : 0;
$_[0] = $value ? 1 : 0;
my $vf = $value ? Bugzilla->get_field('classification')->id : undef;
my $f = Bugzilla->get_field('product');
$f->set_visibility_field($vf);
$f->set_obsolete($value);
$f->set_obsolete($value ? 0 : 1);
$f->update;
return '';
}
@ -68,7 +68,8 @@ sub set_usefield
{
my ($value, $param) = @_;
my $f = Bugzilla->get_field(USENAMES->{$param->{name}});
$f->set_obsolete($_[0] = $value ? 1 : 0);
$_[0] = $value ? 1 : 0;
$f->set_obsolete($value ? 0 : 1);
$f->update;
return '';
}

View File

@ -1129,6 +1129,7 @@ sub get_field_id
sub update_visibility_values
{
my ($controlled_field, $controlled_value_id, $visibility_value_ids) = @_;
$visibility_value_ids ||= [];
my $vis_field = $controlled_value_id
? $controlled_field->value_field
: $controlled_field->visibility_field;

View File

@ -103,26 +103,30 @@ sub type
if ($class->CLASS_MAP->{$field_name})
{
$package = $class->CLASS_MAP->{$field_name};
eval "require $package";
if (!defined *{"${package}::DB_TABLE"})
{
eval "require $package";
}
}
else
{
# For generic classes, we use a lowercase class name, so as
# not to interfere with any real subclasses we might make some day.
$package = "Bugzilla::Field::Choice::$field_name";
}
Bugzilla->request_cache->{"field_$package"} = $field_obj;
# The package only needs to be created once. We check if the DB_TABLE
# glob for this package already exists, which tells us whether or not
# we need to create the package (this works even under mod_perl, where
# this package definition will persist across requests)).
if (!defined *{"${package}::DB_TABLE"}) {
eval <<EOC;
package $package;
use base qw(Bugzilla::Field::Choice);
use constant DB_TABLE => '$field_name';
# The package only needs to be created once. We check if the DB_TABLE
# glob for this package already exists, which tells us whether or not
# we need to create the package (this works even under mod_perl, where
# this package definition will persist across requests)).
if (!defined *{"${package}::DB_TABLE"})
{
eval <<EOC;
package $package;
use base qw(Bugzilla::Field::Choice);
use constant DB_TABLE => '$field_name';
use constant FIELD_NAME => '$field_name';
EOC
}
}
return $package;
@ -147,20 +151,10 @@ sub new {
# Database Manipulation #
#########################
# Our subclasses can take more arguments than we normally accept.
# So, we override create() to remove arguments that aren't valid
# columns. (Normally Bugzilla::Object dies if you pass arguments
# that aren't valid columns.)
sub create {
my $class = shift;
my ($params) = @_;
foreach my $key (keys %$params) {
if (!grep {$_ eq $key} $class->DB_COLUMNS) {
delete $params->{$key};
}
}
return $class->SUPER::create(@_);
}
# vitalif@mail.ru 2010-11-11 //
# This is incorrect in create() to remove arguments that are not valid DB columns
# BEFORE calling run_create_validators etc, as these methods can change
# params hash (for example turn Bugzilla::Product to product_id field)
sub update {
my $self = shift;
@ -296,14 +290,10 @@ sub bug_count {
return $count;
}
sub field {
sub field
{
my $invocant = shift;
my $class = ref $invocant || $invocant;
my $cache = Bugzilla->request_cache;
# This is just to make life easier for subclasses. Our auto-generated
# subclasses from type() already have this set.
$cache->{"field_$class"} ||= Bugzilla->get_field($class->DB_TABLE);
return $cache->{"field_$class"};
return Bugzilla->get_field($invocant->FIELD_NAME);
}
sub is_default {

View File

@ -34,6 +34,8 @@ use Bugzilla::Error;
use constant DEFAULT_SORTKEY => 0;
use constant DB_TABLE => 'milestones';
use constant FIELD_NAME => 'target_milestone';
use constant NAME_FIELD => 'value';
use constant LIST_ORDER => 'sortkey, value';

View File

@ -45,6 +45,7 @@ use constant DEFAULT_CLASSIFICATION_ID => 1;
###############################
use constant DB_TABLE => 'products';
use constant FIELD_NAME => 'product';
# Reset these back to the Bugzilla::Object defaults, instead of the
# Bugzilla::Field::Choice defaults.
use constant NAME_FIELD => 'name';

View File

@ -200,7 +200,7 @@ sub CHART_FIELDS
{
if (!Bugzilla->request_cache->{search_chart_fields})
{
my @fielddefs = Bugzilla->get_fields({obsolete => 0});
my @fielddefs = Bugzilla->get_fields;
my %searchcols = %{ COLUMNS() };
for (@fielddefs)
{

View File

@ -45,6 +45,7 @@ use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw(
);
use constant DB_TABLE => 'bug_status';
use constant FIELD_NAME => 'bug_status';
# This has all the standard Bugzilla::Field::Choice columns plus "is_open"
sub DB_COLUMNS {

View File

@ -34,6 +34,8 @@ use Bugzilla::Error;
use constant DEFAULT_VERSION => 'unspecified';
use constant DB_TABLE => 'versions';
use constant FIELD_NAME => 'version';
use constant NAME_FIELD => 'value';
# This is "id" because it has to be filled in and id is probably the fastest.
# We do a custom sort in new_from_list below.
@ -129,7 +131,8 @@ sub bug_count {
sub create
{
my $class = shift;
my $self = $class->SUPER::create(@_);
my ($params) = @_;
my $self = $class->SUPER::create($params);
if ($self)
{
# Fill visibility values

View File

@ -18,7 +18,7 @@ die "Please create passwords.conf" if !%$passwords;
'bugzilla_path' => '/home/www/localhost/bugs32-up',
'master_group' => 108,
'admin_group' => 1,
'test_bug_1' => 58702,
'test_bug_1' => 32766,
'test_bug_2' => 38765,
'admin_user_login' => 'filippov@custis.ru',
'admin_user_username' => 'filippov',

View File

@ -29,7 +29,7 @@ my $group_id = $sel->get_value("group_id");
# Mark the Selenium-test group as Shown/Mandatory for TestProduct.
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Edit Group Controls for TestProduct");
@ -148,7 +148,7 @@ ok(!$sel->is_element_present("b$bug2_id"), "Bug $bug2_id NOT restricted to the b
# Make the Selenium-test group mandatory for TestProduct.
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->is_text_present_ok("Selenium-test: Shown/Mandatory");
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load(WAIT_TIME);
@ -260,7 +260,7 @@ $sel->is_element_present_ok("b$bug4_id", undef, "Bug $bug4_id restricted to the
# Try to remove the Selenium-test group from TestProduct, but DON'T do it!
# We just want to make sure a warning is displayed about this removal.
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->is_text_present_ok("Selenium-test: Mandatory/Mandatory");
$sel->click_ok("link=Edit Group Access Controls:");
$sel->wait_for_page_to_load(WAIT_TIME);

View File

@ -19,7 +19,7 @@ set_parameters($sel, {'Bug Fields' => {'usetargetmilestone-on'
# 2nd step: Add the milestone "2.0" (with sortkey = 10) to the TestProduct product.
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", "Archive");
$sel->click_ok("link=Edit milestones:", undef, "Go to the Edit milestones page");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Select milestone of product 'TestProduct'", "Display milestones");
@ -36,7 +36,7 @@ $sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Milestone Created", "Milestone Created");
# 2.5nd step (custis): Get default component and its version
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->click_ok("link=Edit components:", undef, "Go to the Edit components page");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Select component of product 'TestProduct'", "Display components");

View File

@ -17,7 +17,7 @@ set_parameters($sel, { "Bug Fields" => {"usetargetmilestone-on" => undef} });
# Create a new milestone to the 'TestProduct' product.
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->click_ok("link=Edit milestones:");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Select milestone of product 'TestProduct'");
@ -46,6 +46,7 @@ $sel->title_is("Bug $test_bug_1 processed");
open_advanced_search_page($sel);
$sel->is_text_present_ok("Target:");
$sel->remove_all_selections_ok("bug_status");
$sel->remove_all_selections_ok("product");
$sel->add_selection_ok("product", "label=TestProduct");
$sel->add_selection_ok("target_milestone", "label=TM1");
@ -92,7 +93,7 @@ ok($text =~ /OK, the selenium_m0 search is gone./, "The selenium_m0 search is go
set_parameters($sel, { "Bug Fields" => {"usetargetmilestone-on" => undef} });
edit_product($sel, "TestProduct");
edit_product($sel, "TestProduct", 'Archive');
$sel->click_ok("link=Edit milestones:");
$sel->wait_for_page_to_load(WAIT_TIME);
$sel->title_is("Select milestone of product 'TestProduct'");