comfortable_mexican_sofa 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/README.md +1 -1
- data/app/assets/stylesheets/comfy/admin/cms/base.sass +1 -1
- data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +47 -0
- data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +15 -0
- data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +22 -0
- data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +15 -0
- data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +23 -0
- data/app/views/comfy/admin/cms/layouts/edit.html.haml +2 -2
- data/app/views/comfy/admin/cms/pages/edit.html.haml +3 -4
- data/app/views/comfy/admin/cms/revisions/_sidebar.html.haml +2 -0
- data/app/views/comfy/admin/cms/revisions/show.html.haml +2 -3
- data/app/views/comfy/admin/cms/snippets/edit.html.haml +2 -3
- data/app/views/comfy/admin/cms/translations/_sidebar.html.haml +1 -1
- data/app/views/comfy/admin/cms/translations/edit.html.haml +3 -4
- data/config/environments/development.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/config/locales/cs.yml +7 -12
- data/config/locales/da.yml +7 -12
- data/config/locales/de.yml +7 -12
- data/config/locales/en.yml +7 -12
- data/config/locales/es.yml +7 -12
- data/config/locales/fr.yml +7 -12
- data/config/locales/it.yml +7 -12
- data/config/locales/ja.yml +7 -12
- data/config/locales/nb.yml +7 -12
- data/config/locales/nl.yml +7 -12
- data/config/locales/pl.yml +7 -12
- data/config/locales/pt-BR.yml +7 -12
- data/config/locales/ru.yml +7 -12
- data/config/locales/sk.yml +7 -12
- data/config/locales/sv.yml +7 -12
- data/config/locales/tr.yml +7 -12
- data/config/locales/uk.yml +7 -12
- data/config/locales/zh-CN.yml +7 -12
- data/config/locales/zh-TW.yml +7 -12
- data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +19 -14
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +62 -0
- data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +87 -0
- data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +59 -0
- data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +69 -0
- data/test/gemfiles/Gemfile.rails.5.2 +1 -21
- data/test/integration/access_control_test.rb +9 -9
- metadata +12 -4
- data/app/controllers/comfy/admin/cms/revisions_controller.rb +0 -67
- data/test/controllers/comfy/admin/cms/revisions_controller_test.rb +0 -248
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../../../../../test_helper'
|
2
|
+
|
3
|
+
class Comfy::Admin::Cms::Revisions::SnippetControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@site = comfy_cms_sites(:default)
|
7
|
+
@snippet = comfy_cms_snippets(:default)
|
8
|
+
@revision = comfy_cms_revisions(:snippet)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_index
|
12
|
+
r :get, comfy_admin_cms_site_snippet_revisions_path(@site, @snippet)
|
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_cms_site_snippet_revisions_path(@site, @snippet)
|
20
|
+
assert_response :redirect
|
21
|
+
assert_redirected_to edit_comfy_admin_cms_site_snippet_path(@site, @snippet)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_show
|
25
|
+
r :get, comfy_admin_cms_site_snippet_revision_path(@site, @snippet, @revision)
|
26
|
+
assert_response :success
|
27
|
+
assert assigns(:record)
|
28
|
+
assert assigns(:revision)
|
29
|
+
assert assigns(:record).is_a?(Comfy::Cms::Snippet)
|
30
|
+
assert_template :show
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_get_show_for_invalid_record
|
34
|
+
r :get, comfy_admin_cms_site_snippet_revision_path(@site, "invalid", @revision)
|
35
|
+
assert_response :redirect
|
36
|
+
assert_redirected_to comfy_admin_cms_site_snippets_path(@site)
|
37
|
+
assert_equal 'Record Not Found', flash[:danger]
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_get_show_failure
|
41
|
+
r :get, comfy_admin_cms_site_snippet_revision_path(@site, @snippet, 'invalid')
|
42
|
+
assert_response :redirect
|
43
|
+
assert assigns(:record)
|
44
|
+
assert_redirected_to edit_comfy_admin_cms_site_snippet_path(@site, assigns(:record))
|
45
|
+
assert_equal 'Revision Not Found', flash[:danger]
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_revert
|
49
|
+
assert_difference -> {@snippet.revisions.count} do
|
50
|
+
r :patch, revert_comfy_admin_cms_site_snippet_revision_path(@site, @snippet, @revision)
|
51
|
+
assert_response :redirect
|
52
|
+
assert_redirected_to edit_comfy_admin_cms_site_snippet_path(@site, @snippet)
|
53
|
+
assert_equal 'Content Reverted', flash[:success]
|
54
|
+
|
55
|
+
@snippet.reload
|
56
|
+
assert_equal 'revision content', @snippet.content
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative '../../../../../test_helper'
|
2
|
+
|
3
|
+
class Comfy::Admin::Cms::Revisions::TranslationControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@site = comfy_cms_sites(:default)
|
7
|
+
@page = comfy_cms_pages(:default)
|
8
|
+
@translation = comfy_cms_translations(:default)
|
9
|
+
@revision = comfy_cms_revisions(:translation)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_index
|
13
|
+
r :get, comfy_admin_cms_site_page_translation_revisions_path(@site, @page, @translation)
|
14
|
+
assert_response :redirect
|
15
|
+
assert_redirected_to action: :show, id: @revision
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_index_with_no_revisions
|
19
|
+
Comfy::Cms::Revision.delete_all
|
20
|
+
r :get, comfy_admin_cms_site_page_translation_revisions_path(@site, @page, @translation)
|
21
|
+
assert_response :redirect
|
22
|
+
assert_redirected_to edit_comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_show
|
26
|
+
r :get, comfy_admin_cms_site_page_translation_revision_path(@site, @page, @translation, @revision)
|
27
|
+
assert_response :success
|
28
|
+
assert assigns(:record)
|
29
|
+
assert assigns(:revision)
|
30
|
+
assert assigns(:record).is_a?(Comfy::Cms::Translation)
|
31
|
+
assert_template :show
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_show_for_invalid_record
|
35
|
+
r :get, comfy_admin_cms_site_page_translation_revision_path(@site, @page, "invalid", @revision)
|
36
|
+
assert_response :redirect
|
37
|
+
assert_redirected_to comfy_admin_cms_site_pages_path(@site)
|
38
|
+
assert_equal 'Record Not Found', flash[:danger]
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def test_get_show_failure
|
43
|
+
r :get, comfy_admin_cms_site_page_translation_revision_path(@site, @page, @translation, 'invalid')
|
44
|
+
assert_response :redirect
|
45
|
+
assert assigns(:record)
|
46
|
+
assert_redirected_to edit_comfy_admin_cms_site_page_translation_path(@site, @page, assigns(:record))
|
47
|
+
assert_equal 'Revision Not Found', flash[:danger]
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_revert
|
51
|
+
assert_difference -> {@translation.revisions.count} do
|
52
|
+
r :patch, revert_comfy_admin_cms_site_page_translation_revision_path(@site, @page, @translation, @revision)
|
53
|
+
assert_response :redirect
|
54
|
+
assert_redirected_to edit_comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
55
|
+
assert_equal 'Content Reverted', flash[:success]
|
56
|
+
|
57
|
+
@translation.reload
|
58
|
+
|
59
|
+
assert_equal [{
|
60
|
+
identifier: "content",
|
61
|
+
tag: "text",
|
62
|
+
content: "old content",
|
63
|
+
datetime: nil,
|
64
|
+
boolean: false
|
65
|
+
}], @translation.fragments_attributes
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -1,29 +1,9 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
gem "bootstrap_form",
|
6
|
-
github: "bootstrap-ruby/rails-bootstrap-forms",
|
7
|
-
branch: "bootstrap-v4"
|
3
|
+
gemspec path: "../../"
|
8
4
|
|
9
5
|
gem 'kaminari', '>= 0.14.0'
|
10
6
|
|
11
|
-
gem "bootstrap", ">= 4.0.0.beta2.1"
|
12
|
-
gem "mini_magick", ">= 4.8.0"
|
13
|
-
gem "mimemagic", ">= 0.3.2"
|
14
|
-
gem "jquery-rails", ">= 4.3.1"
|
15
|
-
gem "jquery-ui-rails", ">= 6.0.1"
|
16
|
-
gem "codemirror-rails", ">= 5.16.0"
|
17
|
-
gem "font-awesome-rails", ">= 4.7.0"
|
18
|
-
gem "rails-i18n", ">= 5.0.0"
|
19
|
-
gem "active_link_to", ">= 1.0.0"
|
20
|
-
gem "haml-rails", ">= 1.0.0"
|
21
|
-
|
22
|
-
gem 'kramdown', '>= 1.0.0'
|
23
|
-
gem 'sass-rails', '>= 4.0.3'
|
24
|
-
gem 'coffee-rails', '>= 3.1.0'
|
25
|
-
gem 'plupload-rails', '>= 1.2.1'
|
26
|
-
|
27
7
|
group :test do
|
28
8
|
gem 'sqlite3'
|
29
9
|
gem 'coveralls', require: false
|
@@ -25,15 +25,15 @@ class AccessControlTest < ActionDispatch::IntegrationTest
|
|
25
25
|
|
26
26
|
# faking ComfortableMexicanSofa.config.admin_authorization = 'AccessControlTest::TestAuthorization'
|
27
27
|
# faking ComfortableMexicanSofa.config.public_authorization = 'AccessControlTest::TestAuthorization'
|
28
|
-
class SitesController < Comfy::Admin::Cms::SitesController;
|
29
|
-
class LayoutsController < Comfy::Admin::Cms::LayoutsController;
|
30
|
-
class PagesController < Comfy::Admin::Cms::PagesController;
|
31
|
-
class SnippetsController < Comfy::Admin::Cms::SnippetsController;
|
32
|
-
class FilesController < Comfy::Admin::Cms::FilesController;
|
33
|
-
class CategoriesController < Comfy::Admin::Cms::CategoriesController;
|
34
|
-
class RevisionsController < Comfy::Admin::Cms::
|
35
|
-
class TranslationsController < Comfy::Admin::Cms::TranslationsController;
|
36
|
-
class ContentController < Comfy::Cms::ContentController;
|
28
|
+
class SitesController < Comfy::Admin::Cms::SitesController; include Authorize; end
|
29
|
+
class LayoutsController < Comfy::Admin::Cms::LayoutsController; include Authorize; end
|
30
|
+
class PagesController < Comfy::Admin::Cms::PagesController; include Authorize; end
|
31
|
+
class SnippetsController < Comfy::Admin::Cms::SnippetsController; include Authorize; end
|
32
|
+
class FilesController < Comfy::Admin::Cms::FilesController; include Authorize; end
|
33
|
+
class CategoriesController < Comfy::Admin::Cms::CategoriesController; include Authorize; end
|
34
|
+
class RevisionsController < Comfy::Admin::Cms::Revisions::LayoutController; include Authorize; end
|
35
|
+
class TranslationsController < Comfy::Admin::Cms::TranslationsController; include Authorize; end
|
36
|
+
class ContentController < Comfy::Cms::ContentController; include Authorize; end
|
37
37
|
end
|
38
38
|
|
39
39
|
# -- Tests -------------------------------------------------------------------
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfortable_mexican_sofa
|
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: rails
|
@@ -382,7 +382,11 @@ files:
|
|
382
382
|
- app/controllers/comfy/admin/cms/files_controller.rb
|
383
383
|
- app/controllers/comfy/admin/cms/layouts_controller.rb
|
384
384
|
- app/controllers/comfy/admin/cms/pages_controller.rb
|
385
|
-
- app/controllers/comfy/admin/cms/
|
385
|
+
- app/controllers/comfy/admin/cms/revisions/base_controller.rb
|
386
|
+
- app/controllers/comfy/admin/cms/revisions/layout_controller.rb
|
387
|
+
- app/controllers/comfy/admin/cms/revisions/page_controller.rb
|
388
|
+
- app/controllers/comfy/admin/cms/revisions/snippet_controller.rb
|
389
|
+
- app/controllers/comfy/admin/cms/revisions/translation_controller.rb
|
386
390
|
- app/controllers/comfy/admin/cms/sites_controller.rb
|
387
391
|
- app/controllers/comfy/admin/cms/snippets_controller.rb
|
388
392
|
- app/controllers/comfy/admin/cms/translations_controller.rb
|
@@ -435,6 +439,7 @@ files:
|
|
435
439
|
- app/views/comfy/admin/cms/pages/index.html.haml
|
436
440
|
- app/views/comfy/admin/cms/pages/new.html.haml
|
437
441
|
- app/views/comfy/admin/cms/pages/toggle_branch.js.erb
|
442
|
+
- app/views/comfy/admin/cms/revisions/_sidebar.html.haml
|
438
443
|
- app/views/comfy/admin/cms/revisions/show.html.haml
|
439
444
|
- app/views/comfy/admin/cms/sites/_form.html.haml
|
440
445
|
- app/views/comfy/admin/cms/sites/edit.html.haml
|
@@ -581,7 +586,10 @@ files:
|
|
581
586
|
- test/controllers/comfy/admin/cms/files_controller_test.rb
|
582
587
|
- test/controllers/comfy/admin/cms/layouts_controller_test.rb
|
583
588
|
- test/controllers/comfy/admin/cms/pages_controller_test.rb
|
584
|
-
- test/controllers/comfy/admin/cms/
|
589
|
+
- test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb
|
590
|
+
- test/controllers/comfy/admin/cms/revisions/page_controller_test.rb
|
591
|
+
- test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb
|
592
|
+
- test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb
|
585
593
|
- test/controllers/comfy/admin/cms/sites_controller_test.rb
|
586
594
|
- test/controllers/comfy/admin/cms/snippets_controller_test.rb
|
587
595
|
- test/controllers/comfy/admin/cms/translations_controller_test.rb
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Comfy::Admin::Cms::RevisionsController < Comfy::Admin::Cms::BaseController
|
2
|
-
|
3
|
-
before_action :load_record
|
4
|
-
before_action :load_revision, except: :index
|
5
|
-
before_action :authorize
|
6
|
-
|
7
|
-
helper_method :record_path
|
8
|
-
|
9
|
-
def index
|
10
|
-
redirect_to action: :show, id: @record.revisions.order(created_at: :desc).first.try(:id) || 0
|
11
|
-
end
|
12
|
-
|
13
|
-
def show
|
14
|
-
case @record
|
15
|
-
when Comfy::Cms::Page, Comfy::Cms::Translation
|
16
|
-
@current_content = @record.fragments.inject({}){|c, b| c[b.identifier] = b.content; c }
|
17
|
-
@versioned_content = @record.fragments.inject({}){|c, b| c[b.identifier] = @revision.data['fragments_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
|
18
|
-
else
|
19
|
-
@current_content = @record.revision_fields.inject({}){|c, f| c[f] = @record.send(f); c }
|
20
|
-
@versioned_content = @record.revision_fields.inject({}){|c, f| c[f] = @revision.data[f]; c }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def revert
|
25
|
-
@record.restore_from_revision(@revision)
|
26
|
-
flash[:success] = I18n.t('comfy.admin.cms.revisions.reverted')
|
27
|
-
redirect_to record_path
|
28
|
-
end
|
29
|
-
|
30
|
-
protected
|
31
|
-
|
32
|
-
def load_record
|
33
|
-
@record = if params[:layout_id]
|
34
|
-
::Comfy::Cms::Layout.find(params[:layout_id])
|
35
|
-
elsif params[:translation_id]
|
36
|
-
::Comfy::Cms::Translation.find(params[:translation_id])
|
37
|
-
elsif params[:page_id]
|
38
|
-
::Comfy::Cms::Page.find(params[:page_id])
|
39
|
-
elsif params[:snippet_id]
|
40
|
-
::Comfy::Cms::Snippet.find(params[:snippet_id])
|
41
|
-
end
|
42
|
-
|
43
|
-
rescue ActiveRecord::RecordNotFound
|
44
|
-
flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
|
45
|
-
redirect_to comfy_admin_cms_path
|
46
|
-
end
|
47
|
-
|
48
|
-
def load_revision
|
49
|
-
@revision = @record.revisions.find(params[:id])
|
50
|
-
rescue ActiveRecord::RecordNotFound
|
51
|
-
flash[:danger] = I18n.t('comfy.admin.cms.revisions.not_found')
|
52
|
-
redirect_to record_path
|
53
|
-
end
|
54
|
-
|
55
|
-
def record_path(record = @record)
|
56
|
-
case record
|
57
|
-
when ::Comfy::Cms::Layout
|
58
|
-
edit_comfy_admin_cms_site_layout_path(@site, @record)
|
59
|
-
when ::Comfy::Cms::Page
|
60
|
-
edit_comfy_admin_cms_site_page_path(@site, @record)
|
61
|
-
when ::Comfy::Cms::Translation
|
62
|
-
edit_comfy_admin_cms_site_page_translation_path(@site, @record.page, @record)
|
63
|
-
when ::Comfy::Cms::Snippet
|
64
|
-
edit_comfy_admin_cms_site_snippet_path(@site, @record)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,248 +0,0 @@
|
|
1
|
-
require_relative '../../../../test_helper'
|
2
|
-
|
3
|
-
class Comfy::Admin::Cms::RevisionsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@page = comfy_cms_pages(:default)
|
9
|
-
@translation = comfy_cms_translations(:default)
|
10
|
-
@snippet = comfy_cms_snippets(:default)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_get_index_for_layouts
|
14
|
-
r :get, comfy_admin_cms_site_layout_revisions_path(@site, @layout)
|
15
|
-
assert_response :redirect
|
16
|
-
assert_redirected_to action: :show, id: comfy_cms_revisions(:layout)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_get_index_for_pages
|
20
|
-
r :get, comfy_admin_cms_site_page_revisions_path(@site, @page)
|
21
|
-
assert_response :redirect
|
22
|
-
assert_redirected_to action: :show, id: comfy_cms_revisions(:page)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_get_index_for_snippets
|
26
|
-
r :get, comfy_admin_cms_site_snippet_revisions_path(@site, @snippet)
|
27
|
-
assert_response :redirect
|
28
|
-
assert_redirected_to action: :show, id: comfy_cms_revisions(:snippet)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_get_index_for_translations
|
32
|
-
r :get, comfy_admin_cms_site_page_translation_revisions_path(@site, @page, @translation)
|
33
|
-
assert_response :redirect
|
34
|
-
assert_redirected_to action: :show, id: comfy_cms_revisions(:translation)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_get_index_for_snippets_with_no_revisions
|
38
|
-
Comfy::Cms::Revision.delete_all
|
39
|
-
r :get, comfy_admin_cms_site_snippet_revisions_path(@site, @snippet)
|
40
|
-
assert_response :redirect
|
41
|
-
assert_redirected_to action: :show, id: 0
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_get_show_for_layout
|
45
|
-
r :get, comfy_admin_cms_site_layout_revision_path(
|
46
|
-
site_id: @site,
|
47
|
-
layout_id: @layout,
|
48
|
-
id: comfy_cms_revisions(:layout))
|
49
|
-
assert_response :success
|
50
|
-
assert assigns(:record)
|
51
|
-
assert assigns(:revision)
|
52
|
-
assert assigns(:record).is_a?(Comfy::Cms::Layout)
|
53
|
-
assert_template :show
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_get_show_for_page
|
57
|
-
r :get, comfy_admin_cms_site_page_revision_path(
|
58
|
-
site_id: @site,
|
59
|
-
page_id: @page,
|
60
|
-
id: comfy_cms_revisions(:page))
|
61
|
-
assert_response :success
|
62
|
-
assert assigns(:record)
|
63
|
-
assert assigns(:revision)
|
64
|
-
assert assigns(:record).is_a?(Comfy::Cms::Page)
|
65
|
-
assert_template :show
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_get_show_for_translation
|
69
|
-
r :get, comfy_admin_cms_site_page_translation_revision_path(
|
70
|
-
site_id: @site,
|
71
|
-
page_id: @page,
|
72
|
-
translation_id: @translation,
|
73
|
-
id: comfy_cms_revisions(:translation))
|
74
|
-
assert_response :success
|
75
|
-
assert assigns(:record)
|
76
|
-
assert assigns(:revision)
|
77
|
-
assert assigns(:record).is_a?(Comfy::Cms::Translation)
|
78
|
-
assert_template :show
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_get_show_for_snippet
|
82
|
-
r :get, comfy_admin_cms_site_snippet_revision_path(
|
83
|
-
site_id: @site,
|
84
|
-
snippet_id: @snippet,
|
85
|
-
id: comfy_cms_revisions(:snippet))
|
86
|
-
assert_response :success
|
87
|
-
assert assigns(:record)
|
88
|
-
assert assigns(:revision)
|
89
|
-
assert assigns(:record).is_a?(Comfy::Cms::Snippet)
|
90
|
-
assert_template :show
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_get_show_for_bad_type
|
94
|
-
r :get, comfy_admin_cms_site_layout_revision_path(
|
95
|
-
site_id: @site,
|
96
|
-
layout_id: 'invalid',
|
97
|
-
id: comfy_cms_revisions(:layout))
|
98
|
-
assert_response :redirect
|
99
|
-
assert_redirected_to comfy_admin_cms_path
|
100
|
-
assert_equal 'Record Not Found', flash[:danger]
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_get_show_for_layout_failure
|
104
|
-
r :get, comfy_admin_cms_site_layout_revision_path(
|
105
|
-
site_id: @site,
|
106
|
-
layout_id: @layout,
|
107
|
-
id: 'invalid')
|
108
|
-
assert_response :redirect
|
109
|
-
assert assigns(:record)
|
110
|
-
assert_redirected_to edit_comfy_admin_cms_site_layout_path(@site, assigns(:record))
|
111
|
-
assert_equal 'Revision Not Found', flash[:danger]
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_get_show_for_page_failure
|
115
|
-
r :get, comfy_admin_cms_site_page_revision_path(
|
116
|
-
site_id: @site,
|
117
|
-
page_id: @page,
|
118
|
-
id: 'invalid')
|
119
|
-
assert_response :redirect
|
120
|
-
assert assigns(:record)
|
121
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, assigns(:record))
|
122
|
-
assert_equal 'Revision Not Found', flash[:danger]
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_get_show_for_translation_failure
|
126
|
-
r :get, comfy_admin_cms_site_page_translation_revision_path(
|
127
|
-
site_id: @site,
|
128
|
-
page_id: @page,
|
129
|
-
translation_id: @translation,
|
130
|
-
id: 'invalid')
|
131
|
-
assert_response :redirect
|
132
|
-
assert assigns(:record)
|
133
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_translation_path(@site, @page, assigns(:record))
|
134
|
-
assert_equal 'Revision Not Found', flash[:danger]
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_get_show_for_snippet_failure
|
138
|
-
r :get, comfy_admin_cms_site_snippet_revision_path(
|
139
|
-
site_id: @site,
|
140
|
-
snippet_id: @snippet,
|
141
|
-
id: 'invalid')
|
142
|
-
assert_response :redirect
|
143
|
-
assert assigns(:record)
|
144
|
-
assert_redirected_to edit_comfy_admin_cms_site_snippet_path(@site, assigns(:record))
|
145
|
-
assert_equal 'Revision Not Found', flash[:danger]
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_revert_for_layout
|
149
|
-
assert_difference -> {@layout.revisions.count} do
|
150
|
-
r :patch, revert_comfy_admin_cms_site_layout_revision_path(
|
151
|
-
site_id: @site,
|
152
|
-
layout_id: @layout,
|
153
|
-
id: comfy_cms_revisions(:layout)
|
154
|
-
)
|
155
|
-
assert_response :redirect
|
156
|
-
assert_redirected_to edit_comfy_admin_cms_site_layout_path(@site, @layout)
|
157
|
-
assert_equal 'Content Reverted', flash[:success]
|
158
|
-
|
159
|
-
@layout.reload
|
160
|
-
assert_equal 'revision {{cms:fragment content}}', @layout.content
|
161
|
-
assert_equal 'revision css', @layout.css
|
162
|
-
assert_equal 'revision js', @layout.js
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_revert_for_page
|
167
|
-
assert_difference -> {@page.revisions.count} do
|
168
|
-
r :patch, revert_comfy_admin_cms_site_page_revision_path(
|
169
|
-
site_id: @site,
|
170
|
-
page_id: @page,
|
171
|
-
id: comfy_cms_revisions(:page)
|
172
|
-
)
|
173
|
-
assert_response :redirect
|
174
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, @page)
|
175
|
-
assert_equal 'Content Reverted', flash[:success]
|
176
|
-
|
177
|
-
@page.reload
|
178
|
-
|
179
|
-
assert_equal [
|
180
|
-
{ identifier: "boolean",
|
181
|
-
tag: "checkbox",
|
182
|
-
content: nil,
|
183
|
-
datetime: nil,
|
184
|
-
boolean: true },
|
185
|
-
{ identifier: "file",
|
186
|
-
tag: "file",
|
187
|
-
content: nil,
|
188
|
-
datetime: nil,
|
189
|
-
boolean: false },
|
190
|
-
{ identifier: "datetime",
|
191
|
-
tag: "datetime",
|
192
|
-
content: nil,
|
193
|
-
datetime: comfy_cms_fragments(:datetime).datetime,
|
194
|
-
boolean: false },
|
195
|
-
{ identifier: "content",
|
196
|
-
tag: "text",
|
197
|
-
content: "old content",
|
198
|
-
datetime: nil,
|
199
|
-
boolean: false },
|
200
|
-
{ identifier: "title",
|
201
|
-
tag: "text",
|
202
|
-
content: "old title",
|
203
|
-
datetime: nil,
|
204
|
-
boolean: false }
|
205
|
-
], @page.fragments_attributes
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_revert_for_page
|
210
|
-
assert_difference -> {@translation.revisions.count} do
|
211
|
-
r :patch, revert_comfy_admin_cms_site_page_translation_revision_path(
|
212
|
-
site_id: @site,
|
213
|
-
page_id: @page,
|
214
|
-
translation_id: @translation,
|
215
|
-
id: comfy_cms_revisions(:translation)
|
216
|
-
)
|
217
|
-
assert_response :redirect
|
218
|
-
assert_redirected_to edit_comfy_admin_cms_site_page_translation_path(@site, @page, @translation)
|
219
|
-
assert_equal 'Content Reverted', flash[:success]
|
220
|
-
|
221
|
-
@translation.reload
|
222
|
-
|
223
|
-
assert_equal [
|
224
|
-
{ identifier: "content",
|
225
|
-
tag: "text",
|
226
|
-
content: "old content",
|
227
|
-
datetime: nil,
|
228
|
-
boolean: false }
|
229
|
-
], @translation.fragments_attributes
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_revert_for_snippet
|
234
|
-
assert_difference -> {@snippet.revisions.count} do
|
235
|
-
r :patch, revert_comfy_admin_cms_site_snippet_revision_path(
|
236
|
-
site_id: @site,
|
237
|
-
snippet_id: @snippet,
|
238
|
-
id: comfy_cms_revisions(:snippet)
|
239
|
-
)
|
240
|
-
assert_response :redirect
|
241
|
-
assert_redirected_to edit_comfy_admin_cms_site_snippet_path(@site, @snippet)
|
242
|
-
assert_equal 'Content Reverted', flash[:success]
|
243
|
-
|
244
|
-
@snippet.reload
|
245
|
-
assert_equal 'revision content', @snippet.content
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|