comfortable_mexican_sofa 1.8.3 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/Gemfile +2 -2
- data/README.md +3 -3
- data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +11 -11
- data/app/assets/stylesheets/comfortable_mexican_sofa/bootstrap_overrides.css.sass +2 -2
- data/app/controllers/cms_admin/base_controller.rb +1 -1
- data/app/controllers/cms_content_controller.rb +1 -1
- data/app/models/cms/block.rb +1 -1
- data/app/models/cms/file.rb +4 -1
- data/config/database.yml +1 -1
- data/db/cms_fixtures/sample-site/categories/files.yml +1 -0
- data/db/cms_fixtures/sample-site/categories/pages.yml +1 -0
- data/db/cms_fixtures/sample-site/categories/snippets.yml +1 -0
- data/db/cms_fixtures/sample-site/files/_sample.jpg.yml +5 -0
- data/db/cms_fixtures/sample-site/files/sample.jpg +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{_default.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{js.js → javascript.js} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{_nested.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{js.js → javascript.js} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{css.css → stylesheet.css} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{css.css → stylesheet.css} +0 -0
- data/db/cms_fixtures/sample-site/pages/index/attributes.yml +6 -0
- data/db/cms_fixtures/sample-site/pages/index/child/{_child.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/snippets/default/attributes.yml +4 -0
- data/lib/comfortable_mexican_sofa.rb +25 -23
- data/lib/comfortable_mexican_sofa/fixture.rb +77 -0
- data/lib/comfortable_mexican_sofa/fixture/category.rb +35 -0
- data/lib/comfortable_mexican_sofa/fixture/file.rb +70 -0
- data/lib/comfortable_mexican_sofa/fixture/layout.rb +90 -0
- data/lib/comfortable_mexican_sofa/fixture/page.rb +122 -0
- data/lib/comfortable_mexican_sofa/fixture/snippet.rb +71 -0
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/lib/tasks/comfortable_mexican_sofa.rake +17 -20
- data/test/fixtures/cms/files.yml +2 -2
- data/test/functional/cms_admin/base_controller_test.rb +1 -1
- data/test/functional/cms_admin/categories_controller_test.rb +1 -1
- data/test/functional/cms_admin/files_controller_test.rb +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +1 -1
- data/test/functional/cms_admin/pages_controller_test.rb +1 -1
- data/test/functional/cms_admin/revisions_controller_test.rb +1 -1
- data/test/functional/cms_admin/sites_controller_test.rb +1 -1
- data/test/functional/cms_admin/snippets_controller_test.rb +1 -1
- data/test/functional/cms_content_controller_test.rb +1 -1
- data/test/gemfiles/Gemfile.rails.3.1 +2 -1
- data/test/gemfiles/Gemfile.rails.3.2 +2 -1
- data/test/integration/authentication_test.rb +1 -1
- data/test/integration/fixtures_test.rb +5 -3
- data/test/integration/mirrors_test.rb +1 -1
- data/test/integration/render_cms_test.rb +1 -1
- data/test/integration/sites_test.rb +1 -1
- data/test/integration/view_hooks_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/configuration_test.rb +1 -1
- data/test/unit/fixtures/_sample.jpg.yml +0 -0
- data/test/unit/fixtures/categories_test.rb +35 -0
- data/test/unit/fixtures/files_test.rb +100 -0
- data/test/unit/fixtures/layouts_test.rb +135 -0
- data/test/unit/fixtures/pages_test.rb +152 -0
- data/test/unit/fixtures/snippets_test.rb +101 -0
- data/test/unit/fixtures_test.rb +11 -325
- data/test/unit/mirrors_test.rb +1 -1
- data/test/unit/models/block_test.rb +1 -1
- data/test/unit/models/categorization_test.rb +1 -1
- data/test/unit/models/category_test.rb +1 -1
- data/test/unit/models/file_test.rb +11 -6
- data/test/unit/models/layout_test.rb +1 -1
- data/test/unit/models/page_test.rb +2 -1
- data/test/unit/models/site_test.rb +1 -1
- data/test/unit/models/snippet_test.rb +1 -1
- data/test/unit/revisions_test.rb +1 -1
- data/test/unit/sitemap_test.rb +1 -1
- data/test/unit/tag_test.rb +1 -1
- data/test/unit/tags/asset_test.rb +1 -1
- data/test/unit/tags/collection_test.rb +1 -1
- data/test/unit/tags/field_datetime_test.rb +1 -1
- data/test/unit/tags/field_integer_test.rb +1 -1
- data/test/unit/tags/field_rich_text_test.rb +1 -1
- data/test/unit/tags/field_string_test.rb +1 -1
- data/test/unit/tags/field_text_test.rb +1 -1
- data/test/unit/tags/file_test.rb +1 -1
- data/test/unit/tags/helper_test.rb +1 -1
- data/test/unit/tags/page_datetime_test.rb +1 -1
- data/test/unit/tags/page_file_test.rb +1 -1
- data/test/unit/tags/page_files_test.rb +1 -1
- data/test/unit/tags/page_integer_test.rb +1 -1
- data/test/unit/tags/page_markdown_test.rb +1 -1
- data/test/unit/tags/page_rich_text_test.rb +1 -1
- data/test/unit/tags/page_string_test.rb +1 -1
- data/test/unit/tags/page_text_test.rb +1 -1
- data/test/unit/tags/partial_test.rb +1 -1
- data/test/unit/tags/snippet_test.rb +1 -1
- data/test/unit/view_methods_test.rb +1 -1
- metadata +28 -12
- data/db/cms_fixtures/sample-site/pages/index/_index.yml +0 -2
- data/db/cms_fixtures/sample-site/snippets/default/_default.yml +0 -1
- data/lib/comfortable_mexican_sofa/fixtures.rb +0 -289
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../test_helper'
|
|
4
|
+
|
|
5
|
+
class FixtureSnippetsTest < ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
def test_creation
|
|
8
|
+
Cms::Snippet.delete_all
|
|
9
|
+
|
|
10
|
+
assert_difference 'Cms::Snippet.count' do
|
|
11
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site').import!
|
|
12
|
+
assert snippet = Cms::Snippet.last
|
|
13
|
+
assert_equal 'default', snippet.identifier
|
|
14
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
|
15
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
16
|
+
assert_equal 2, snippet.categories.count
|
|
17
|
+
assert_equal ['category_a', 'category_b'], snippet.categories.map{|c| c.label}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_update
|
|
22
|
+
snippet = cms_snippets(:default)
|
|
23
|
+
snippet.update_column(:updated_at, 10.years.ago)
|
|
24
|
+
assert_equal 'default', snippet.identifier
|
|
25
|
+
assert_equal 'Default Snippet', snippet.label
|
|
26
|
+
assert_equal 'default_snippet_content', snippet.content
|
|
27
|
+
|
|
28
|
+
assert_no_difference 'Cms::Snippet.count' do
|
|
29
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site').import!
|
|
30
|
+
snippet.reload
|
|
31
|
+
assert_equal 'default', snippet.identifier
|
|
32
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
|
33
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_delete
|
|
38
|
+
old_snippet = cms_snippets(:default)
|
|
39
|
+
old_snippet.update_column(:identifier, 'old')
|
|
40
|
+
|
|
41
|
+
assert_no_difference 'Cms::Snippet.count' do
|
|
42
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site').import!
|
|
43
|
+
assert snippet = Cms::Snippet.last
|
|
44
|
+
assert_equal 'default', snippet.identifier
|
|
45
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
|
46
|
+
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
47
|
+
|
|
48
|
+
assert_nil Cms::Snippet.where(:id => old_snippet.id).first
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_update_ignoring
|
|
53
|
+
snippet = cms_snippets(:default)
|
|
54
|
+
snippet_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'snippets', 'default')
|
|
55
|
+
attr_file_path = File.join(snippet_path, 'attributes.yml')
|
|
56
|
+
content_file_path = File.join(snippet_path, 'content.html')
|
|
57
|
+
|
|
58
|
+
assert snippet.updated_at >= File.mtime(attr_file_path)
|
|
59
|
+
assert snippet.updated_at >= File.mtime(content_file_path)
|
|
60
|
+
|
|
61
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site').import!
|
|
62
|
+
snippet.reload
|
|
63
|
+
assert_equal 'default', snippet.identifier
|
|
64
|
+
assert_equal 'Default Snippet', snippet.label
|
|
65
|
+
assert_equal 'default_snippet_content', snippet.content
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_update_force
|
|
69
|
+
snippet = cms_snippets(:default)
|
|
70
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site').import!
|
|
71
|
+
snippet.reload
|
|
72
|
+
assert_equal 'Default Snippet', snippet.label
|
|
73
|
+
|
|
74
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new('sample-site', 'default-site', :forced).import!
|
|
75
|
+
snippet.reload
|
|
76
|
+
assert_equal 'Default Fixture Snippet', snippet.label
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_export
|
|
80
|
+
cms_categories(:default).categorizations.create!(
|
|
81
|
+
:categorized => cms_snippets(:default)
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
host_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'test-site')
|
|
85
|
+
attr_path = File.join(host_path, 'snippets/default/attributes.yml')
|
|
86
|
+
content_path = File.join(host_path, 'snippets/default/content.html')
|
|
87
|
+
|
|
88
|
+
ComfortableMexicanSofa::Fixture::Snippet::Exporter.new('default-site', 'test-site').export!
|
|
89
|
+
|
|
90
|
+
assert File.exists?(attr_path)
|
|
91
|
+
assert File.exists?(content_path)
|
|
92
|
+
assert_equal ({
|
|
93
|
+
'label' => 'Default Snippet',
|
|
94
|
+
'categories' => ['Default']
|
|
95
|
+
}), YAML.load_file(attr_path)
|
|
96
|
+
assert_equal cms_snippets(:default).content, IO.read(content_path)
|
|
97
|
+
|
|
98
|
+
FileUtils.rm_rf(host_path)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
data/test/unit/fixtures_test.rb
CHANGED
|
@@ -1,232 +1,9 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative '../test_helper'
|
|
4
4
|
|
|
5
5
|
class FixturesTest < ActiveSupport::TestCase
|
|
6
6
|
|
|
7
|
-
def test_import_layouts_creating
|
|
8
|
-
Cms::Layout.delete_all
|
|
9
|
-
|
|
10
|
-
assert_difference 'Cms::Layout.count', 2 do
|
|
11
|
-
ComfortableMexicanSofa::Fixtures.import_layouts('default-site', 'sample-site')
|
|
12
|
-
|
|
13
|
-
assert layout = Cms::Layout.find_by_identifier('default')
|
|
14
|
-
assert_equal 'Default Fixture Layout', layout.label
|
|
15
|
-
assert_equal "<html>\n <body>\n {{ cms:page:content }}\n </body>\n</html>", layout.content
|
|
16
|
-
assert_equal 'body{color: red}', layout.css
|
|
17
|
-
assert_equal '// default js', layout.js
|
|
18
|
-
|
|
19
|
-
assert nested_layout = Cms::Layout.find_by_identifier('nested')
|
|
20
|
-
assert_equal layout, nested_layout.parent
|
|
21
|
-
assert_equal 'Default Fixture Nested Layout', nested_layout.label
|
|
22
|
-
assert_equal "<div class='left'> {{ cms:page:left }} </div>\n<div class='right'> {{ cms:page:right }} </div>", nested_layout.content
|
|
23
|
-
assert_equal 'div{float:left}', nested_layout.css
|
|
24
|
-
assert_equal '// nested js', nested_layout.js
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_import_layouts_updating_and_deleting
|
|
29
|
-
layout = cms_layouts(:default)
|
|
30
|
-
nested_layout = cms_layouts(:nested)
|
|
31
|
-
child_layout = cms_layouts(:child)
|
|
32
|
-
layout.update_column(:updated_at, 10.years.ago)
|
|
33
|
-
nested_layout.update_column(:updated_at, 10.years.ago)
|
|
34
|
-
child_layout.update_column(:updated_at, 10.years.ago)
|
|
35
|
-
|
|
36
|
-
assert_difference 'Cms::Layout.count', -1 do
|
|
37
|
-
ComfortableMexicanSofa::Fixtures.import_layouts('default-site', 'sample-site')
|
|
38
|
-
|
|
39
|
-
layout.reload
|
|
40
|
-
assert_equal 'Default Fixture Layout', layout.label
|
|
41
|
-
assert_equal "<html>\n <body>\n {{ cms:page:content }}\n </body>\n</html>", layout.content
|
|
42
|
-
assert_equal 'body{color: red}', layout.css
|
|
43
|
-
assert_equal '// default js', layout.js
|
|
44
|
-
assert_equal 0, layout.position
|
|
45
|
-
|
|
46
|
-
nested_layout.reload
|
|
47
|
-
assert_equal layout, nested_layout.parent
|
|
48
|
-
assert_equal 'Default Fixture Nested Layout', nested_layout.label
|
|
49
|
-
assert_equal "<div class='left'> {{ cms:page:left }} </div>\n<div class='right'> {{ cms:page:right }} </div>", nested_layout.content
|
|
50
|
-
assert_equal 'div{float:left}', nested_layout.css
|
|
51
|
-
assert_equal '// nested js', nested_layout.js
|
|
52
|
-
assert_equal 42, nested_layout.position
|
|
53
|
-
|
|
54
|
-
assert_nil Cms::Layout.find_by_identifier('child')
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def test_import_layouts_ignoring
|
|
59
|
-
layout = cms_layouts(:default)
|
|
60
|
-
layout_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'layouts', 'default')
|
|
61
|
-
attr_file_path = File.join(layout_path, '_default.yml')
|
|
62
|
-
content_file_path = File.join(layout_path, 'content.html')
|
|
63
|
-
css_file_path = File.join(layout_path, 'css.css')
|
|
64
|
-
js_file_path = File.join(layout_path, 'js.js')
|
|
65
|
-
|
|
66
|
-
assert layout.updated_at >= File.mtime(attr_file_path)
|
|
67
|
-
assert layout.updated_at >= File.mtime(content_file_path)
|
|
68
|
-
assert layout.updated_at >= File.mtime(css_file_path)
|
|
69
|
-
assert layout.updated_at >= File.mtime(js_file_path)
|
|
70
|
-
|
|
71
|
-
ComfortableMexicanSofa::Fixtures.import_layouts('default-site', 'sample-site')
|
|
72
|
-
layout.reload
|
|
73
|
-
assert_equal 'default', layout.identifier
|
|
74
|
-
assert_equal 'Default Layout', layout.label
|
|
75
|
-
assert_equal "{{cms:field:default_field_text:text}}\nlayout_content_a\n{{cms:page:default_page_text:text}}\nlayout_content_b\n{{cms:snippet:default}}\nlayout_content_c", layout.content
|
|
76
|
-
assert_equal 'default_css', layout.css
|
|
77
|
-
assert_equal 'default_js', layout.js
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def test_import_pages_creating
|
|
81
|
-
Cms::Page.delete_all
|
|
82
|
-
|
|
83
|
-
layout = cms_layouts(:default)
|
|
84
|
-
layout.update_column(:content, '<html>{{cms:page:content}}</html>')
|
|
85
|
-
|
|
86
|
-
nested = cms_layouts(:nested)
|
|
87
|
-
nested.update_column(:content, '<html>{{cms:page:left}}<br/>{{cms:page:right}}</html>')
|
|
88
|
-
|
|
89
|
-
assert_difference 'Cms::Page.count', 2 do
|
|
90
|
-
ComfortableMexicanSofa::Fixtures.import_pages('default-site', 'sample-site')
|
|
91
|
-
|
|
92
|
-
assert page = Cms::Page.find_by_full_path('/')
|
|
93
|
-
assert_equal layout, page.layout
|
|
94
|
-
assert_equal 'index', page.slug
|
|
95
|
-
assert_equal "<html>Home Page Fixture Contént\ndefault_snippet_content</html>", page.content
|
|
96
|
-
assert_equal 0, page.position
|
|
97
|
-
assert page.is_published?
|
|
98
|
-
|
|
99
|
-
assert child_page = Cms::Page.find_by_full_path('/child')
|
|
100
|
-
assert_equal page, child_page.parent
|
|
101
|
-
assert_equal nested, child_page.layout
|
|
102
|
-
assert_equal 'child', child_page.slug
|
|
103
|
-
assert_equal '<html>Child Page Left Fixture Content<br/>Child Page Right Fixture Content</html>', child_page.content
|
|
104
|
-
assert_equal 42, child_page.position
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def test_import_pages_updating_and_deleting
|
|
109
|
-
page = cms_pages(:default)
|
|
110
|
-
page.update_column(:updated_at, 10.years.ago)
|
|
111
|
-
assert_equal 'Default Page', page.label
|
|
112
|
-
|
|
113
|
-
child = cms_pages(:child)
|
|
114
|
-
child.update_column(:slug, 'old')
|
|
115
|
-
|
|
116
|
-
assert_no_difference 'Cms::Page.count' do
|
|
117
|
-
ComfortableMexicanSofa::Fixtures.import_pages('default-site', 'sample-site')
|
|
118
|
-
|
|
119
|
-
page.reload
|
|
120
|
-
assert_equal 'Home Fixture Page', page.label
|
|
121
|
-
|
|
122
|
-
assert_nil Cms::Page.find_by_slug('old')
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_import_pages_ignoring
|
|
127
|
-
Cms::Page.destroy_all
|
|
128
|
-
|
|
129
|
-
page = cms_sites(:default).pages.create!(
|
|
130
|
-
:label => 'Test',
|
|
131
|
-
:layout => cms_layouts(:default),
|
|
132
|
-
:blocks_attributes => [ { :identifier => 'content', :content => 'test content' } ]
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
page_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'pages', 'index')
|
|
136
|
-
attr_file_path = File.join(page_path, '_index.yml')
|
|
137
|
-
content_file_path = File.join(page_path, 'content.html')
|
|
138
|
-
|
|
139
|
-
assert page.updated_at >= File.mtime(attr_file_path)
|
|
140
|
-
assert page.updated_at >= File.mtime(content_file_path)
|
|
141
|
-
|
|
142
|
-
ComfortableMexicanSofa::Fixtures.import_pages('default-site', 'sample-site')
|
|
143
|
-
page.reload
|
|
144
|
-
|
|
145
|
-
assert_equal nil, page.slug
|
|
146
|
-
assert_equal 'Test', page.label
|
|
147
|
-
block = page.blocks.where(:identifier => 'content').first
|
|
148
|
-
assert_equal 'test content', block.content
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def test_import_pages_removing_deleted_blocks
|
|
152
|
-
Cms::Page.destroy_all
|
|
153
|
-
|
|
154
|
-
page = cms_sites(:default).pages.create!(
|
|
155
|
-
:label => 'Test',
|
|
156
|
-
:layout => cms_layouts(:default),
|
|
157
|
-
:blocks_attributes => [ { :identifier => 'to_delete', :content => 'test content' } ]
|
|
158
|
-
)
|
|
159
|
-
page.update_column(:updated_at, 10.years.ago)
|
|
160
|
-
|
|
161
|
-
ComfortableMexicanSofa::Fixtures.import_pages('default-site', 'sample-site')
|
|
162
|
-
page.reload
|
|
163
|
-
|
|
164
|
-
block = page.blocks.where(:identifier => 'content').first
|
|
165
|
-
assert_equal "Home Page Fixture Contént\n{{ cms:snippet:default }}", block.content
|
|
166
|
-
|
|
167
|
-
block = page.blocks.where(:identifier => 'to_delete').first
|
|
168
|
-
assert_equal nil, block.content
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
def test_import_snippets_creating
|
|
172
|
-
Cms::Snippet.delete_all
|
|
173
|
-
|
|
174
|
-
assert_difference 'Cms::Snippet.count' do
|
|
175
|
-
ComfortableMexicanSofa::Fixtures.import_snippets('default-site', 'sample-site')
|
|
176
|
-
assert snippet = Cms::Snippet.last
|
|
177
|
-
assert_equal 'default', snippet.identifier
|
|
178
|
-
assert_equal 'Default Fixture Snippet', snippet.label
|
|
179
|
-
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def test_import_snippets_updating
|
|
184
|
-
snippet = cms_snippets(:default)
|
|
185
|
-
snippet.update_column(:updated_at, 10.years.ago)
|
|
186
|
-
assert_equal 'default', snippet.identifier
|
|
187
|
-
assert_equal 'Default Snippet', snippet.label
|
|
188
|
-
assert_equal 'default_snippet_content', snippet.content
|
|
189
|
-
|
|
190
|
-
assert_no_difference 'Cms::Snippet.count' do
|
|
191
|
-
ComfortableMexicanSofa::Fixtures.import_snippets('default-site', 'sample-site')
|
|
192
|
-
snippet.reload
|
|
193
|
-
assert_equal 'default', snippet.identifier
|
|
194
|
-
assert_equal 'Default Fixture Snippet', snippet.label
|
|
195
|
-
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def test_import_snippets_deleting
|
|
200
|
-
snippet = cms_snippets(:default)
|
|
201
|
-
snippet.update_column(:identifier, 'old')
|
|
202
|
-
|
|
203
|
-
assert_no_difference 'Cms::Snippet.count' do
|
|
204
|
-
ComfortableMexicanSofa::Fixtures.import_snippets('default-site', 'sample-site')
|
|
205
|
-
assert snippet = Cms::Snippet.last
|
|
206
|
-
assert_equal 'default', snippet.identifier
|
|
207
|
-
assert_equal 'Default Fixture Snippet', snippet.label
|
|
208
|
-
assert_equal 'Fixture Content for Default Snippet', snippet.content
|
|
209
|
-
|
|
210
|
-
assert_nil Cms::Snippet.find_by_identifier('old')
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def test_import_snippets_ignoring
|
|
215
|
-
snippet = cms_snippets(:default)
|
|
216
|
-
snippet_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'sample-site', 'snippets', 'default')
|
|
217
|
-
attr_file_path = File.join(snippet_path, '_default.yml')
|
|
218
|
-
content_file_path = File.join(snippet_path, 'content.html')
|
|
219
|
-
|
|
220
|
-
assert snippet.updated_at >= File.mtime(attr_file_path)
|
|
221
|
-
assert snippet.updated_at >= File.mtime(content_file_path)
|
|
222
|
-
|
|
223
|
-
ComfortableMexicanSofa::Fixtures.import_snippets('default-site', 'sample-site')
|
|
224
|
-
snippet.reload
|
|
225
|
-
assert_equal 'default', snippet.identifier
|
|
226
|
-
assert_equal 'Default Snippet', snippet.label
|
|
227
|
-
assert_equal 'default_snippet_content', snippet.content
|
|
228
|
-
end
|
|
229
|
-
|
|
230
7
|
def test_import_all
|
|
231
8
|
Cms::Page.destroy_all
|
|
232
9
|
Cms::Layout.destroy_all
|
|
@@ -235,7 +12,7 @@ class FixturesTest < ActiveSupport::TestCase
|
|
|
235
12
|
assert_difference 'Cms::Layout.count', 2 do
|
|
236
13
|
assert_difference 'Cms::Page.count', 2 do
|
|
237
14
|
assert_difference 'Cms::Snippet.count', 1 do
|
|
238
|
-
ComfortableMexicanSofa::
|
|
15
|
+
ComfortableMexicanSofa::Fixture::Importer.new('sample-site', 'default-site').import!
|
|
239
16
|
end
|
|
240
17
|
end
|
|
241
18
|
end
|
|
@@ -244,114 +21,23 @@ class FixturesTest < ActiveSupport::TestCase
|
|
|
244
21
|
def test_import_all_with_no_site
|
|
245
22
|
cms_sites(:default).destroy
|
|
246
23
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
assert_difference 'Cms::Page.count', 2 do
|
|
250
|
-
assert_difference 'Cms::Snippet.count', 1 do
|
|
251
|
-
ComfortableMexicanSofa::Fixtures.import_all('default-site', 'sample-site')
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
end
|
|
24
|
+
assert_exception_raised ActiveRecord::RecordNotFound do
|
|
25
|
+
ComfortableMexicanSofa::Fixture::Importer.new('sample-site', 'default-site').import!
|
|
255
26
|
end
|
|
256
27
|
end
|
|
257
28
|
|
|
258
|
-
def
|
|
259
|
-
host_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'test-site')
|
|
260
|
-
layout_1_attr_path = File.join(host_path, 'layouts/nested/_nested.yml')
|
|
261
|
-
layout_1_content_path = File.join(host_path, 'layouts/nested/content.html')
|
|
262
|
-
layout_1_css_path = File.join(host_path, 'layouts/nested/css.css')
|
|
263
|
-
layout_1_js_path = File.join(host_path, 'layouts/nested/js.js')
|
|
264
|
-
layout_2_attr_path = File.join(host_path, 'layouts/nested/child/_child.yml')
|
|
265
|
-
layout_2_content_path = File.join(host_path, 'layouts/nested/child/content.html')
|
|
266
|
-
layout_2_css_path = File.join(host_path, 'layouts/nested/child/css.css')
|
|
267
|
-
layout_2_js_path = File.join(host_path, 'layouts/nested/child/js.js')
|
|
268
|
-
|
|
269
|
-
ComfortableMexicanSofa::Fixtures.export_layouts('default-site', 'test-site')
|
|
270
|
-
|
|
271
|
-
assert File.exists?(layout_1_attr_path)
|
|
272
|
-
assert File.exists?(layout_1_content_path)
|
|
273
|
-
assert File.exists?(layout_1_css_path)
|
|
274
|
-
assert File.exists?(layout_1_js_path)
|
|
275
|
-
|
|
276
|
-
assert File.exists?(layout_2_attr_path)
|
|
277
|
-
assert File.exists?(layout_2_content_path)
|
|
278
|
-
assert File.exists?(layout_2_css_path)
|
|
279
|
-
assert File.exists?(layout_2_js_path)
|
|
280
|
-
|
|
281
|
-
assert_equal ({
|
|
282
|
-
'label' => 'Nested Layout',
|
|
283
|
-
'app_layout' => nil,
|
|
284
|
-
'parent' => nil,
|
|
285
|
-
'position' => 0
|
|
286
|
-
}), YAML.load_file(layout_1_attr_path)
|
|
287
|
-
assert_equal cms_layouts(:nested).content, IO.read(layout_1_content_path)
|
|
288
|
-
assert_equal cms_layouts(:nested).css, IO.read(layout_1_css_path)
|
|
289
|
-
assert_equal cms_layouts(:nested).js, IO.read(layout_1_js_path)
|
|
290
|
-
|
|
291
|
-
assert_equal ({
|
|
292
|
-
'label' => 'Child Layout',
|
|
293
|
-
'app_layout' => nil,
|
|
294
|
-
'parent' => 'nested',
|
|
295
|
-
'position' => 0
|
|
296
|
-
}), YAML.load_file(layout_2_attr_path)
|
|
297
|
-
assert_equal cms_layouts(:child).content, IO.read(layout_2_content_path)
|
|
298
|
-
assert_equal cms_layouts(:child).css, IO.read(layout_2_css_path)
|
|
299
|
-
assert_equal cms_layouts(:child).js, IO.read(layout_2_js_path)
|
|
300
|
-
|
|
301
|
-
FileUtils.rm_rf(host_path)
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
def test_export_pages
|
|
29
|
+
def test_export_all
|
|
305
30
|
host_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'test-site')
|
|
306
|
-
|
|
307
|
-
page_1_block_a_path = File.join(host_path, 'pages/index/default_field_text.html')
|
|
308
|
-
page_1_block_b_path = File.join(host_path, 'pages/index/default_page_text.html')
|
|
309
|
-
page_2_attr_path = File.join(host_path, 'pages/index/child-page/_child-page.yml')
|
|
310
|
-
|
|
311
|
-
ComfortableMexicanSofa::Fixtures.export_pages('default-site', 'test-site')
|
|
312
|
-
|
|
313
|
-
assert_equal ({
|
|
314
|
-
'label' => 'Default Page',
|
|
315
|
-
'layout' => 'default',
|
|
316
|
-
'parent' => nil,
|
|
317
|
-
'target_page' => nil,
|
|
318
|
-
'is_published' => true,
|
|
319
|
-
'position' => 0
|
|
320
|
-
}), YAML.load_file(page_1_attr_path)
|
|
321
|
-
assert_equal cms_blocks(:default_field_text).content, IO.read(page_1_block_a_path)
|
|
322
|
-
assert_equal cms_blocks(:default_page_text).content, IO.read(page_1_block_b_path)
|
|
323
|
-
|
|
324
|
-
assert_equal ({
|
|
325
|
-
'label' => 'Child Page',
|
|
326
|
-
'layout' => 'default',
|
|
327
|
-
'parent' => 'index',
|
|
328
|
-
'target_page' => nil,
|
|
329
|
-
'is_published' => true,
|
|
330
|
-
'position' => 0
|
|
331
|
-
}), YAML.load_file(page_2_attr_path)
|
|
332
|
-
|
|
31
|
+
ComfortableMexicanSofa::Fixture::Exporter.new('default-site', 'test-site').export!
|
|
333
32
|
FileUtils.rm_rf(host_path)
|
|
334
33
|
end
|
|
335
34
|
|
|
336
|
-
def
|
|
337
|
-
|
|
338
|
-
attr_path = File.join(host_path, 'snippets/default/_default.yml')
|
|
339
|
-
content_path = File.join(host_path, 'snippets/default/content.html')
|
|
340
|
-
|
|
341
|
-
ComfortableMexicanSofa::Fixtures.export_snippets('default-site', 'test-site')
|
|
342
|
-
|
|
343
|
-
assert File.exists?(attr_path)
|
|
344
|
-
assert File.exists?(content_path)
|
|
345
|
-
assert_equal ({'label' => 'Default Snippet'}), YAML.load_file(attr_path)
|
|
346
|
-
assert_equal cms_snippets(:default).content, IO.read(content_path)
|
|
35
|
+
def test_import_all_with_no_site
|
|
36
|
+
cms_sites(:default).destroy
|
|
347
37
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
def test_export_all
|
|
352
|
-
host_path = File.join(ComfortableMexicanSofa.config.fixtures_path, 'test-site')
|
|
353
|
-
ComfortableMexicanSofa::Fixtures.export_all('default-site', 'test-site')
|
|
354
|
-
FileUtils.rm_rf(host_path)
|
|
38
|
+
assert_exception_raised ActiveRecord::RecordNotFound do
|
|
39
|
+
ComfortableMexicanSofa::Fixture::Exporter.new('sample-site', 'default-site').export!
|
|
40
|
+
end
|
|
355
41
|
end
|
|
356
42
|
|
|
357
43
|
end
|