Repository navigation
Bug 2085398 - Make flag_activity.who NOT NULL, add a starting flag_activity row for older flags and store the cutoff #2830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
241c2ec
Bug 2085398 - Make flag_activity.who NOT NULL, add a starting flag_ac…
Xzzz 5c5f944
Bug 2085398 - Log flag_activity when a deleted user's requests are cl…
Xzzz 693fdef
Bug 2085398 - Add the flag_activity.who foreign key back with foreign…
Xzzz f8e4e92
Bug 2085398 - Test that the flag_activity.who foreign key is added back
Xzzz b27aea0
Bug 2085398 - Test the starting flag_activity row of an attachment flag
Xzzz 29c7e1d
Bug 2085398 - Don't refer to Bugzilla::FlagActivity->cutoff before #2796
Xzzz 1ea2e80
Bug 2085398 - Set flag_activity.requestee_id to NULL when the request…
Xzzz a7f1517
Bug 2085398 - Let editusers delete a requestee kept in flag_activity
Xzzz 55a159b
Bug 2085398 - Always clean up after the requestee deletion test and t…
Xzzz b0f4c33
Bug 2085398 - Make flag_activity.who NOT NULL in place on MySQL
Xzzz 6a80a48
Bug 2085398 - Count only bugs_activity in the user deletion warning
Xzzz e76aee5
Bug 2085398 - Test the flag_activity row logged when a deleted user's…
Xzzz 1bc33c4
Merge branch 'master' into bug-2085398-schema
dklawren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| use strict; | ||
| use warnings; | ||
| use lib qw(lib ../../lib ../../local/lib/perl5); | ||
|
|
||
| use Bugzilla; | ||
|
|
||
| use Test::More "no_plan"; | ||
|
|
||
| use QA::Util; | ||
|
|
||
| my ($sel, $config) = get_selenium(); | ||
| my $dbh = Bugzilla->dbh; | ||
| my ($user_id, $flag_id); | ||
|
|
||
| # Runs even if a check below dies, so that a rerun finds a clean database. | ||
| END { | ||
| if ($flag_id) { | ||
| $dbh->do('DELETE FROM flag_activity WHERE flag_id = ?', undef, $flag_id); | ||
| $dbh->do('DELETE FROM flags WHERE id = ?', undef, $flag_id); | ||
| } | ||
| $dbh->do('DELETE FROM profiles WHERE userid = ?', undef, $user_id) if $user_id; | ||
| eval { | ||
| set_parameters($sel, | ||
| {"Administrative Policies" => {"allowuserdeletion-off" => undef}}); | ||
| logout($sel); | ||
| }; | ||
| } | ||
|
|
||
| log_in($sel, $config, 'admin'); | ||
| set_parameters($sel, | ||
| {"Administrative Policies" => {"allowuserdeletion-on" => undef}}); | ||
|
|
||
| # A user asked to set a flag, and named as requestee in the flag history, can | ||
| # be deleted: the request is cleared and the history keeps the row without | ||
| # the requestee. | ||
| my $login = 'requestee@selenium.bugzilla.org'; | ||
| $dbh->do( | ||
| "INSERT INTO profiles (login_name, realname, cryptpassword) | ||
| VALUES (?, 'Requestee', '*')", undef, $login | ||
| ); | ||
| $user_id = $dbh->bz_last_key('profiles', 'userid'); | ||
| my ($admin_id) | ||
| = $dbh->selectrow_array('SELECT userid FROM profiles WHERE login_name = ?', | ||
| undef, $config->{admin_user_login}); | ||
| my ($bug_id) = $dbh->selectrow_array('SELECT MIN(bug_id) FROM bugs'); | ||
| my ($type_id) | ||
| = $dbh->selectrow_array( | ||
| "SELECT MIN(id) FROM flagtypes WHERE target_type = 'b'"); | ||
| $dbh->do( | ||
| "INSERT INTO flags (type_id, status, bug_id, creation_date, | ||
| modification_date, setter_id, requestee_id) | ||
| VALUES (?, '?', ?, NOW(), NOW(), ?, ?)", undef, $type_id, $bug_id, $admin_id, | ||
| $user_id | ||
| ); | ||
| $flag_id = $dbh->bz_last_key('flags', 'id'); | ||
| $dbh->do( | ||
| "INSERT INTO flag_activity | ||
| (flag_when, type_id, flag_id, setter_id, who, requestee_id, bug_id, status) | ||
| VALUES (NOW(), ?, ?, ?, ?, ?, ?, '?')", undef, $type_id, $flag_id, $admin_id, | ||
| $admin_id, $user_id, $bug_id | ||
| ); | ||
| my $history_id = $dbh->bz_last_key('flag_activity', 'id'); | ||
|
|
||
| $sel->open_ok("/editusers.cgi?action=del&userid=$user_id"); | ||
| $sel->title_is("Confirm deletion of user $login"); | ||
| ok(!$sel->is_text_present('You cannot delete this user account'), | ||
| 'The requestee can be deleted'); | ||
| $sel->click_ok("delete"); | ||
| $sel->wait_for_page_to_load_ok(WAIT_TIME); | ||
| $sel->title_is("User $login deleted"); | ||
|
|
||
| is( | ||
| scalar $dbh->selectrow_array( | ||
| 'SELECT COUNT(*) FROM flag_activity WHERE id = ? AND requestee_id IS NULL', | ||
| undef, $history_id | ||
| ), | ||
| 1, | ||
| 'The flag history keeps the row without the requestee' | ||
| ); | ||
| is( | ||
| scalar $dbh->selectrow_array( | ||
| 'SELECT COUNT(*) FROM flags WHERE id = ? AND requestee_id IS NULL', | ||
| undef, $flag_id | ||
| ), | ||
| 1, | ||
| 'The request is cleared' | ||
| ); | ||
| is_deeply( | ||
| $dbh->selectall_arrayref( | ||
| 'SELECT status, who, requestee_id FROM flag_activity | ||
| WHERE flag_id = ? AND id > ?', undef, $flag_id, $history_id | ||
| ), | ||
| [['?', $admin_id, undef]], | ||
| 'Clearing the request is logged in the flag history, by the admin' | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.