Skip to content

Commit ca5a29d

Browse files
authored
DEV: adds method to destroy all expired invites (#232)
1 parent 3068694 commit ca5a29d

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

examples/invite_users.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222

2323
# retrieve invite
2424
puts client.retrieve_invite(email: "foo@bar.com")
25+
26+
# destroy all expired invites
27+
client.destroy_all_expired_invites

lib/discourse_api/api/invite.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def update_invite(invite_id, params = {})
6363

6464
put("invites/#{invite_id}", args)
6565
end
66+
67+
def destroy_all_expired_invites
68+
post("invites/destroy-all-expired")
69+
end
6670
end
6771
end
6872
end

spec/discourse_api/api/invite_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,21 @@
5353
expect(invites).to have_key("invite_key")
5454
end
5555
end
56+
57+
describe "#destroy_all_expired_invites" do
58+
let(:url) { "#{host}/invites/destroy-all-expired" }
59+
60+
before do
61+
stub_post(url)
62+
.to_return(
63+
body: '{"success": "OK"}',
64+
headers: { content_type: "application/json" }
65+
)
66+
end
67+
68+
it "destroys all expired invites" do
69+
subject.destroy_all_expired_invites
70+
expect(a_post(url)).to have_been_made
71+
end
72+
end
5673
end

0 commit comments

Comments
 (0)