Skip to content

Instantly share code, notes, and snippets.

@peakpg
Last active December 15, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peakpg/5249564 to your computer and use it in GitHub Desktop.
Save peakpg/5249564 to your computer and use it in GitHub Desktop.
Expectionations for working with Content Blocks
# What would you expect to happen in each of these cases? (Don't test, just what you expect should happen)
# Case A
case_a = Cms::HtmlBlock.new(name: "Case A")
case_a.save
# Is this block in draft or published mode?
# Case B
case_b = Cms::HtmlBlock.new(name: "Case B")
case_b.publish
# - How many versions of case_b.versions return?
# - Is case_b.persisted? == true ?
# Case C
case_c = Cms::HtmlBlock.new(name: "Case C")
case_c.save
case_c.publish
# - How many versions of will case_c.versions return?
# Case D
case_d = Cms::HtmlBlock.create(name: "Case D", publish_on_save: false)
case_d.name = "Case D - Updated"
case_d.publish
# - What is the value of Cms::HtmlBlock.find(case_d).name ?
@jtwohiou
Copy link

Case A

Knowing browsercms I would assume this would leave the block in draft mode, meaning it will create a new version of the block in the versions table but leave the active version set to its prior state to saving.

A few comments on case A

Before I knew browsercms I had a big issue keeping this straight, I think for people not using bcms on a regular basis my knowledge is not a good barometer as to what a user would expect. I would expect it only because of much trial and error reinforcing my expectations. I partly wonder if it might make sense to have the default save also publish, remove publish, and add something like save_as_draft. Just throwing that out there.

Case B

One version.
Yes it is persisted, would assume publish calls save.

Case C

One version.
Huh, now I see the issue. I guess if my case B is correct then C would presumably make two versions.

Case D

Case D - Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment