run this script in rails console:
admin_email = EMAIL_ADDRESS_ASSOCIATED_WITH_ONE_OF_YOUR_ADMIN_ACCOUNTS
user_email = ONE_OF_YOUR_ALTERNATE_EMAIL_ADDRESSES
## mix's case :
admin_email = '[email protected]'
user_email = '[email protected]'
unless admin = User.find_by_email(admin_email)
admin = User.create(email: admin_email, password: "password", name: "Dummy Admin")
end
unless user = User.find_by_email(user_email)
user = User.create(email: user_email, password: "password", name: "Dummy USER")
end
group = Group.create(name: "TEST GROUP | RM USER 2", initialized: true)
group.add_admin(admin)
group.add_member(user)
Allocation.create(group: group, user: admin, amount: 100)
Allocation.create(group: group, user: user, amount: 100)
funded_bucket_a = Bucket.create(group: group, user: admin, target: 20, name: "FUNDED A", description: "asdf", status: 'funded')
funding_bucket_a = Bucket.create(group: group, user: admin, target: 60, name: "FUNDING A", description: "asdf", status: 'live')
idea_bucket_a = Bucket.create(group: group, user: admin, target: 10, name: "IDEA A", description: "asdf", status: 'draft')
funded_bucket_b = Bucket.create(group: group, user: user, target: 20, name: "FUNDED B", description: "asdf", status: 'funded')
funding_bucket_b = Bucket.create(group: group, user: user, target: 60, name: "FUNDING B", description: "asdf", status: 'live')
idea_bucket_b = Bucket.create(group: group, user: user, target: 10, name: "IDEA B", description: "asdf", status: 'draft')
Contribution.create(bucket: funding_bucket_a, amount: 15, user: admin) # stays
Contribution.create(bucket: funding_bucket_b, amount: 5, user: admin) # goes
Contribution.create(bucket: funded_bucket_a, amount: 15, user: admin) # stays
Contribution.create(bucket: funded_bucket_b, amount: 5, user: admin) # stays
Contribution.create(bucket: funding_bucket_a, amount: 5, user: user) # stays
Contribution.create(bucket: funding_bucket_b, amount: 20, user: user) # goes
Contribution.create(bucket: funded_bucket_a, amount: 5, user: user) # stays
Contribution.create(bucket: funded_bucket_b, amount: 15, user: user) # stays
Comment.create(bucket: funded_bucket_a, body: "I WILL SOON VANISH", user: user)
Comment.create(bucket: funding_bucket_a, body: "I WILL SOON VANISH", user: user)
Comment.create(bucket: idea_bucket_a, body: "I WILL SOON VANISH", user: user)
this will create a new group, with two users (both of which are associated with email addresses of yours). one is an admin and the other isn't. both users are given $100, and have created an 'idea', 'funding', and 'funded' bucket, each of which has a target of $10.
non-admin has funded admin's funded bucket entirely, and vice-versa. non-admin has halfway funded admin's funding bucket, and vice-versa. non-admin has commented on each of the admin's buckets.
now we have everything we need to start testing this feature!
confirm script success and remove user:
- log in as admin
- confirm that group balance is $200-40-45= $115 and personal balance is $100-40= $60.
- confirm that the script above has done what it should have
- go to the funders tab on the group page, and remove user "USER"
we expect to see the following
- on the group page:
- the group balance at the top of the group page should be $60 + 5 (refunded) = 65
- your balance should be $65
- on the 'all buckets' tab:
- "FUNDING B" should not exist
- "IDEA B" should not exist
- "FUNDED B" should still exist
- "FUNDED B" should have an author name of "[deleted user]"
- "FUNDED A" should still be under the 'funded' group
- on the 'funders' tab:
- "USER" shouldn't exist anymore NOTE: I think they should be there and marked deleted with the funds they had still noted
- on the bucket page for "FUNDED B"
- author name should be "[deleted user]" NOTE: if it's not DONE, then this is going to raise questions
- on the bucket page for "FUNDED A"
- "USER"s comment should still exist
- "USER"s comment should have author name "[deleted user]"
- on the bucket page for "FUNDING A"
- number of backers should now be 1
- amount pledged should be $20
- "USER"s comment should still exist
- "USER"s comment should have author name "[deleted user]"
- on the bucket page for "IDEA A"
- "USER"s comment should still exist
- "USER"s comment should have author name "[deleted user]"
- in admin account's email inbox
- there should be an email about "FUNDING B" being deleted, and you getting refunded $5.
- now, add a comment to "FUNDED B"
- "USER" should not have received an email about your comment
- now, log out, and attempt to log in as USER.
- this should trigger an error dialog that says "invalid credentials"
- now, log in as admin, go to the admin panel, and create a new group.
- invite the same "USER" to this new group
- create a bucket
- log out
- go to "USER"s email inbox, and open the group invitation email, and click the link
- no errors should occur, and you should be redirected to group page
- on group page sidenav, you should see only ONE group.
- attempting to view the group you were previously removed from by visiting its URL directly should cause error.
- finally, tomorrow morning, anytime after 6am
- "USER"'s email digest should not contain any information about the group they were removed from this is hard to test manually (slow), got good tests ??
""USER"'s email digest should not contain any information about the group they were removed from this is hard to test manually (slow), got good tests ??"
yep! tested here: https://github.com/cobudget/cobudget-api/blob/feature/remove-user/spec/services/user_service_spec.rb#L101