Browse Source

Add `change` block expectation to `admin/invites#deactivate_all` spec (#29412)

Matt Jankowski 2 months ago
parent
commit
8f3c91fc3c
1 changed files with 6 additions and 7 deletions
  1. 6 7
      spec/controllers/admin/invites_controller_spec.rb

+ 6 - 7
spec/controllers/admin/invites_controller_spec.rb

@@ -44,14 +44,13 @@ describe Admin::InvitesController do
   end
 
   describe 'POST #deactivate_all' do
-    it 'expires all invites, then redirects to admin_invites_path' do
-      invites = Fabricate.times(1, :invite, expires_at: nil)
-
-      post :deactivate_all
+    before { Fabricate(:invite, expires_at: nil) }
 
-      invites.each do |invite|
-        expect(invite.reload).to be_expired
-      end
+    it 'expires all invites, then redirects to admin_invites_path' do
+      expect { post :deactivate_all }
+        .to change { Invite.exists?(expires_at: nil) }
+        .from(true)
+        .to(false)
 
       expect(response).to redirect_to admin_invites_path
     end