Skip to content

Commit

Permalink
Merge pull request #806 from tf/publication-hook
Browse files Browse the repository at this point in the history
Call hook on entry publication
  • Loading branch information
tf committed Jul 26, 2017
2 parents 7e98fc2 + 48b309a commit dfc049d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/pageflow/entry_publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/models/pageflow/entry_publication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit dfc049d

Please sign in to comment.