-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4634 - Add the Delete button on the Partner Group Page (#4649)
* Add the Delete button on the Partner Group Page * Replace Destroyed with Deleted * Resolve Comments * Added Request Spec for PartnerGroup and remove corresponding system-spec * Fix lint * fix the request-spec
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |