Actions
Bug #4061
closedNeed test for dependent destroy of org and user
Description
https://github.com/Katello/katello/pull/2895
The above pull-request fixes an issue that prevented deletion of an org or user that had notices or task_statuses associated with it. I was not able to write a minitest that triggered the failure. Below is the script that I used to reproduce the problem during development:
#!/bin/csh -f echo "============ user delete then org delete ============" echo " SETUP" katello -u xadmin -p admin user create --username=user$1 --password=admin --email=foo@bar.com katello -u xadmin -p admin user assign_role --username user$1 --role Administrator katello -u user$1 -p admin org create --name org$1 katello -u user$1 -p admin provider import_manifest --name "Red Hat" --file ~/Downloads/Mega_Corp.zip --org org$1 katello -u user$1 -p admin provider refresh_manifest --name "Red Hat" --org org$1 echo " ORG DELETE" katello -u user$1 -p admin org delete --name org$1 echo " USER DELETE" katello -u xadmin -p admin user delete --username=user$1 echo "============ org delete then user delete ============" echo " SETUP" katello -u xadmin -p admin user create --username=user$1x --password=admin --email=foo@bar.com katello -u xadmin -p admin user assign_role --username user$1x --role Administrator katello -u user$1x -p admin org create --name org$1x katello -u user$1x -p admin provider import_manifest --name "Red Hat" --file ~/Downloads/Mega_Corp.zip --org org$1x katello -u user$1x -p admin provider refresh_manifest --name "Red Hat" --org org$1x echo " USER DELETE" katello -u xadmin -p admin user delete --username=user$1x echo " ORG DELETE" katello -u xadmin -p admin org delete --name org$1x
Also my attempt at writing a test/models/organization_test.rb
```ruby- Test dependent destroy of tasks and notices on orgs and users
- https://bugzilla.redhat.com/show_bug.cgi?id=1001609
class OrganizationTestDependentDestroy < MiniTest::Rails::ActiveSupport::TestCase
extend ActiveRecord::TestFixtures
fixtures :all
def self.before_suite
services = ['Candlepin', 'Pulp', 'ElasticSearch', 'Foreman']
models = ['Organization', 'KTEnvironment', 'Notice',
'User', 'TaskStatus', 'Provider']
disable_glue_layers(services, models, true)
end
def setup
@user = User.create!(:username => 'yUserTaskNotices', :email => 'foo@bar.com', :password => 'abcdef123')
@user.roles << Role.find(roles(:administrator))
@user.save!
User.current = @user
@org = Organization.create!(:name => 'yOrgTaskNotices', :label => 'OrgTaskNotices')
Notice.create!(:text=>'Test notice', :level => :success, :details => 'Test details',
:user_notices => [UserNotice.create!(:user => @user)])
TaskStatus.create!(:organization_id => @org.id, :uuid => 'FOO', :progress=>'0', :user => @user)
User.current = User.find(users(:admin))
end
def test_delete_org_then_user
refute_empty TaskStatus.all.to_a
Provider.any_instance.stubs(:prevent_redhat_deletion).returns(true)
@org.destroy
@user.destroy
assert_nil User.find_by_username('UserTaskNotices')
assert_nil Organization.find_by_name('OrgTaskNotices')
end
#def test_delete_user_then_org
- @user.destroy
- @org.destroy
#end
end
```
Created: thomasmckay on September 09, 2013 14:39 +00:00
Imported from https://api.github.com/repos/Katello/katello/issues/2905
Actions