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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61326ff45ee457862bc9f4f00de3c9c825fd8e71
4
- data.tar.gz: 5cf76269962ea8a37ad65a06a1ba903735f437d3
3
+ metadata.gz: ed87b17424062fedd960bd78ef9b0c6bd9b8923d
4
+ data.tar.gz: a652f008197705629d93c583c1d36cb79a9b9712
5
5
  SHA512:
6
- metadata.gz: 7524fe62eb167f1a074bf50f2f0620c56a74ce45fdf7a3d3f08e30c848eec0fa1e1ab6aeb9b73f9a33599436bf575fc37a0b9b75708902da1592fdd1816372af
7
- data.tar.gz: 980e2668fa3323a5382710b2821a608d75a556b72e5867f09757e5de8513c699c65a9ccefb80fd3d6416f08dfdce4df85abbef885da7c4a1baadd4a7d63eae96
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'
@@ -1,3 +1,7 @@
1
+ - content_for :right_column do
2
+ - link = comfy_admin_blog_post_revisions_path(@site, @post)
3
+ = render "comfy/admin/cms/revisions/sidebar", record: @post, link: link
4
+
1
5
  .page-header
2
6
  %h2= t('.title')
3
7
 
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.required_ruby_version = ">= 2.2.2"
21
21
 
22
- s.add_dependency 'comfortable_mexican_sofa', '>= 2.0.0'
22
+ s.add_dependency 'comfortable_mexican_sofa', '>= 2.0.2'
23
23
  end
@@ -57,4 +57,6 @@ defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
57
57
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
58
58
 
59
59
  config.active_job.queue_adapter = :inline
60
+
61
+ config.action_view.raise_on_missing_translations = true
60
62
  end
@@ -44,4 +44,6 @@ defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
44
44
  # config.action_view.raise_on_missing_translations = true
45
45
 
46
46
  config.active_job.queue_adapter = :inline
47
+
48
+ config.action_view.raise_on_missing_translations = true
47
49
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ComfyBlog
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -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
@@ -0,0 +1,7 @@
1
+ post:
2
+ record: default (Comfy::Blog::Post)
3
+ data: <%= {
4
+ "fragments_attributes" => [
5
+ { "identifier" => "content",
6
+ "content" => "old content" }
7
+ ]}.to_yaml.inspect %>
@@ -1,16 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem "rails",
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.1
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-01 00:00:00.000000000 Z
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.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.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