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

Resolves #4739 #4763

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add new tests for Product Drive system spec
  • Loading branch information
jorgecoutinhobr committed Nov 1, 2024
commit 3aec94e073f2892444abc98e09e9a1e2c4678332
30 changes: 30 additions & 0 deletions spec/system/product_drive_system_spec.rb
Original file line number Diff line number Diff line change
@@ -130,4 +130,34 @@
expect(page).to have_content 'Endless drive'
end
end

context "when deleting a Product drive" do
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 these tests to request tests? There's no reason to load a whole browser to test the HTML output by the controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Thanks for the heads-up

let(:new_product_drive) { create(:product_drive, name: 'New Test', start_date: 3.weeks.ago, end_date: 3.weeks.from_now, organization: organization) }
let(:subject) { product_drive_path(new_product_drive.id) }

context "when user is a org_admin" do
before do
user.add_role(:org_admin, organization)
end

it "must delete" do
visit subject
click_on 'Delete'
expect(page).to have_content 'Product drive was successfully destroyed.'
end

it "must not delete if there are donations" do
create(:donation, product_drive: new_product_drive)
visit subject
expect(page).not_to have_button 'Delete'
end
end

context "when user is not a org_admin" do
it "must not delete" do
visit subject
expect(page).not_to have_button 'Delete'
end
end
end
end