From bbe6aa42b11340cac3e8a9a53c8ed2c29982263c Mon Sep 17 00:00:00 2001 From: vfilippov Date: Thu, 11 Nov 2010 13:36:23 +0000 Subject: [PATCH] Bug 69481 - Tests/debug git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1050 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/Classification.pm | 2 ++ Bugzilla/Component.pm | 1 + Bugzilla/Config/BugFields.pm | 7 +++-- Bugzilla/Field.pm | 1 + Bugzilla/Field/Choice.pm | 56 ++++++++++++++--------------------- Bugzilla/Milestone.pm | 2 ++ Bugzilla/Product.pm | 1 + Bugzilla/Search.pm | 2 +- Bugzilla/Status.pm | 1 + Bugzilla/Version.pm | 5 +++- qa/config/selenium_test.conf | 2 +- qa/t/test_groups.t | 6 ++-- qa/t/test_milestones.t | 4 +-- qa/t/test_target_milestones.t | 5 ++-- 14 files changed, 49 insertions(+), 46 deletions(-) diff --git a/Bugzilla/Classification.pm b/Bugzilla/Classification.pm index ddece14b3..d95a02b88 100644 --- a/Bugzilla/Classification.pm +++ b/Bugzilla/Classification.pm @@ -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'; diff --git a/Bugzilla/Component.pm b/Bugzilla/Component.pm index fa3ab2614..2ee974d78 100644 --- a/Bugzilla/Component.pm +++ b/Bugzilla/Component.pm @@ -36,6 +36,7 @@ use Bugzilla::Series; ############################### use constant DB_TABLE => 'components'; +use constant FIELD_NAME => 'component'; use constant LIST_ORDER => 'product_id, name'; diff --git a/Bugzilla/Config/BugFields.pm b/Bugzilla/Config/BugFields.pm index 376b7fb6e..a3801a45c 100644 --- a/Bugzilla/Config/BugFields.pm +++ b/Bugzilla/Config/BugFields.pm @@ -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 ''; } diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 0a315b8f5..b30404d69 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -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; diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index 8e4236a97..8ed8907ee 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -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 < '$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 < '$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 { diff --git a/Bugzilla/Milestone.pm b/Bugzilla/Milestone.pm index ab6c7bc4f..abd7576d2 100644 --- a/Bugzilla/Milestone.pm +++ b/Bugzilla/Milestone.pm @@ -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'; diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm index c3e4fc583..0a1c6b87f 100644 --- a/Bugzilla/Product.pm +++ b/Bugzilla/Product.pm @@ -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'; diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 22af3b11a..01805bcd2 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -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) { diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm index 4d1281e7e..86c12f4b4 100644 --- a/Bugzilla/Status.pm +++ b/Bugzilla/Status.pm @@ -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 { diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm index 3c4e73e0d..c9a8fa4f5 100644 --- a/Bugzilla/Version.pm +++ b/Bugzilla/Version.pm @@ -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 diff --git a/qa/config/selenium_test.conf b/qa/config/selenium_test.conf index 0c9b00019..580887033 100644 --- a/qa/config/selenium_test.conf +++ b/qa/config/selenium_test.conf @@ -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', diff --git a/qa/t/test_groups.t b/qa/t/test_groups.t index cbd5ef46f..195c197b5 100644 --- a/qa/t/test_groups.t +++ b/qa/t/test_groups.t @@ -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); diff --git a/qa/t/test_milestones.t b/qa/t/test_milestones.t index c63288e2c..accdbb128 100644 --- a/qa/t/test_milestones.t +++ b/qa/t/test_milestones.t @@ -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"); diff --git a/qa/t/test_target_milestones.t b/qa/t/test_target_milestones.t index b68b33d23..ed2a91a23 100644 --- a/qa/t/test_target_milestones.t +++ b/qa/t/test_target_milestones.t @@ -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'");