pulitzer 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/pulitzer/versions_controller.rb +8 -2
- data/app/interactions/pulitzer/update_version_status.rb +23 -16
- data/lib/pulitzer/version.rb +1 -1
- data/spec/controllers/pulitzer/versions_controller_spec.rb +39 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20150618224344_create_pulitzer_post_types.rb +9 -0
- data/spec/dummy/db/migrate/20150618225402_create_pulitzer_content_element_types.rb +9 -0
- data/spec/dummy/db/migrate/20150619204615_create_pulitzer_posts.rb +11 -0
- data/spec/dummy/db/migrate/20150619204708_create_pulitzer_content_elements.rb +15 -0
- data/spec/dummy/db/migrate/20150619213436_create_pulitzer_tags.rb +9 -0
- data/spec/dummy/db/migrate/20150619213457_create_pulitzer_post_tags.rb +11 -0
- data/spec/dummy/db/migrate/20150619215914_create_pulitzer_post_type_content_element_types.rb +13 -0
- data/spec/dummy/db/migrate/20150629195832_add_plural_and_template_to_pulitzer_post_types.rb +6 -0
- data/spec/dummy/db/migrate/20150702150819_add_pulitzer_content_element_types.rb +13 -0
- data/spec/dummy/db/migrate/20150724150230_add_slug_to_pulitzer_posts.rb +6 -0
- data/spec/dummy/db/migrate/20150902212741_change_label_type_from_pulitzer_post_tags.rb +5 -0
- data/spec/dummy/db/migrate/20151026180630_add_text_editor_to_pulitzer_post_type_content_element_types.rb +10 -0
- data/spec/dummy/db/migrate/20151029194354_create_pulitzer_versions.rb +10 -0
- data/spec/dummy/db/migrate/20151029220558_change_post_elements_to_versions.rb +20 -0
- data/spec/dummy/db/migrate/20151113183344_add_post_type_content_element_attributes_to_content_elements.rb +21 -0
- data/spec/dummy/db/migrate/20151116162508_change_template_to_pulitzer_post_types.rb +11 -0
- data/spec/dummy/db/migrate/20151118031237_add_kind_to_pulitzer_content_elements.rb +5 -0
- data/spec/dummy/db/migrate/20160122204201_add_errors_to_version.rb +5 -0
- data/spec/dummy/db/migrate/20160511192041_create_partials.rb +9 -0
- data/spec/dummy/db/migrate/20160511201527_add_parent_id_to_pulitzer_tag.rb +7 -0
- data/spec/dummy/db/migrate/20160512214545_add_partial_to_content_element.rb +5 -0
- data/spec/dummy/db/migrate/20160513153209_create_free_form_section_type.rb +8 -0
- data/spec/dummy/db/migrate/20160513153214_create_free_form_section.rb +9 -0
- data/spec/dummy/db/migrate/20160516150237_fix_post_type_kinds.rb +7 -0
- data/spec/dummy/db/migrate/20160517181706_create_layouts.rb +8 -0
- data/spec/dummy/db/migrate/20160517182500_add_layout_to_partial.rb +5 -0
- data/spec/dummy/db/migrate/20160519181030_add_label_to_partial.rb +5 -0
- data/spec/dummy/db/migrate/20160609214139_remove_title_from_content_elements.rb +5 -0
- data/spec/dummy/db/migrate/20160927160910_add_required_to_pulitzer_post_type_content_element_type.rb +5 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +103 -0
- data/spec/dummy/log/test.log +7132 -0
- data/spec/dummy/public/uploads/tmp/1481137841-25126-0001-1732/cms_sam_and_snow.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1481137841-25126-0001-1732/sam_and_snow.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1481137841-25126-0001-1732/thumb_sam_and_snow.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1481139929-27725-0001-9237/cms_sam_and_snow.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1481139929-27725-0001-9237/sam_and_snow.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1481139929-27725-0001-9237/thumb_sam_and_snow.jpg +0 -0
- data/spec/spec_helper.rb +2 -0
- metadata +94 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f63ebe9b07ab0474e255a16a33374d0eb001506
|
4
|
+
data.tar.gz: 3f9f50630a0bceae4deb42bee8b7069f282a59c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6560fc2250800a2921293211d5244da76769920d975cd66804882083f080668604f6ca99b693020a1fbebb5b6eeb6b38927ba27cfb9df098cc1a2111541771
|
7
|
+
data.tar.gz: bd0215be4171c56bd682a95e43481b7ef67c160ba12bea05d7b4d2f3afd26a32c0b9d7eca222f49a6f7589f3b79044e78980d6bacf0d20ff4c426ac539176f95
|
@@ -14,12 +14,18 @@ class Pulitzer::VersionsController < Pulitzer::ApplicationController
|
|
14
14
|
if status_updater.errors.any?
|
15
15
|
processing_version = @version
|
16
16
|
flash_message = processing_version.errors.first
|
17
|
+
status = :conflict
|
17
18
|
else
|
18
19
|
processing_version = status_updater.call
|
19
|
-
|
20
|
+
if processing_version.errors.empty?
|
21
|
+
status = :ok
|
22
|
+
flash_message = "The new version of #{@post.title} has been activated."
|
23
|
+
else
|
24
|
+
status = :conflict
|
25
|
+
end
|
20
26
|
end
|
21
27
|
render json: {html: render_to_string(partial: '/pulitzer/versions/edit', locals: {version: processing_version}),
|
22
|
-
flash_message: flash_message}
|
28
|
+
flash_message: flash_message}, status: status
|
23
29
|
end
|
24
30
|
|
25
31
|
private
|
@@ -23,16 +23,17 @@ class Pulitzer::UpdateVersionStatus
|
|
23
23
|
def make_version_active
|
24
24
|
@new_active_version = @transitional_version
|
25
25
|
@old_active_version = @new_active_version.post.active_version
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
@new_active_version.update(status: :active)
|
27
|
+
if @new_active_version.errors.any?
|
28
|
+
@new_active_version.update(status: :processing_failed, cloning_errors: @new_active_version.errors.full_messages)
|
29
|
+
@processing_version = @new_active_version
|
30
|
+
else
|
31
|
+
@new_active_version.tags.each &:touch
|
32
|
+
@old_active_version.update(status: :archived) if @old_active_version
|
33
|
+
@processing_version = @post.create_processing_version
|
34
|
+
Pulitzer::CloneVersionJob.perform_later(@new_active_version)
|
35
|
+
instance_eval(&Pulitzer.publish_callback) unless Pulitzer.skip_publish_callback?
|
30
36
|
end
|
31
|
-
@new_active_version.tags.each &:touch
|
32
|
-
@old_active_version.update(status: :archived) if @old_active_version
|
33
|
-
@processing_version = @post.create_processing_version
|
34
|
-
Pulitzer::CloneVersionJob.perform_later(@new_active_version)
|
35
|
-
instance_eval(&Pulitzer.publish_callback) unless Pulitzer.skip_publish_callback?
|
36
37
|
@post.reload
|
37
38
|
@processing_version.reload
|
38
39
|
end
|
@@ -40,14 +41,20 @@ class Pulitzer::UpdateVersionStatus
|
|
40
41
|
def make_version_abandoned
|
41
42
|
@active_version = @transitional_version.post.active_version
|
42
43
|
@transitional_version.update(status: :abandoned)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
@transitional_version.tags.each &:touch
|
45
|
+
if @active_version.is_a? Pulitzer::Version
|
46
|
+
if @active_version == @transitional_version
|
47
|
+
@processing_version = @transitional_version.post.preview_version
|
48
|
+
instance_eval(&Pulitzer.publish_callback) unless Pulitzer.skip_publish_callback?
|
49
|
+
else
|
50
|
+
@processing_version = @post.create_processing_version
|
51
|
+
Pulitzer::CloneVersionJob.perform_later(@active_version)
|
52
|
+
@processing_version
|
53
|
+
end
|
54
|
+
else # There is no active version, we never published this one
|
55
|
+
@processing_version = @transitional_version
|
50
56
|
end
|
57
|
+
@transitional_version
|
51
58
|
end
|
52
59
|
|
53
60
|
end
|
data/lib/pulitzer/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Pulitzer::VersionsController do
|
4
|
+
routes { Pulitzer::Engine.routes }
|
5
|
+
render_views
|
6
|
+
|
7
|
+
let(:version) {create(:version, :with_content_elements)}
|
8
|
+
|
9
|
+
describe "updating versions" do
|
10
|
+
it "abandons a post that was never published" do
|
11
|
+
patch :update, id: version.id, status: 'abandoned'
|
12
|
+
expect(response.status).to eq 200
|
13
|
+
expect(version.reload.status).to eq 'abandoned'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "abandons a post that was published" do
|
17
|
+
Pulitzer::UpdateVersionStatus.new(version, 'active').call
|
18
|
+
expect(version.status).to eq 'active'
|
19
|
+
expect(version.post.active_version).not_to be_nil
|
20
|
+
patch :update, id: version.id, status: 'abandoned'
|
21
|
+
expect(response.status).to eq 200
|
22
|
+
expect(version.reload.status).to eq 'abandoned'
|
23
|
+
expect(version.post.active_version).to be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "abandons changes" do
|
27
|
+
Pulitzer::UpdateVersionStatus.new(version, 'active').call
|
28
|
+
active_version = version
|
29
|
+
expect(active_version.status).to eq 'active'
|
30
|
+
old_preview = version.post.preview_version
|
31
|
+
patch :update, id: old_preview.id, status: 'abandoned'
|
32
|
+
expect(response.status).to eq 200
|
33
|
+
expect(active_version.reload.status).to eq 'active'
|
34
|
+
expect(old_preview.reload.status).to eq 'abandoned'
|
35
|
+
expect(active_version.post.preview_version.status).to eq 'preview'
|
36
|
+
expect(version.post.preview_version.id).not_to eq old_preview.id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreatePulitzerContentElements < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :pulitzer_content_elements do |t|
|
4
|
+
t.string :label
|
5
|
+
t.string :title
|
6
|
+
t.text :body
|
7
|
+
t.string :image
|
8
|
+
t.integer :post_id
|
9
|
+
t.integer :post_type_content_element_type_id
|
10
|
+
t.integer :content_element_type_id
|
11
|
+
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreatePulitzerPostTypeContentElementTypes < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :pulitzer_post_type_content_element_types do |t|
|
4
|
+
t.integer :post_type_id
|
5
|
+
t.integer :content_element_type_id
|
6
|
+
t.string :label
|
7
|
+
t.integer :height, default: 100
|
8
|
+
t.integer :width, default: 100
|
9
|
+
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddPulitzerContentElementTypes < ActiveRecord::Migration
|
2
|
+
ELEMENT_TYPES = %w(Text Image Video)
|
3
|
+
|
4
|
+
def up
|
5
|
+
ELEMENT_TYPES.each do |type|
|
6
|
+
Pulitzer::ContentElementType.create(name: type)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
Pulitzer::ContentElementType.where(name: ELEMENT_TYPES).destroy_all
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddTextEditorToPulitzerPostTypeContentElementTypes < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :pulitzer_post_type_content_element_types, :text_editor, :string
|
4
|
+
Pulitzer::PostTypeContentElementType.update_all(text_editor: 'None')
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :pulitzer_post_type_content_element_types, :text_editor
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ChangePostElementsToVersions < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
rename_column :pulitzer_content_elements, :post_id, :version_id
|
4
|
+
rename_column :pulitzer_post_tags, :post_id, :version_id
|
5
|
+
Pulitzer::ContentElement.reset_column_information
|
6
|
+
Pulitzer::PostTag.reset_column_information
|
7
|
+
|
8
|
+
# Clone post content elements and clone tags, and assign them to the new version
|
9
|
+
Pulitzer::Post.find_each do |post|
|
10
|
+
version = post.create_preview_version
|
11
|
+
Pulitzer::ContentElement.where(version_id: post.id).update_all(version_id: version.id)
|
12
|
+
Pulitzer::PostTag.where(version_id: post.id).update_all(version_id: version.id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
rename_column :pulitzer_content_elements, :version_id, :post_id
|
18
|
+
rename_column :pulitzer_post_tags, :version_id, :post_id
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AddPostTypeContentElementAttributesToContentElements < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :pulitzer_content_elements, :text_editor, :string
|
4
|
+
add_column :pulitzer_content_elements, :height, :integer, default: 100
|
5
|
+
add_column :pulitzer_content_elements, :width, :integer, default: 100
|
6
|
+
add_column :pulitzer_content_elements, :sort_order, :integer
|
7
|
+
Pulitzer::ContentElement.reset_column_information
|
8
|
+
Pulitzer::ContentElement.find_each do |ce|
|
9
|
+
if ptce = ce.post_type_content_element_type
|
10
|
+
ce.update(text_editor: ptce.text_editor, height: ptce.height, width: ptce.width)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
remove_column :pulitzer_content_elements, :text_editor
|
17
|
+
remove_column :pulitzer_content_elements, :height
|
18
|
+
remove_column :pulitzer_content_elements, :width
|
19
|
+
remove_column :pulitzer_content_elements, :sort_order
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ChangeTemplateToPulitzerPostTypes < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
remove_column :pulitzer_post_types, :template
|
4
|
+
add_column :pulitzer_post_types, :kind, :integer, default: 0
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :pulitzer_post_types, :kind
|
9
|
+
add_column :pulitzer_post_types, :template, :boolean
|
10
|
+
end
|
11
|
+
end
|