-
-
Notifications
You must be signed in to change notification settings - Fork 538
4634 - Add the Delete button on the Partner Group Page #4649
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
Merged
dorner
merged 6 commits into
rubyforgood:main
from
Aaryanpal:4634_add_ability_to_remove_partner_group
Sep 20, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74c74dc
Add the Delete button on the Partner Group Page
Aaryanpal ffac7ad
Replace Destroyed with Deleted
Aaryanpal cb8fa3a
Resolve Comments
Aaryanpal d858a40
Added Request Spec for PartnerGroup and remove corresponding system-spec
Aaryanpal 2880826
Fix lint
Aaryanpal 2e6f4a3
fix the request-spec
Aaryanpal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
RSpec.describe "PartnerGroups", type: :request do | ||
let(:user) { create(:user) } | ||
let(:partner_group) { create(:partner_group) } | ||
|
||
before do | ||
sign_in(user) | ||
end | ||
|
||
describe "DELETE #destroy" do | ||
context "when partner group has no partners" do | ||
let!(:partner_group) { create(:partner_group) } | ||
before { get partners_path + "#nav-partner-groups" } | ||
it "destroys the partner group" do | ||
within "#nav-partner-groups" do | ||
expect(response.body).to have_link("Delete") | ||
end | ||
expect { | ||
delete partner_group_path(partner_group) | ||
}.to change(PartnerGroup, :count).by(-1) | ||
|
||
expect(flash[:notice]).to eq("Partner Group was successfully deleted.") | ||
expect(response).to redirect_to(partners_path + "#nav-partner-groups") | ||
end | ||
end | ||
|
||
context "when partner group has partners" do | ||
let!(:partner_group) { create(:partner_group) } | ||
|
||
before do | ||
create(:partner, partner_group: partner_group) | ||
get partners_path + "#nav-partner-groups" | ||
end | ||
it "does not destroy the partner group" do | ||
within "#nav-partner-groups" do | ||
expect(reponse.body).not_to have_link("Delete") | ||
end | ||
expect { | ||
delete partner_group_path(partner_group) | ||
}.not_to change(PartnerGroup, :count) | ||
|
||
expect(flash[:alert]).to eq("Partner Group cannot be deleted.") | ||
expect(response).to redirect_to(partners_path + "#nav-partner-groups") | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There should be a spec that checks that the delete button is only shown if there are no partners. This can still be a request spec since you can check the response HTML.
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.
Also - please don't force push your branch once a review has started - it becomes harder to see what has changed since the last review.
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.
Hii @dorner,
I've updated the spec based on your suggestion. I had to force-push the changes since I couldn't see my updates in the branch. Please ignore this for now. I'll work on improving it in future PRs