diff --git a/app/models/pageflow/entry_publication.rb b/app/models/pageflow/entry_publication.rb index b863613359..67e2629e4e 100644 --- a/app/models/pageflow/entry_publication.rb +++ b/app/models/pageflow/entry_publication.rb @@ -16,6 +16,8 @@ def exceeding? def save! assumed_quota.verify_not_exceeded! entry.publish(attributes.merge(creator: user)) + + Pageflow.config.hooks.invoke(:entry_published, entry: entry) end private diff --git a/spec/models/pageflow/entry_publication_spec.rb b/spec/models/pageflow/entry_publication_spec.rb index 6f3bdbe00b..4c9388701c 100644 --- a/spec/models/pageflow/entry_publication_spec.rb +++ b/spec/models/pageflow/entry_publication_spec.rb @@ -84,6 +84,19 @@ module Pageflow entry_publication.save! end + + it 'invokes entry_published hooks' do + entry = create(:entry) + user = create(:user, :previewer, on: entry) + quota = QuotaDouble.available.new(:published_entries, entry.account) + entry_publication = EntryPublication.new(entry, {}, quota, user) + subscriber = double('subscriber', call: nil) + + Pageflow.config.hooks.on(:entry_published, subscriber) + entry_publication.save! + + expect(subscriber).to have_received(:call).with(entry: entry) + end end end end