-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
handling old/stale account requests #4622
handling old/stale account requests #4622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great -- one very minor request to change the type of db update to !
method so it'll raise an exception as needed.
app/models/account_request.rb
Outdated
# @param reason [String] | ||
def close!(reason) | ||
return false unless can_be_closed? | ||
update(status: 'admin_closed', rejection_reason: reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update(status: 'admin_closed', rejection_reason: reason) | |
update!(status: 'admin_closed', rejection_reason: reason) |
Use an !
method like the others here so that it'll raise an exception if anything goes wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Ah -- I also ran all of the tests and you can see that a browser (system) spec failed, please take a look at that as well. |
f3fffdf
to
b885cea
Compare
06edd02
to
a84ada2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor issue: During functional testing, I noted that the rejection reason has an asterisk on it, which indicates that it's mandatory, but I was able to complete the close without providing the reason.
Can you make the field mandatory, on close, please?
a84ada2
to
18606cd
Compare
@cielf Hi, the Change is done, I made some code changes to make the validation easier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality looks good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some further notes.
# @param reason [String] | ||
def close!(reason) | ||
return false unless can_be_closed? | ||
update!(status: 'admin_closed', rejection_reason: reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - changing this to update!
means that this method will never return false - it'll raise an error if it can't save. That means you need to handle this error and return the message to the user rather than rely on true/false returns from this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed, what do you think?
app/views/admin/account_requests/_open_account_request.html.erb
Outdated
Show resolved
Hide resolved
expect(account_request.reload).to be_admin_closed | ||
expect(flash[:notice]).to eq("Account request closed!") | ||
expect(response).to redirect_to(admin_account_requests_path) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should test where the update errors out (e.g. introduce a validation error). That would have caught the mistake above 😄
@@ -40,6 +40,19 @@ | |||
expect(page).not_to have_content(request4.name) | |||
end | |||
end | |||
|
|||
it 'should close the account', js: true do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine the expectations here with the request specs, so we don't need to do the same actions twice? We can just remove the request specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Couldn't test the validation errors in this spec because the button to "Close" is only displayed on the open requests, therefore I tested the validation on the controller spec (above), also I removed the duplicated tests in that controller to avoid the same action twice
35f548b
to
7ab5c1c
Compare
7ab5c1c
to
87a9697
Compare
Looks good on my end. @cielf it's probably worth it to do one more test for function. |
If I understand correctly, this requested change wasn't actually going to work correctly -- and @dorner has approved the final version.
@manuel1280: Your PR |
Checklist:
Resolves #4514
Description
This new button allows admin users to close old and stale Account requests without sending emails or notifications. this new feature is relevant to clean up data easily. my approach for the solution was:
Type of change
How Has This Been Tested?
running these files