pulitzer 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/app/interactions/pulitzer/create_free_form_section_partials.rb +2 -2
  3. data/app/interactions/pulitzer/post_types_controller/create_singleton_post.rb +1 -1
  4. data/app/interactions/pulitzer/post_types_controller/create_template_version.rb +1 -1
  5. data/app/models/pulitzer/partial.rb +4 -4
  6. data/app/models/pulitzer/partial_type.rb +1 -1
  7. data/app/models/pulitzer/post_type.rb +0 -6
  8. data/app/models/pulitzer/version.rb +2 -2
  9. data/app/views/pulitzer/partial_types/_new.html.erb +2 -2
  10. data/app/views/pulitzer/partial_types/_show.html.erb +1 -1
  11. data/db/migrate/20170515230633_create_post_type_version.rb +2 -2
  12. data/db/migrate/20170515232938_reconnect_post_type_to_post.rb +40 -1
  13. data/lib/pulitzer/version.rb +1 -1
  14. data/spec/controllers/pages_controller_spec.rb +4 -2
  15. data/spec/controllers/pulitzer/arrangement_styles_controller_spec.rb +4 -3
  16. data/spec/controllers/pulitzer/background_styles_controller_spec.rb +4 -3
  17. data/spec/controllers/pulitzer/free_form_section_types_controller_spec.rb +5 -4
  18. data/spec/controllers/pulitzer/justification_styles_controller_spec.rb +4 -3
  19. data/spec/controllers/pulitzer/partials_controller_spec.rb +12 -10
  20. data/spec/controllers/pulitzer/post_type_content_element_types_controller_spec.rb +10 -9
  21. data/spec/controllers/pulitzer/post_types_controller_spec.rb +7 -4
  22. data/spec/controllers/pulitzer/sequence_flow_styles_controller_spec.rb +4 -3
  23. data/spec/controllers/pulitzer/versions_controller_spec.rb +4 -3
  24. data/spec/dummy/app/controllers/pages_controller.rb +2 -1
  25. data/spec/dummy/config/application.rb +3 -0
  26. data/spec/dummy/db/development.sqlite3 +0 -0
  27. data/spec/dummy/db/schema.rb +20 -12
  28. data/spec/dummy/db/seeds/pulitzer_post_types.rb +10 -6
  29. data/spec/dummy/db/test.sqlite3 +0 -0
  30. data/spec/dummy/lib/state_machine/model.rb +23 -0
  31. data/spec/dummy/lib/state_machine/transition.rb +65 -0
  32. data/spec/dummy/log/development.log +275 -0
  33. data/spec/dummy/log/test.log +104454 -0
  34. data/spec/dummy/public/uploads/pulitzer/content_element/image/199/cms_sam_and_snow.jpg +0 -0
  35. data/spec/dummy/public/uploads/pulitzer/content_element/image/199/sam_and_snow.jpg +0 -0
  36. data/spec/dummy/public/uploads/pulitzer/content_element/image/199/thumb_sam_and_snow.jpg +0 -0
  37. data/spec/dummy/public/uploads/pulitzer/content_element/image/221/cms_sam_and_snow.jpg +0 -0
  38. data/spec/dummy/public/uploads/pulitzer/content_element/image/221/sam_and_snow.jpg +0 -0
  39. data/spec/dummy/public/uploads/pulitzer/content_element/image/221/thumb_sam_and_snow.jpg +0 -0
  40. data/spec/dummy/public/uploads/pulitzer/content_element/image/243/cms_sam_and_snow.jpg +0 -0
  41. data/spec/dummy/public/uploads/pulitzer/content_element/image/243/sam_and_snow.jpg +0 -0
  42. data/spec/dummy/public/uploads/pulitzer/content_element/image/243/thumb_sam_and_snow.jpg +0 -0
  43. data/spec/dummy/public/uploads/pulitzer/content_element/image/265/cms_sam_and_snow.jpg +0 -0
  44. data/spec/dummy/public/uploads/pulitzer/content_element/image/265/sam_and_snow.jpg +0 -0
  45. data/spec/dummy/public/uploads/pulitzer/content_element/image/265/thumb_sam_and_snow.jpg +0 -0
  46. data/spec/dummy/public/uploads/pulitzer/content_element/image/287/cms_sam_and_snow.jpg +0 -0
  47. data/spec/dummy/public/uploads/pulitzer/content_element/image/287/sam_and_snow.jpg +0 -0
  48. data/spec/dummy/public/uploads/pulitzer/content_element/image/287/thumb_sam_and_snow.jpg +0 -0
  49. data/spec/dummy/public/uploads/pulitzer/content_element/image/309/cms_sam_and_snow.jpg +0 -0
  50. data/spec/dummy/public/uploads/pulitzer/content_element/image/309/sam_and_snow.jpg +0 -0
  51. data/spec/dummy/public/uploads/pulitzer/content_element/image/309/thumb_sam_and_snow.jpg +0 -0
  52. data/spec/dummy/public/uploads/pulitzer/content_element/image/331/cms_sam_and_snow.jpg +0 -0
  53. data/spec/dummy/public/uploads/pulitzer/content_element/image/331/sam_and_snow.jpg +0 -0
  54. data/spec/dummy/public/uploads/pulitzer/content_element/image/331/thumb_sam_and_snow.jpg +0 -0
  55. data/spec/dummy/public/uploads/pulitzer/content_element/image/353/cms_sam_and_snow.jpg +0 -0
  56. data/spec/dummy/public/uploads/pulitzer/content_element/image/353/sam_and_snow.jpg +0 -0
  57. data/spec/dummy/public/uploads/pulitzer/content_element/image/353/thumb_sam_and_snow.jpg +0 -0
  58. data/spec/dummy/public/uploads/pulitzer/content_element/image/375/cms_sam_and_snow.jpg +0 -0
  59. data/spec/dummy/public/uploads/pulitzer/content_element/image/375/sam_and_snow.jpg +0 -0
  60. data/spec/dummy/public/uploads/pulitzer/content_element/image/375/thumb_sam_and_snow.jpg +0 -0
  61. data/spec/dummy/public/uploads/pulitzer/content_element/image/397/cms_sam_and_snow.jpg +0 -0
  62. data/spec/dummy/public/uploads/pulitzer/content_element/image/397/sam_and_snow.jpg +0 -0
  63. data/spec/dummy/public/uploads/pulitzer/content_element/image/397/thumb_sam_and_snow.jpg +0 -0
  64. data/spec/dummy/public/uploads/pulitzer/content_element/image/419/cms_sam_and_snow.jpg +0 -0
  65. data/spec/dummy/public/uploads/pulitzer/content_element/image/419/sam_and_snow.jpg +0 -0
  66. data/spec/dummy/public/uploads/pulitzer/content_element/image/419/thumb_sam_and_snow.jpg +0 -0
  67. data/spec/dummy/public/uploads/pulitzer/content_element/image/441/cms_sam_and_snow.jpg +0 -0
  68. data/spec/dummy/public/uploads/pulitzer/content_element/image/441/sam_and_snow.jpg +0 -0
  69. data/spec/dummy/public/uploads/pulitzer/content_element/image/441/thumb_sam_and_snow.jpg +0 -0
  70. data/spec/dummy/public/uploads/pulitzer/content_element/image/463/cms_sam_and_snow.jpg +0 -0
  71. data/spec/dummy/public/uploads/pulitzer/content_element/image/463/sam_and_snow.jpg +0 -0
  72. data/spec/dummy/public/uploads/pulitzer/content_element/image/463/thumb_sam_and_snow.jpg +0 -0
  73. data/spec/dummy/public/uploads/pulitzer/content_element/image/485/cms_sam_and_snow.jpg +0 -0
  74. data/spec/dummy/public/uploads/pulitzer/content_element/image/485/sam_and_snow.jpg +0 -0
  75. data/spec/dummy/public/uploads/pulitzer/content_element/image/485/thumb_sam_and_snow.jpg +0 -0
  76. data/spec/dummy/public/uploads/pulitzer/content_element/image/507/cms_sam_and_snow.jpg +0 -0
  77. data/spec/dummy/public/uploads/pulitzer/content_element/image/507/sam_and_snow.jpg +0 -0
  78. data/spec/dummy/public/uploads/pulitzer/content_element/image/507/thumb_sam_and_snow.jpg +0 -0
  79. data/spec/dummy/public/uploads/pulitzer/content_element/image/529/cms_sam_and_snow.jpg +0 -0
  80. data/spec/dummy/public/uploads/pulitzer/content_element/image/529/sam_and_snow.jpg +0 -0
  81. data/spec/dummy/public/uploads/pulitzer/content_element/image/529/thumb_sam_and_snow.jpg +0 -0
  82. data/spec/dummy/public/uploads/pulitzer/content_element/image/551/cms_sam_and_snow.jpg +0 -0
  83. data/spec/dummy/public/uploads/pulitzer/content_element/image/551/sam_and_snow.jpg +0 -0
  84. data/spec/dummy/public/uploads/pulitzer/content_element/image/551/thumb_sam_and_snow.jpg +0 -0
  85. data/spec/dummy/public/uploads/pulitzer/content_element/image/595/cms_sam_and_snow.jpg +0 -0
  86. data/spec/dummy/public/uploads/pulitzer/content_element/image/595/sam_and_snow.jpg +0 -0
  87. data/spec/dummy/public/uploads/pulitzer/content_element/image/595/thumb_sam_and_snow.jpg +0 -0
  88. data/spec/dummy/public/uploads/pulitzer/content_element/image/617/cms_sam_and_snow.jpg +0 -0
  89. data/spec/dummy/public/uploads/pulitzer/content_element/image/617/sam_and_snow.jpg +0 -0
  90. data/spec/dummy/public/uploads/pulitzer/content_element/image/617/thumb_sam_and_snow.jpg +0 -0
  91. data/spec/dummy/public/uploads/pulitzer/content_element/image/639/cms_sam_and_snow.jpg +0 -0
  92. data/spec/dummy/public/uploads/pulitzer/content_element/image/639/sam_and_snow.jpg +0 -0
  93. data/spec/dummy/public/uploads/pulitzer/content_element/image/639/thumb_sam_and_snow.jpg +0 -0
  94. data/spec/dummy/public/uploads/pulitzer/content_element/image/661/cms_sam_and_snow.jpg +0 -0
  95. data/spec/dummy/public/uploads/pulitzer/content_element/image/661/sam_and_snow.jpg +0 -0
  96. data/spec/dummy/public/uploads/pulitzer/content_element/image/661/thumb_sam_and_snow.jpg +0 -0
  97. data/spec/dummy/public/uploads/pulitzer/content_element/image/683/cms_sam_and_snow.jpg +0 -0
  98. data/spec/dummy/public/uploads/pulitzer/content_element/image/683/sam_and_snow.jpg +0 -0
  99. data/spec/dummy/public/uploads/pulitzer/content_element/image/683/thumb_sam_and_snow.jpg +0 -0
  100. data/spec/dummy/public/uploads/pulitzer/content_element/image/705/cms_sam_and_snow.jpg +0 -0
  101. data/spec/dummy/public/uploads/pulitzer/content_element/image/705/sam_and_snow.jpg +0 -0
  102. data/spec/dummy/public/uploads/pulitzer/content_element/image/705/thumb_sam_and_snow.jpg +0 -0
  103. data/spec/dummy/public/uploads/pulitzer/content_element/image/727/cms_sam_and_snow.jpg +0 -0
  104. data/spec/dummy/public/uploads/pulitzer/content_element/image/727/sam_and_snow.jpg +0 -0
  105. data/spec/dummy/public/uploads/pulitzer/content_element/image/727/thumb_sam_and_snow.jpg +0 -0
  106. data/spec/dummy/public/uploads/pulitzer/content_element/image/749/cms_sam_and_snow.jpg +0 -0
  107. data/spec/dummy/public/uploads/pulitzer/content_element/image/749/sam_and_snow.jpg +0 -0
  108. data/spec/dummy/public/uploads/pulitzer/content_element/image/749/thumb_sam_and_snow.jpg +0 -0
  109. data/spec/dummy/public/uploads/pulitzer/content_element/image/771/cms_sam_and_snow.jpg +0 -0
  110. data/spec/dummy/public/uploads/pulitzer/content_element/image/771/sam_and_snow.jpg +0 -0
  111. data/spec/dummy/public/uploads/pulitzer/content_element/image/771/thumb_sam_and_snow.jpg +0 -0
  112. data/spec/dummy/public/uploads/pulitzer/content_element/image/793/cms_sam_and_snow.jpg +0 -0
  113. data/spec/dummy/public/uploads/pulitzer/content_element/image/793/sam_and_snow.jpg +0 -0
  114. data/spec/dummy/public/uploads/pulitzer/content_element/image/793/thumb_sam_and_snow.jpg +0 -0
  115. data/spec/factories/free_form_section_types.rb +1 -1
  116. data/spec/factories/partial_type.rb +1 -1
  117. data/spec/factories/post.rb +1 -1
  118. data/spec/factories/post_type.rb +2 -12
  119. data/spec/factories/post_type_content_element_type.rb +1 -1
  120. data/spec/factories/post_type_version.rb +19 -0
  121. data/spec/interactions/clone_version_spec.rb +2 -1
  122. data/spec/interactions/create_free_form_section_partials_spec.rb +3 -3
  123. data/spec/interactions/create_partial_content_elements_spec.rb +4 -4
  124. data/spec/interactions/create_post_content_elements_spec.rb +4 -4
  125. data/spec/interactions/update_post_type_content_elements_spec.rb +3 -2
  126. data/spec/models/post_spec.rb +1 -1
  127. data/spec/models/post_type_content_element_type_spec.rb +4 -3
  128. data/spec/models/post_type_spec.rb +0 -6
  129. data/spec/models/version_spec.rb +2 -2
  130. metadata +184 -4
  131. data/spec/interactions/destroy_free_form_partials_spec.rb +0 -18
@@ -9,16 +9,19 @@ describe Pulitzer::PostTypesController do
9
9
  post pulitzer.post_types_path post_type: { name: 'Flock of birds', kind: 'template', plural: '1' }
10
10
  expect(response.status).to eq 200
11
11
  expect(response.body).to match /Flock of birds/
12
- expect(Pulitzer::PostType.find_by(name: 'Flock of birds').posts.any?).to be false
12
+ post_type = Pulitzer::PostType.find_by(name: 'Flock of birds')
13
+ post_type_version = post_type.post_type_versions.first
14
+ expect(post_type_version.posts.any?).to be false
13
15
  end
14
16
 
15
17
  it "Creates a single post type with an intial post" do
16
18
  post pulitzer.post_types_path post_type: { name: 'Crow', kind: 'template', plural: '0' }
17
19
  post_type = Pulitzer::PostType.find_by(name: 'Crow')
20
+ post_type_version = post_type.post_type_versions.first
18
21
  expect(response.status).to eq 200
19
- expect(response.body).to match post_type.name
20
- expect(post_type.posts.count).to eq 1
21
- expect(post_type.posts.first.title).to eq post_type.name
22
+ expect(response.body).to match post_type_version.name
23
+ expect(post_type_version.posts.count).to eq 1
24
+ expect(post_type_version.posts.first.title).to eq post_type_version.name
22
25
  end
23
26
  end
24
27
  end
@@ -5,11 +5,12 @@ describe Pulitzer::SequenceFlowStylesController do
5
5
  render_views
6
6
 
7
7
  let(:post_type) { Pulitzer::PostType.create(name: 'partial with various layout styles', kind: Pulitzer::PostType.kinds[:partial], plural: false) }
8
- let(:sequence_flow_style) { post_type.sequence_flow_styles.create(display_name: 'White', css_class_name: 'white') }
8
+ let(:post_type_version) {post_type.post_type_versions.create}
9
+ let(:sequence_flow_style) { post_type_version.sequence_flow_styles.create(display_name: 'White', css_class_name: 'white') }
9
10
 
10
11
  describe "sequence_flow_styles", type: :request do
11
12
  it "renders the new form" do
12
- get pulitzer.new_sequence_flow_style_path(sequence_flow_style: {post_type_id: post_type.id})
13
+ get pulitzer.new_sequence_flow_style_path(sequence_flow_style: {post_type_version_id: post_type_version.id})
13
14
  expect(response.status).to eq 200
14
15
  expect(response.body).to match /sequence_flow_style\[display_name\]/
15
16
  end
@@ -17,7 +18,7 @@ describe Pulitzer::SequenceFlowStylesController do
17
18
  it "creates a new sequence_flow_style" do
18
19
  post pulitzer.sequence_flow_styles_path(
19
20
  sequence_flow_style: {
20
- post_type_id: post_type.id,
21
+ post_type_version_id: post_type_version.id,
21
22
  css_class_name: 'pretty-class',
22
23
  display_name: 'Pretty Class'})
23
24
  expect(response.status).to eq 200
@@ -5,8 +5,9 @@ describe Pulitzer::VersionsController do
5
5
  render_views
6
6
 
7
7
  let(:post_type) { Pulitzer::PostType.named('Welcome') }
8
- let(:content_element_type) { post_type.post_type_content_element_types.first.content_element_type }
9
- let(:ppost) { post_type.posts.first }
8
+ let(:post_type_version) {post_type.published_type_version}
9
+ let(:content_element_type) { post_type_version.post_type_content_element_types.first.content_element_type }
10
+ let(:ppost) { post_type_version.posts.first }
10
11
  let(:version) {ppost.preview_version}
11
12
 
12
13
  describe "updating versions", type: :request do
@@ -43,7 +44,7 @@ describe Pulitzer::VersionsController do
43
44
  end
44
45
 
45
46
  it "responds with errors if the interaction has one" do
46
- ptcet = post_type.post_type_content_element_types.create(label: 'test', required: true, content_element_type: content_element_type)
47
+ ptcet = post_type_version.post_type_content_element_types.create(label: 'test', required: true, content_element_type: content_element_type)
47
48
  version.content_elements.first.update_columns(body: nil, post_type_content_element_type_id: ptcet.id)
48
49
  patch pulitzer.version_path id: version.id, status: 'active'
49
50
  expect(response.status).to eq 409
@@ -10,7 +10,8 @@ class PagesController < ApplicationController
10
10
  #Pulitzer Generated Actions
11
11
 
12
12
  def welcome
13
- @post = Pulitzer::PostType.named('Welcome').posts.find_by!(slug: params[:slug]).get_active_version!
13
+ post_type_version = Pulitzer::PostType.named('Welcome').published_type_version
14
+ @post = post_type_version.posts.find_by!(slug: params[:slug]).get_active_version!
14
15
  end
15
16
 
16
17
  end
@@ -21,6 +21,9 @@ module Dummy
21
21
 
22
22
  # Do not swallow errors in after_commit/after_rollback callbacks.
23
23
  Rails.application.config.assets.precompile += %w( pulitzer/pulitzer.css )
24
+ config.autoload_paths += %W(
25
+ #{Rails.root}/lib
26
+ )
24
27
  end
25
28
  end
26
29
 
Binary file
@@ -13,13 +13,13 @@
13
13
  ActiveRecord::Schema.define(version: 20170602204900) do
14
14
 
15
15
  create_table "pulitzer_arrangement_styles", force: :cascade do |t|
16
- t.integer "post_type_id"
16
+ t.integer "post_type_version_id"
17
17
  t.string "display_name"
18
18
  t.string "view_file_name"
19
19
  end
20
20
 
21
21
  create_table "pulitzer_background_styles", force: :cascade do |t|
22
- t.integer "post_type_id"
22
+ t.integer "post_type_version_id"
23
23
  t.string "display_name"
24
24
  t.string "css_class_name"
25
25
  end
@@ -60,7 +60,7 @@ ActiveRecord::Schema.define(version: 20170602204900) do
60
60
  end
61
61
 
62
62
  create_table "pulitzer_free_form_section_types", force: :cascade do |t|
63
- t.integer "post_type_id"
63
+ t.integer "post_type_version_id"
64
64
  t.string "name"
65
65
  t.integer "sort_order"
66
66
  end
@@ -72,7 +72,7 @@ ActiveRecord::Schema.define(version: 20170602204900) do
72
72
  end
73
73
 
74
74
  create_table "pulitzer_justification_styles", force: :cascade do |t|
75
- t.integer "post_type_id"
75
+ t.integer "post_type_version_id"
76
76
  t.string "display_name"
77
77
  t.string "css_class_name"
78
78
  end
@@ -82,11 +82,11 @@ ActiveRecord::Schema.define(version: 20170602204900) do
82
82
  t.string "label"
83
83
  t.integer "sort_order"
84
84
  t.integer "layout_id"
85
- t.integer "post_type_id"
85
+ t.integer "post_type_version_id"
86
86
  end
87
87
 
88
88
  create_table "pulitzer_partials", force: :cascade do |t|
89
- t.integer "post_type_id"
89
+ t.integer "post_type_version_id"
90
90
  t.integer "free_form_section_id"
91
91
  t.integer "sort_order"
92
92
  t.integer "layout_id"
@@ -111,7 +111,7 @@ ActiveRecord::Schema.define(version: 20170602204900) do
111
111
  end
112
112
 
113
113
  create_table "pulitzer_post_type_content_element_types", force: :cascade do |t|
114
- t.integer "post_type_id"
114
+ t.integer "post_type_version_id"
115
115
  t.integer "content_element_type_id"
116
116
  t.string "label"
117
117
  t.integer "height", default: 100
@@ -124,6 +124,13 @@ ActiveRecord::Schema.define(version: 20170602204900) do
124
124
  t.string "clickable_kind", default: "any", null: false
125
125
  end
126
126
 
127
+ create_table "pulitzer_post_type_versions", force: :cascade do |t|
128
+ t.integer "post_type_id"
129
+ t.integer "version_number", default: 1, null: false
130
+ t.string "status", default: "preview", null: false
131
+ t.index ["post_type_id"], name: "index_pulitzer_post_type_versions_on_post_type_id"
132
+ end
133
+
127
134
  create_table "pulitzer_post_types", force: :cascade do |t|
128
135
  t.string "name"
129
136
  t.datetime "created_at", null: false
@@ -134,16 +141,17 @@ ActiveRecord::Schema.define(version: 20170602204900) do
134
141
 
135
142
  create_table "pulitzer_posts", force: :cascade do |t|
136
143
  t.string "title"
137
- t.integer "post_type_id"
138
- t.string "status", default: "unpublished"
139
- t.datetime "created_at", null: false
140
- t.datetime "updated_at", null: false
144
+ t.string "status", default: "unpublished"
145
+ t.datetime "created_at", null: false
146
+ t.datetime "updated_at", null: false
141
147
  t.string "slug"
148
+ t.integer "post_type_version_id"
149
+ t.index ["post_type_version_id"], name: "index_pulitzer_posts_on_post_type_version_id"
142
150
  t.index ["slug"], name: "index_pulitzer_posts_on_slug", unique: true
143
151
  end
144
152
 
145
153
  create_table "pulitzer_sequence_flow_styles", force: :cascade do |t|
146
- t.integer "post_type_id"
154
+ t.integer "post_type_version_id"
147
155
  t.string "display_name"
148
156
  t.string "css_class_name"
149
157
  end
@@ -2,6 +2,7 @@ module Seeds
2
2
  module PulitzerPostTypes
3
3
  def self.create
4
4
  welcome_post_type = Pulitzer::PostType.create( name: "Welcome", plural: true, kind: :template)
5
+ post_type_version = welcome_post_type.post_type_versions.create(status: :published)
5
6
  content_element_type = Pulitzer::ContentElementType.create(name: 'Text')
6
7
  image_element_type = Pulitzer::ContentElementType.create(name: 'Image')
7
8
  video_element_type = Pulitzer::ContentElementType.create(name: 'Video')
@@ -22,24 +23,27 @@ module Seeds
22
23
  ]
23
24
 
24
25
  content_elements.each do |ce|
25
- welcome_post_type.post_type_content_element_types.create ce
26
+ post_type_version.post_type_content_element_types.create ce
26
27
  end
27
28
 
28
29
  free_forms = [{name: "Main Content"}, {name: "Handpicked Homes"}]
29
- free_forms.each{|ff| welcome_post_type.free_form_section_types.create(ff)}
30
+ free_forms.each{|ff| post_type_version.free_form_section_types.create(ff)}
30
31
 
31
- welcome_post = Pulitzer::Post.create( title: "Welcome", post_type: welcome_post_type )
32
+ welcome_post = Pulitzer::Post.create( title: "Welcome", post_type_version: post_type_version )
32
33
 
33
34
  Pulitzer::CreatePostContentElements.new(welcome_post).call
34
35
 
35
36
  travel_guide_post_type = Pulitzer::PostType.create( name: "Travel Guides", plural: true, kind: :template)
36
- travel_guide = travel_guide_post_type.posts.create( title: 'Complete Guide to Breckenridge')
37
+ tg_version = travel_guide_post_type.post_type_versions.create(status: :published)
38
+ travel_guide = tg_version.posts.create( title: 'Complete Guide to Breckenridge')
37
39
 
38
40
  travel_article_post_type = Pulitzer::PostType.create( name: "Travel Articles", plural: true, kind: :template)
39
- travel_article = travel_article_post_type.posts.create( title: 'Ski Jump Competition')
41
+ ta_version = travel_article_post_type.post_type_versions.create(status: :published)
42
+ travel_article = ta_version.posts.create( title: 'Ski Jump Competition')
40
43
 
41
44
  external_article_post_type = Pulitzer::PostType.create( name: "External Articles", plural: true, kind: :template)
42
- external_article = external_article_post_type.posts.create( title: 'Why visit Breckenridge')
45
+ ea_version = external_article_post_type.post_type_versions.create(status: :published)
46
+ external_article = ea_version.posts.create( title: 'Why visit Breckenridge')
43
47
 
44
48
  #publish the welcome post
45
49
  welcome_post = Pulitzer::Post.find_by title: "Welcome"
Binary file
@@ -0,0 +1,23 @@
1
+ module StateMachine
2
+ module Model
3
+
4
+ def self.included(klass)
5
+ klass.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def register_transitions(service_hash)
11
+ service_hash.each do |service_name, service_class|
12
+ define_method("#{service_name}") {
13
+ service_class.new(self)
14
+ }
15
+ define_method("#{service_class.target_state}?") {
16
+ service_class.target_state.to_s == self.send(service_class.status_field)
17
+ }
18
+ delegate service_class.action_name, to: service_name
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,65 @@
1
+ module StateMachine
2
+ module Transition
3
+ def self.included(klass)
4
+ klass.extend ActiveModel::Naming
5
+ klass.extend ClassMethods
6
+ klass.class_attribute :action_name, :target_state
7
+ end
8
+
9
+ attr_accessor :errors, :object
10
+
11
+ delegate :action_name, :target_state, :valid_from_states, :status_field, to: :class
12
+
13
+ module ClassMethods
14
+ def status_field=(field_name)
15
+ @status_field = field_name
16
+ end
17
+
18
+ def status_field
19
+ return @status_field if @status_field
20
+ return 'status' if self.transitioning_class.column_names.include? 'status'
21
+ return 'state' if self.transitioning_class.column_names.include? 'state'
22
+ end
23
+
24
+ def valid_from_states=(array)
25
+ if array.first.respond_to? :to_sym
26
+ @valid_from_states = array.map(&:to_sym)
27
+ else
28
+ @valid_from_states = array
29
+ end
30
+ end
31
+
32
+ def valid_from_states
33
+ @valid_from_states
34
+ end
35
+
36
+ def transitioning_class
37
+ self.name.deconstantize.constantize
38
+ end
39
+ end
40
+
41
+ def current_state
42
+ current_state = self.object.send status_field
43
+ current_state = current_state.to_sym if current_state.respond_to? :to_sym
44
+ current_state
45
+ end
46
+
47
+ def validate_transition
48
+ if self.valid_from_states.exclude? self.current_state
49
+ self.errors.add(:base, "You can't transition from #{self.current_state} to #{self.target_state}")
50
+ self.object.errors.add(:base, "You can't transition from #{self.current_state} to #{self.target_state}")
51
+ end
52
+ end
53
+
54
+ def validate_transition!
55
+ if self.valid_from_states.exclude? self.current_state
56
+ raise "You can't transition from #{self.current_state} to #{self.target_state} for #{self.object.class.name} #{self.object.id}"
57
+ end
58
+ end
59
+
60
+ def update_status
61
+ self.object.update status_field => self.target_state
62
+ end
63
+
64
+ end
65
+ end
@@ -1218,3 +1218,278 @@ Migrating to AddStyleToContentElement (20170602204900)
1218
1218
  ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1219
1219
   (0.1ms) begin transaction
1220
1220
   (0.1ms) commit transaction
1221
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
1222
+  (0.1ms)  SELECT sql
1223
+ FROM sqlite_master
1224
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1225
+ UNION ALL
1226
+ SELECT sql
1227
+ FROM sqlite_temp_master
1228
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1229
+ 
1230
+  (0.1ms)  SELECT sql
1231
+ FROM sqlite_master
1232
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1233
+ UNION ALL
1234
+ SELECT sql
1235
+ FROM sqlite_temp_master
1236
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1237
+ 
1238
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1239
+ Migrating to CreatePostTypeVersion (20170515230633)
1240
+  (0.1ms) begin transaction
1241
+  (0.6ms) CREATE TABLE "pulitzer_post_type_versions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "pulitzer_post_type_id" integer, "version_number" integer DEFAULT 1 NOT NULL, "status" varchar DEFAULT 'preview' NOT NULL)
1242
+  (0.1ms) select sqlite_version(*)
1243
+  (0.1ms) CREATE INDEX "index_pulitzer_post_type_versions_on_pulitzer_post_type_id" ON "pulitzer_post_type_versions" ("pulitzer_post_type_id")
1244
+ SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170515230633"]]
1245
+  (0.8ms) commit transaction
1246
+ Migrating to ReconnectPostTypeToPost (20170515232938)
1247
+  (0.1ms) begin transaction
1248
+  (0.4ms) ALTER TABLE "pulitzer_posts" ADD "post_type_version_id" integer
1249
+ Pulitzer::PostType Load (0.2ms) SELECT "pulitzer_post_types".* FROM "pulitzer_post_types"
1250
+  (0.4ms) CREATE TEMPORARY TABLE "apulitzer_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "post_type_id" integer, "status" varchar DEFAULT 'unpublished', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "slug" varchar, "post_type_version_id" integer)
1251
+  (0.1ms)  SELECT sql
1252
+ FROM sqlite_master
1253
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1254
+ UNION ALL
1255
+ SELECT sql
1256
+ FROM sqlite_temp_master
1257
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1258
+ 
1259
+  (0.2ms) CREATE UNIQUE INDEX "tindex_apulitzer_posts_on_slug" ON "apulitzer_posts" ("slug")
1260
+  (0.3ms) INSERT INTO "apulitzer_posts" ("id","title","post_type_id","status","created_at","updated_at","slug","post_type_version_id")
1261
+ SELECT "id","title","post_type_id","status","created_at","updated_at","slug","post_type_version_id" FROM "pulitzer_posts"
1262
+  (0.4ms) DROP TABLE "pulitzer_posts"
1263
+  (0.1ms) CREATE TABLE "pulitzer_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "status" varchar DEFAULT 'unpublished', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "slug" varchar, "post_type_version_id" integer)
1264
+  (0.1ms)  SELECT sql
1265
+ FROM sqlite_master
1266
+ WHERE name='tindex_apulitzer_posts_on_slug' AND type='index'
1267
+ UNION ALL
1268
+ SELECT sql
1269
+ FROM sqlite_temp_master
1270
+ WHERE name='tindex_apulitzer_posts_on_slug' AND type='index'
1271
+ 
1272
+  (0.2ms) CREATE UNIQUE INDEX "index_pulitzer_posts_on_slug" ON "pulitzer_posts" ("slug")
1273
+  (0.2ms) INSERT INTO "pulitzer_posts" ("id","title","status","created_at","updated_at","slug","post_type_version_id")
1274
+ SELECT "id","title","status","created_at","updated_at","slug","post_type_version_id" FROM "apulitzer_posts"
1275
+  (0.2ms) DROP TABLE "apulitzer_posts"
1276
+  (0.1ms)  SELECT sql
1277
+ FROM sqlite_master
1278
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1279
+ UNION ALL
1280
+ SELECT sql
1281
+ FROM sqlite_temp_master
1282
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1283
+ 
1284
+  (0.2ms) CREATE INDEX "index_pulitzer_posts_on_post_type_version_id" ON "pulitzer_posts" ("post_type_version_id")
1285
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20170515232938"]]
1286
+  (0.9ms) commit transaction
1287
+ ActiveRecord::InternalMetadata Load (0.6ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1288
+  (0.4ms) begin transaction
1289
+  (0.2ms) commit transaction
1290
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1291
+  (0.1ms)  SELECT sql
1292
+ FROM sqlite_master
1293
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1294
+ UNION ALL
1295
+ SELECT sql
1296
+ FROM sqlite_temp_master
1297
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1298
+ 
1299
+  (0.1ms)  SELECT sql
1300
+ FROM sqlite_master
1301
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1302
+ UNION ALL
1303
+ SELECT sql
1304
+ FROM sqlite_temp_master
1305
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1306
+ 
1307
+  (0.2ms)  SELECT sql
1308
+ FROM sqlite_master
1309
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1310
+ UNION ALL
1311
+ SELECT sql
1312
+ FROM sqlite_temp_master
1313
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1314
+ 
1315
+  (0.1ms)  SELECT sql
1316
+ FROM sqlite_master
1317
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1318
+ UNION ALL
1319
+ SELECT sql
1320
+ FROM sqlite_temp_master
1321
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1322
+ 
1323
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1324
+  (0.1ms)  SELECT sql
1325
+ FROM sqlite_master
1326
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1327
+ UNION ALL
1328
+ SELECT sql
1329
+ FROM sqlite_temp_master
1330
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1331
+ 
1332
+  (0.1ms)  SELECT sql
1333
+ FROM sqlite_master
1334
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1335
+ UNION ALL
1336
+ SELECT sql
1337
+ FROM sqlite_temp_master
1338
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1339
+ 
1340
+  (0.2ms)  SELECT sql
1341
+ FROM sqlite_master
1342
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1343
+ UNION ALL
1344
+ SELECT sql
1345
+ FROM sqlite_temp_master
1346
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1347
+ 
1348
+  (0.1ms)  SELECT sql
1349
+ FROM sqlite_master
1350
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1351
+ UNION ALL
1352
+ SELECT sql
1353
+ FROM sqlite_temp_master
1354
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1355
+ 
1356
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1357
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1358
+  (0.1ms)  SELECT sql
1359
+ FROM sqlite_master
1360
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1361
+ UNION ALL
1362
+ SELECT sql
1363
+ FROM sqlite_temp_master
1364
+ WHERE name='index_pulitzer_post_type_versions_on_pulitzer_post_type_id' AND type='index'
1365
+ 
1366
+  (0.1ms)  SELECT sql
1367
+ FROM sqlite_master
1368
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1369
+ UNION ALL
1370
+ SELECT sql
1371
+ FROM sqlite_temp_master
1372
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1373
+ 
1374
+  (0.1ms)  SELECT sql
1375
+ FROM sqlite_master
1376
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1377
+ UNION ALL
1378
+ SELECT sql
1379
+ FROM sqlite_temp_master
1380
+ WHERE name='index_pulitzer_posts_on_slug' AND type='index'
1381
+ 
1382
+  (0.1ms)  SELECT sql
1383
+ FROM sqlite_master
1384
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1385
+ UNION ALL
1386
+ SELECT sql
1387
+ FROM sqlite_temp_master
1388
+ WHERE name='index_pulitzer_tags_on_hierarchical' AND type='index'
1389
+ 
1390
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1391
+  (0.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", :environment]]
1392
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1393
+  (0.0ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", :environment]]
1394
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
1395
+  (0.0ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? [["key", :environment]]
1396
+  (1.1ms) CREATE TABLE "pulitzer_arrangement_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "view_file_name" varchar)
1397
+  (1.0ms) CREATE TABLE "pulitzer_background_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1398
+  (0.9ms) CREATE TABLE "pulitzer_content_element_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1399
+  (1.1ms) CREATE TABLE "pulitzer_content_elements" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "label" varchar, "title" varchar, "body" text, "image" varchar, "version_id" integer, "post_type_content_element_type_id" integer, "content_element_type_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "text_editor" varchar, "height" integer DEFAULT 100, "width" integer DEFAULT 100, "sort_order" integer, "partial_id" integer, "style_id" integer, "custom_option_id" integer)
1400
+  (1.2ms) CREATE TABLE "pulitzer_custom_option_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar)
1401
+  (1.1ms) CREATE TABLE "pulitzer_custom_options" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "custom_option_list_id" integer, "display" varchar, "value" varchar)
1402
+  (0.9ms) CREATE TABLE "pulitzer_free_form_section_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "name" varchar, "sort_order" integer)
1403
+  (0.9ms) CREATE TABLE "pulitzer_free_form_sections" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "version_id" integer, "free_form_section_type_id" integer, "name" varchar)
1404
+  (0.9ms) CREATE TABLE "pulitzer_justification_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1405
+  (1.0ms) CREATE TABLE "pulitzer_partial_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "free_form_section_type_id" integer, "label" varchar, "sort_order" integer, "layout_id" integer, "post_type_id" integer)
1406
+  (1.0ms) CREATE TABLE "pulitzer_partials" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "free_form_section_id" integer, "sort_order" integer, "layout_id" integer, "label" varchar, "background_style_id" integer, "justification_style_id" integer, "sequence_flow_style_id" integer, "arrangement_style_id" integer)
1407
+  (1.1ms) CREATE TABLE "pulitzer_post_tags" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "version_id" integer, "label_id" integer, "label_type" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1408
+  (1.0ms) CREATE TABLE "pulitzer_post_type_content_element_type_custom_option_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_content_element_type_id" integer, "custom_option_list_id" integer)
1409
+  (1.1ms) CREATE TABLE "pulitzer_post_type_content_element_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "content_element_type_id" integer, "label" varchar, "height" integer DEFAULT 100, "width" integer DEFAULT 100, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "text_editor" varchar, "required" boolean DEFAULT 'f', "sort_order" integer, "clickable_kind" varchar DEFAULT 'any' NOT NULL)
1410
+  (0.9ms) CREATE TABLE "pulitzer_post_type_versions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "version_number" integer DEFAULT 1 NOT NULL, "status" varchar DEFAULT 'preview' NOT NULL)
1411
+  (0.1ms) select sqlite_version(*)
1412
+  (1.0ms) CREATE INDEX "index_pulitzer_post_type_versions_on_post_type_id" ON "pulitzer_post_type_versions" ("post_type_id")
1413
+  (1.0ms) CREATE TABLE "pulitzer_post_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "plural" boolean, "kind" integer DEFAULT 0)
1414
+  (1.7ms) CREATE TABLE "pulitzer_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "status" varchar DEFAULT 'unpublished', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "slug" varchar, "post_type_version_id" integer)
1415
+  (1.2ms) CREATE INDEX "index_pulitzer_posts_on_post_type_version_id" ON "pulitzer_posts" ("post_type_version_id")
1416
+  (0.1ms)  SELECT sql
1417
+ FROM sqlite_master
1418
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1419
+ UNION ALL
1420
+ SELECT sql
1421
+ FROM sqlite_temp_master
1422
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1423
+ 
1424
+  (1.1ms) CREATE UNIQUE INDEX "index_pulitzer_posts_on_slug" ON "pulitzer_posts" ("slug")
1425
+  (1.1ms) CREATE TABLE "pulitzer_sequence_flow_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1426
+  (1.0ms) CREATE TABLE "pulitzer_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_content_element_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1427
+  (2.7ms) CREATE TABLE "pulitzer_tags" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "parent_id" integer, "hierarchical" boolean DEFAULT 'f' NOT NULL)
1428
+  (1.9ms) CREATE INDEX "index_pulitzer_tags_on_hierarchical" ON "pulitzer_tags" ("hierarchical")
1429
+  (2.1ms) CREATE TABLE "pulitzer_versions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "status" integer DEFAULT 0, "post_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "cloning_errors" text)
1430
+  (2.4ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
1431
+  (0.2ms) SELECT version FROM "schema_migrations"
1432
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20170602204900')
1433
+  (0.9ms) INSERT INTO schema_migrations (version) VALUES
1434
+ ('20170515230633'),
1435
+ ('20170515232938');
1436
+
1437
+ 
1438
+  (1.0ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1439
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1440
+  (0.1ms) begin transaction
1441
+ SQL (0.5ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", 2017-06-07 00:28:00 UTC], ["updated_at", 2017-06-07 00:28:00 UTC]]
1442
+  (0.8ms) commit transaction
1443
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1444
+  (0.1ms) begin transaction
1445
+  (0.1ms) commit transaction
1446
+  (1.0ms) CREATE TABLE "pulitzer_arrangement_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "view_file_name" varchar)
1447
+  (1.1ms) CREATE TABLE "pulitzer_background_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1448
+  (1.0ms) CREATE TABLE "pulitzer_content_element_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1449
+  (1.0ms) CREATE TABLE "pulitzer_content_elements" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "label" varchar, "title" varchar, "body" text, "image" varchar, "version_id" integer, "post_type_content_element_type_id" integer, "content_element_type_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "text_editor" varchar, "height" integer DEFAULT 100, "width" integer DEFAULT 100, "sort_order" integer, "partial_id" integer, "style_id" integer, "custom_option_id" integer)
1450
+  (2.1ms) CREATE TABLE "pulitzer_custom_option_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar)
1451
+  (1.8ms) CREATE TABLE "pulitzer_custom_options" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "custom_option_list_id" integer, "display" varchar, "value" varchar)
1452
+  (2.0ms) CREATE TABLE "pulitzer_free_form_section_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "name" varchar, "sort_order" integer)
1453
+  (1.0ms) CREATE TABLE "pulitzer_free_form_sections" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "version_id" integer, "free_form_section_type_id" integer, "name" varchar)
1454
+  (0.9ms) CREATE TABLE "pulitzer_justification_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1455
+  (1.0ms) CREATE TABLE "pulitzer_partial_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "free_form_section_type_id" integer, "label" varchar, "sort_order" integer, "layout_id" integer, "post_type_id" integer)
1456
+  (1.0ms) CREATE TABLE "pulitzer_partials" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "free_form_section_id" integer, "sort_order" integer, "layout_id" integer, "label" varchar, "background_style_id" integer, "justification_style_id" integer, "sequence_flow_style_id" integer, "arrangement_style_id" integer)
1457
+  (1.0ms) CREATE TABLE "pulitzer_post_tags" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "version_id" integer, "label_id" integer, "label_type" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1458
+  (1.0ms) CREATE TABLE "pulitzer_post_type_content_element_type_custom_option_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_content_element_type_id" integer, "custom_option_list_id" integer)
1459
+  (1.0ms) CREATE TABLE "pulitzer_post_type_content_element_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "content_element_type_id" integer, "label" varchar, "height" integer DEFAULT 100, "width" integer DEFAULT 100, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "text_editor" varchar, "required" boolean DEFAULT 'f', "sort_order" integer, "clickable_kind" varchar DEFAULT 'any' NOT NULL)
1460
+  (1.1ms) CREATE TABLE "pulitzer_post_type_versions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "version_number" integer DEFAULT 1 NOT NULL, "status" varchar DEFAULT 'preview' NOT NULL)
1461
+  (0.1ms) select sqlite_version(*)
1462
+  (1.1ms) CREATE INDEX "index_pulitzer_post_type_versions_on_post_type_id" ON "pulitzer_post_type_versions" ("post_type_id")
1463
+  (1.1ms) CREATE TABLE "pulitzer_post_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "plural" boolean, "kind" integer DEFAULT 0)
1464
+  (0.9ms) CREATE TABLE "pulitzer_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "status" varchar DEFAULT 'unpublished', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "slug" varchar, "post_type_version_id" integer)
1465
+  (0.9ms) CREATE INDEX "index_pulitzer_posts_on_post_type_version_id" ON "pulitzer_posts" ("post_type_version_id")
1466
+  (0.1ms)  SELECT sql
1467
+ FROM sqlite_master
1468
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1469
+ UNION ALL
1470
+ SELECT sql
1471
+ FROM sqlite_temp_master
1472
+ WHERE name='index_pulitzer_posts_on_post_type_version_id' AND type='index'
1473
+ 
1474
+  (1.1ms) CREATE UNIQUE INDEX "index_pulitzer_posts_on_slug" ON "pulitzer_posts" ("slug")
1475
+  (2.6ms) CREATE TABLE "pulitzer_sequence_flow_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1476
+  (1.1ms) CREATE TABLE "pulitzer_styles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "post_type_content_element_type_id" integer, "display_name" varchar, "css_class_name" varchar)
1477
+  (1.0ms) CREATE TABLE "pulitzer_tags" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "parent_id" integer, "hierarchical" boolean DEFAULT 'f' NOT NULL)
1478
+  (0.9ms) CREATE INDEX "index_pulitzer_tags_on_hierarchical" ON "pulitzer_tags" ("hierarchical")
1479
+  (1.0ms) CREATE TABLE "pulitzer_versions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "status" integer DEFAULT 0, "post_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "cloning_errors" text)
1480
+  (1.0ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
1481
+  (0.1ms) SELECT version FROM "schema_migrations"
1482
+  (2.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20170602204900')
1483
+  (1.0ms) INSERT INTO schema_migrations (version) VALUES
1484
+ ('20170515230633'),
1485
+ ('20170515232938');
1486
+
1487
+ 
1488
+  (1.8ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1489
+ ActiveRecord::InternalMetadata Load (0.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1490
+  (0.2ms) begin transaction
1491
+ SQL (1.0ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "development"], ["created_at", 2017-06-07 00:28:00 UTC], ["updated_at", 2017-06-07 00:28:00 UTC]]
1492
+  (1.4ms) commit transaction
1493
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", :environment], ["LIMIT", 1]]
1494
+  (0.0ms) begin transaction
1495
+  (0.0ms) commit transaction