-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
#4739: Fix product drive delete (updated) #4918
base: main
Are you sure you want to change the base?
Conversation
…into 4739-fix-product-drive-delete
…into 4739-fix-product-drive-delete
@@ -69,6 +71,10 @@ def self.search_date_range(dates) | |||
@search_date_range = { start_date: dates[0], end_date: dates[1] } | |||
end | |||
|
|||
def destroy_product_drive |
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.
Not sure this method is really worth defining when it's a one-liner.
@@ -0,0 +1,23 @@ | |||
class ProductDriveDestroyService | |||
def initialize(product_drive) |
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 change call
to a class method? It's easier to work with in terms of stubbing tests.
@@ -90,7 +90,10 @@ | |||
</p> | |||
<div class="card-footer clearfix"> | |||
<%= edit_button_to edit_product_drive_path(@product_drive), { text: "Make a correction", size: "md" } %> | |||
<%= delete_button_to product_drive_path(@product_drive), { confirm: "Are you sure you want to permanently remove this product drive?", size: "md" } if current_user.has_role?(Role::ORG_ADMIN, current_organization) %> | |||
confirm: "Are you sure you want to permanently remove this product drive?", |
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 think this was a mistake?
expect(response.body).to include('Product drive was successfully destroyed.') | ||
end | ||
|
||
it "does not delete the product drive if it has donations" 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.
This test probably should be moved to the destroy service.
@@ -85,6 +94,13 @@ def destroy | |||
|
|||
private | |||
|
|||
def verify_role |
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 move this verification to the destroy service? You can pass the user into it.
Resolves #4739
Builds of the suggested changes from PR: #4763