Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable publish 1st draft on save, when no changes #721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/cms/behaviors/versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,13 @@ def create_or_update
self.skip_callbacks = false
unless different_from_last_draft?
logger.debug { "No difference between this version and last. Skipping save" }
self.skip_callbacks = true
return true
if !published && publish_on_save
logger.debug { "Publishing current draft version" }
return publish
else
self.skip_callbacks = true
return true
end
end
logger.debug { "Saving #{self.class} #{self.attributes}" }
if new_record?
Expand Down
6 changes: 6 additions & 0 deletions test/unit/behaviors/publishing_mini_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
draft_block.versions.size.must_equal 1
end

it "should publish a draft block, without creating a version, when saving 1st draft version as published" do
draft_block.save.must_equal true
draft_block.must_be_published
draft_block.versions.size.must_equal 1
end

it "should return false if there was no draft copy to publish" do
block.publish.must_equal false
block.must_be_published
Expand Down