Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MichaScant
Copy link
Contributor

@MichaScant MichaScant commented Jan 6, 2025

Resolves #4739

Builds of the suggested changes from PR: #4763

@@ -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
Copy link
Collaborator

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)
Copy link
Collaborator

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?",
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove product drive delete if any donations for product drive
3 participants