comfy_blog 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comfy/admin/blog/revisions/post_controller.rb +22 -0
- data/app/models/comfy/blog/post.rb +2 -0
- data/app/views/comfy/admin/blog/posts/edit.html.haml +4 -0
- data/comfy_blog.gemspec +1 -1
- data/config/environments/development.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/lib/comfy_blog/routes/blog_admin.rb +5 -1
- data/lib/comfy_blog/version.rb +1 -1
- data/test/controllers/comfy/admin/blog/revisions/post_controller_test.rb +67 -0
- data/test/fixtures/comfy/cms/revisions.yml +7 -0
- data/test/gemfiles/Gemfile.rails.5.2 +1 -11
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed87b17424062fedd960bd78ef9b0c6bd9b8923d
|
4
|
+
data.tar.gz: a652f008197705629d93c583c1d36cb79a9b9712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1489b02510daba80054da073d9c0ef0ee001146e6f00fdd0eeca4594cf69b74699d36843ff07dd29532b3dbaff5cd127b1a758ed36cead694851d8d6aa67cc7
|
7
|
+
data.tar.gz: '0586168fa718e0f0123e98568a8f20f9c71a17ad3b98debda40ba06854d645a71ed85332d6f03c93721d25f6ceab735046d639539b29b7ee0d578e5bc0b530e7'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Comfy::Admin::Blog::Revisions::PostController < Comfy::Admin::Cms::Revisions::BaseController
|
2
|
+
|
3
|
+
def show
|
4
|
+
@current_content = @record.fragments.inject({}){|c, b| c[b.identifier] = b.content; c }
|
5
|
+
@versioned_content = @record.fragments.inject({}){|c, b| c[b.identifier] = @revision.data['fragments_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
|
6
|
+
|
7
|
+
render "comfy/admin/cms/revisions/show"
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def load_record
|
13
|
+
@record = @site.blog_posts.find(params[:blog_post_id])
|
14
|
+
rescue ActiveRecord::RecordNotFound
|
15
|
+
flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
|
16
|
+
redirect_to comfy_admin_blog_posts_path(@site)
|
17
|
+
end
|
18
|
+
|
19
|
+
def record_path
|
20
|
+
edit_comfy_admin_blog_post_path(@site, @record)
|
21
|
+
end
|
22
|
+
end
|
@@ -5,6 +5,8 @@ class Comfy::Blog::Post < ActiveRecord::Base
|
|
5
5
|
include Comfy::Cms::WithFragments
|
6
6
|
include Comfy::Cms::WithCategories
|
7
7
|
|
8
|
+
cms_has_revisions_for :fragments_attributes
|
9
|
+
|
8
10
|
# -- Relationships -----------------------------------------------------------
|
9
11
|
belongs_to :site,
|
10
12
|
class_name: 'Comfy::Cms::Site'
|
data/comfy_blog.gemspec
CHANGED
data/config/environments/test.rb
CHANGED
@@ -7,7 +7,11 @@ class ActionDispatch::Routing::Mapper
|
|
7
7
|
scope module: :comfy, as: :comfy do
|
8
8
|
scope module: :admin do
|
9
9
|
namespace :blog, as: :admin, path: path, except: [:show] do
|
10
|
-
resources :posts, as: :blog_posts, path: "blog-posts"
|
10
|
+
resources :posts, as: :blog_posts, path: "blog-posts" do
|
11
|
+
resources :revisions, only: [:index, :show], controller: "revisions/post" do
|
12
|
+
patch :revert, on: :member
|
13
|
+
end
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/comfy_blog/version.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../../../../../test_helper'
|
2
|
+
|
3
|
+
class Comfy::Admin::Cms::Revisions::PageControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@site = comfy_cms_sites(:default)
|
7
|
+
@post = comfy_blog_posts(:default)
|
8
|
+
@revision = comfy_cms_revisions(:post)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_index
|
12
|
+
r :get, comfy_admin_blog_post_revisions_path(@site, @post)
|
13
|
+
assert_response :redirect
|
14
|
+
assert_redirected_to action: :show, id: @revision
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_index_with_no_revisions
|
18
|
+
Comfy::Cms::Revision.delete_all
|
19
|
+
r :get, comfy_admin_blog_post_revisions_path(@site, @post)
|
20
|
+
assert_response :redirect
|
21
|
+
assert_redirected_to edit_comfy_admin_blog_post_path(@site, @post)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_show
|
25
|
+
r :get, comfy_admin_blog_post_revision_path(@site, @post, @revision)
|
26
|
+
assert_response :success
|
27
|
+
assert assigns(:record)
|
28
|
+
assert assigns(:revision)
|
29
|
+
assert assigns(:record).is_a?(Comfy::Blog::Post)
|
30
|
+
assert_template :show
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_get_show_for_invalid_record
|
34
|
+
r :get, comfy_admin_blog_post_revision_path(@site, "invalid", @revision)
|
35
|
+
assert_response :redirect
|
36
|
+
assert_redirected_to comfy_admin_blog_posts_path(@site)
|
37
|
+
assert_equal 'Record Not Found', flash[:danger]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def test_get_show_failure
|
42
|
+
r :get, comfy_admin_blog_post_revision_path(@site, @post, "invalid")
|
43
|
+
assert_response :redirect
|
44
|
+
assert assigns(:record)
|
45
|
+
assert_redirected_to edit_comfy_admin_blog_post_path(@site, assigns(:record))
|
46
|
+
assert_equal 'Revision Not Found', flash[:danger]
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_revert
|
50
|
+
assert_difference -> {@post.revisions.count} do
|
51
|
+
r :patch, revert_comfy_admin_blog_post_revision_path(@site, @post, @revision)
|
52
|
+
assert_response :redirect
|
53
|
+
assert_redirected_to edit_comfy_admin_blog_post_path(@site, @post)
|
54
|
+
assert_equal 'Content Reverted', flash[:success]
|
55
|
+
|
56
|
+
@post.reload
|
57
|
+
|
58
|
+
assert_equal [{
|
59
|
+
identifier: "content",
|
60
|
+
tag: "text",
|
61
|
+
content: "old content",
|
62
|
+
datetime: nil,
|
63
|
+
boolean: false
|
64
|
+
}], @post.fragments_attributes
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,16 +1,6 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
github: "rails"
|
5
|
-
gem "arel",
|
6
|
-
github: "rails/arel"
|
7
|
-
|
8
|
-
gem "bootstrap_form",
|
9
|
-
github: "bootstrap-ruby/rails-bootstrap-forms",
|
10
|
-
branch: "bootstrap-v4"
|
11
|
-
|
12
|
-
gem "comfortable_mexican_sofa",
|
13
|
-
github: "comfy/comfortable-mexican-sofa"
|
3
|
+
gemspec path: "../../"
|
14
4
|
|
15
5
|
gem 'kaminari', '>= 0.14.0'
|
16
6
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfy_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Khabarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: comfortable_mexican_sofa
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.
|
19
|
+
version: 2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.
|
26
|
+
version: 2.0.2
|
27
27
|
description: Simple Blog Engine for ComfortableMexicanSofa
|
28
28
|
email:
|
29
29
|
- oleg@khabarov.ca
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
40
|
- app/controllers/comfy/admin/blog/posts_controller.rb
|
41
|
+
- app/controllers/comfy/admin/blog/revisions/post_controller.rb
|
41
42
|
- app/controllers/comfy/blog/posts_controller.rb
|
42
43
|
- app/models/comfy/blog/post.rb
|
43
44
|
- app/views/comfy/admin/blog/partials/_navigation.html.haml
|
@@ -90,9 +91,11 @@ files:
|
|
90
91
|
- lib/generators/comfy/blog/blog_generator.rb
|
91
92
|
- script/rails
|
92
93
|
- test/controllers/comfy/admin/blog/posts_controller_test.rb
|
94
|
+
- test/controllers/comfy/admin/blog/revisions/post_controller_test.rb
|
93
95
|
- test/controllers/comfy/blog/posts_controller_test.rb
|
94
96
|
- test/fixtures/comfy/blog/posts.yml
|
95
97
|
- test/fixtures/comfy/cms/layouts.yml
|
98
|
+
- test/fixtures/comfy/cms/revisions.yml
|
96
99
|
- test/fixtures/comfy/cms/sites.yml
|
97
100
|
- test/fixtures/generators/blog/routes.rb
|
98
101
|
- test/gemfiles/Gemfile.rails.5.2
|