Skip to content

Commit

Permalink
Added Request Spec for PartnerGroup and remove corresponding system-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaryanpal committed Sep 14, 2024
1 parent 81655f3 commit 539b725
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 33 deletions.
27 changes: 27 additions & 0 deletions spec/requests/partner_group_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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
it "destroys the requested partner_group" do
partner_group
expect {
delete partner_group_path(partner_group)
}.to change(PartnerGroup, :count).by(-1)
end

it "redirects to partners path with anchor" do
delete partner_group_path(partner_group)
expect(response).to redirect_to(partners_path + "#nav-partner-groups")
end

it "sets a success notice" do
delete partner_group_path(partner_group)
expect(flash[:notice]).to eq("Partner Group was successfully deleted.")
end
end
end
33 changes: 0 additions & 33 deletions spec/system/partner_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,39 +532,6 @@
assert page.has_content? item_category_2.name
end
end

describe 'deleting an existing partner group' do
context 'when the partner group has partners' do
let!(:first_partner_group) { create(:partner_group, organization: organization) }
let!(:first_partner) { create(:partner, partner_group: first_partner_group) }
it 'should not display the delete link' do
visit partners_path
click_on 'Groups'
expect(page).to have_content('Group 2')
expect(page).to have_content('Leslie Sue, the 1')
expect(page).not_to have_link('Delete')
end
end

context 'when the partner group has no partners' do
before do
PartnerGroup.destroy_all
end
let!(:second_partner_group) { create(:partner_group, organization: organization) }
it 'should display the delete link and allow deletion' do
visit partners_path
click_on 'Groups'
expect(page).to have_content('Group 1')
expect(page).to have_link('Delete')
expect do
accept_confirm do
click_link "Delete"
end
end.to change { PartnerGroup.count }.by(-1)
expect(page).not_to have_content(second_partner_group.name)
end
end
end
end
end
end
Expand Down

0 comments on commit 539b725

Please sign in to comment.