Skip to content

Commit

Permalink
Trigger discourse event after subscriptions update
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Sep 15, 2024
1 parent 931ada1 commit e858272
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ GEM
PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down
2 changes: 2 additions & 0 deletions lib/discourse_subscription_client/subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def update
end
end

DiscourseEvent.trigger(:subscription_client_subscriptions_updated, @result)

@result.errors.blank?
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@

expect(SubscriptionClientSubscription.exists?(product_id: response_body[:subscriptions][0][:product_id])).to eq(false)
end

it "triggers an event" do
stub_subscription_request(200, resource, response_body)
DiscourseEvent
.should_receive(:trigger)
.with(
:subscription_client_subscriptions_updated,
instance_of(DiscourseSubscriptionClient::Subscriptions::UpdateResult)
)
.once
described_class.update
end
end

0 comments on commit e858272

Please sign in to comment.