comfy_blog 2.0.4 → 2.0.5
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.
- checksums.yaml +5 -5
- data/.travis.yml +12 -10
- data/Gemfile +15 -8
- data/LICENSE +1 -1
- data/README.md +5 -5
- data/app/views/comfy/admin/blog/posts/edit.html.haml +1 -1
- data/app/views/comfy/admin/blog/posts/new.html.haml +1 -1
- data/comfy_blog.gemspec +5 -3
- data/config/locales/ca.yml +38 -0
- data/config/locales/fr.yml +22 -22
- data/config/locales/gr.yml +38 -0
- data/config/locales/tr.yml +21 -21
- data/config/locales/zh-CN.yml +22 -22
- data/config/locales/zh-TW.yml +22 -22
- data/lib/comfy_blog/version.rb +1 -1
- metadata +7 -20
- data/doc/preview.jpg +0 -0
- data/test/controllers/comfy/admin/blog/posts_controller_test.rb +0 -153
- data/test/controllers/comfy/admin/blog/revisions/post_controller_test.rb +0 -67
- data/test/controllers/comfy/blog/posts_controller_test.rb +0 -95
- data/test/fixtures/comfy/blog/posts.yml +0 -9
- data/test/fixtures/comfy/cms/layouts.yml +0 -10
- data/test/fixtures/comfy/cms/revisions.yml +0 -7
- data/test/fixtures/comfy/cms/sites.yml +0 -4
- data/test/fixtures/generators/blog/routes.rb +0 -5
- data/test/gemfiles/Gemfile.rails.5.2 +0 -13
- data/test/generators/blog_generator_test.rb +0 -20
- data/test/integration/i18n_test.rb +0 -38
- data/test/lib/configuration_test.rb +0 -17
- data/test/models/posts_test.rb +0 -103
- data/test/test_helper.rb +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ced1c8ddc66db697dd6df8d669e2fc6a32841a667cd63b323cebe1d466f15b7d
|
4
|
+
data.tar.gz: 2b97e015ac0480fb61bd5779e18e5d77d31be90c9cb562a7b779348199b9a579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c113c5b36b83fed58049f41cb8f990c20e2b752bac862069740456ce46e7bbd58e2b4e58876ce57f0d39f80b14fde625de106563595f237fb30acb063a9329e
|
7
|
+
data.tar.gz: 7b9c2bbffe4f9e29f908b100522b8433309f112eb5bb0e8ad41e68a5e335ec760b65f06fd17e0ee96f5d1cb29479f82474274fd275489025a3406938c62be199
|
data/.travis.yml
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2.9
|
4
|
+
- 2.3.6
|
5
|
+
- 2.4.3
|
6
|
+
- 2.5.0
|
7
|
+
gemfile:
|
8
|
+
- test/gemfiles/5.2.gemfile
|
9
|
+
branches:
|
10
|
+
only:
|
11
|
+
- master
|
2
12
|
before_install:
|
3
|
-
- gem
|
13
|
+
- gem update --system
|
14
|
+
- gem update bundler
|
4
15
|
before_script:
|
5
16
|
- rake db:migrate
|
6
17
|
script:
|
7
18
|
- bundle exec rake test
|
8
19
|
- bundle exec rubocop
|
9
|
-
rvm:
|
10
|
-
- 2.2.7
|
11
|
-
- 2.3.5
|
12
|
-
- 2.4.2
|
13
|
-
gemfile:
|
14
|
-
- test/gemfiles/Gemfile.rails.5.2
|
15
|
-
branches:
|
16
|
-
only:
|
17
|
-
- master
|
data/Gemfile
CHANGED
@@ -2,17 +2,24 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
5
|
+
# CMS has dependency on prerelease and Bundler chokes on it
|
6
|
+
gem "rails", "~> 5.2.0.rc1"
|
7
|
+
|
8
|
+
group :development, :test do
|
9
|
+
gem "byebug", "~> 10.0.0", platforms: %i[mri mingw x64_mingw]
|
10
|
+
gem "kaminari", "~> 1.1.1"
|
11
|
+
gem "puma", "~> 3.11.2"
|
12
|
+
gem "rubocop", "~> 0.52.1", require: false
|
13
|
+
gem "sqlite3", "~> 1.3.13"
|
14
|
+
end
|
6
15
|
|
7
16
|
group :development do
|
8
|
-
gem "listen"
|
9
|
-
gem "
|
10
|
-
gem "web-console"
|
17
|
+
gem "listen", "~> 3.1.5"
|
18
|
+
gem "web-console", "~> 3.5.1"
|
11
19
|
end
|
12
20
|
|
13
21
|
group :test do
|
14
|
-
gem "coveralls",
|
15
|
-
gem "mocha", require: false
|
16
|
-
gem "rails-controller-testing"
|
17
|
-
gem "sqlite3"
|
22
|
+
gem "coveralls", "~> 0.8.21", require: false
|
23
|
+
gem "mocha", "~> 1.3.0", require: false
|
24
|
+
gem "rails-controller-testing", "~> 1.0.2"
|
18
25
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Make sure that you have [ComfortableMexicanSofa](https://github.com/comfy/comfor
|
|
19
19
|
Add gem definition to your Gemfile:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem
|
22
|
+
gem "comfy_blog", "~> 2.0.0"
|
23
23
|
```
|
24
24
|
|
25
25
|
Then from the Rails project's root run:
|
@@ -31,14 +31,14 @@ Then from the Rails project's root run:
|
|
31
31
|
Take a look inside your `config/routes.rb` file and you should see following lines there:
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
comfy_route :blog_admin, path:
|
35
|
-
comfy_route :blog, path:
|
34
|
+
comfy_route :blog_admin, path: "admin"
|
35
|
+
comfy_route :blog, path: "blog"
|
36
36
|
```
|
37
37
|
|
38
38
|
You should also find view templates in `/app/views/blog` folder. Feel free to adjust them as you see fit.
|
39
39
|
|
40
|
-

|
41
41
|
|
42
42
|
---
|
43
43
|
|
44
|
-
Copyright 2009-
|
44
|
+
Copyright 2009-2018 Oleg Khabarov
|
data/comfy_blog.gemspec
CHANGED
@@ -13,11 +13,13 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = "Simple Blog Engine for ComfortableMexicanSofa"
|
14
14
|
s.license = "MIT"
|
15
15
|
|
16
|
-
s.files
|
17
|
-
|
16
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|doc)/})
|
18
|
+
end
|
19
|
+
|
18
20
|
s.require_paths = ["lib"]
|
19
21
|
|
20
22
|
s.required_ruby_version = ">= 2.2.2"
|
21
23
|
|
22
|
-
s.add_dependency "comfortable_mexican_sofa", ">= 2.0.
|
24
|
+
s.add_dependency "comfortable_mexican_sofa", ">= 2.0.10"
|
23
25
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
ca:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
comfy/blog/post: Entrada
|
5
|
+
attributes:
|
6
|
+
comfy/blog/post:
|
7
|
+
title: Títol
|
8
|
+
slug: Ruta
|
9
|
+
published_at: Publicat
|
10
|
+
is_published: Publicada
|
11
|
+
|
12
|
+
comfy:
|
13
|
+
admin:
|
14
|
+
cms:
|
15
|
+
base:
|
16
|
+
posts: Entrada del blog
|
17
|
+
blog:
|
18
|
+
posts:
|
19
|
+
created: S'ha creat l'entrada del blog
|
20
|
+
create_failure: No s'ha pogut crear l'entrada del blog
|
21
|
+
updated: S'ha actualitzat l'entrada del blog
|
22
|
+
update_failure: No s'ha pogut actualitzar l'entrada del blog
|
23
|
+
deleted: S'ha esborrat l'entrada del blog
|
24
|
+
not_found: L'entrada del blog no s'ha pogut trobar
|
25
|
+
index:
|
26
|
+
title: Entrada del blog
|
27
|
+
new_link: S'ha creat una nova entrada al blog
|
28
|
+
edit: Edita
|
29
|
+
delete: Esborra
|
30
|
+
are_you_sure: Esteu segur de que voleu esborrar aquesta entrada?
|
31
|
+
new:
|
32
|
+
title: Nova entrada del blog
|
33
|
+
edit:
|
34
|
+
title: Edita l'entrada del blog
|
35
|
+
form:
|
36
|
+
create: Crea una entrada
|
37
|
+
update: Actualitza una entrada
|
38
|
+
cancel: Cancel.la
|
data/config/locales/fr.yml
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
fr:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
comfy/blog/post:
|
4
|
+
comfy/blog/post: Article
|
5
5
|
attributes:
|
6
6
|
comfy/blog/post:
|
7
|
-
title:
|
8
|
-
slug:
|
9
|
-
published_at:
|
10
|
-
is_published:
|
7
|
+
title: Titre
|
8
|
+
slug: Identifiant
|
9
|
+
published_at: Publié le
|
10
|
+
is_published: Publié
|
11
11
|
|
12
12
|
comfy:
|
13
13
|
admin:
|
14
14
|
cms:
|
15
15
|
base:
|
16
|
-
posts: Blog
|
16
|
+
posts: Articles de Blog
|
17
17
|
blog:
|
18
18
|
posts:
|
19
|
-
created: Blog
|
20
|
-
create_failure:
|
21
|
-
updated: Blog
|
22
|
-
update_failure:
|
23
|
-
deleted: Blog
|
24
|
-
not_found:
|
19
|
+
created: Article de Blog créé
|
20
|
+
create_failure: Échec de la création de l'Article de Blog
|
21
|
+
updated: Article de Blog modifié
|
22
|
+
update_failure: Échec de la modification de l'Article de Blog
|
23
|
+
deleted: Article de Blog supprimé
|
24
|
+
not_found: Article de Blog introuvable
|
25
25
|
index:
|
26
|
-
title: Blog
|
27
|
-
new_link:
|
28
|
-
edit:
|
29
|
-
delete:
|
30
|
-
are_you_sure:
|
26
|
+
title: Articles de Blog
|
27
|
+
new_link: Nouvel Article de Blog
|
28
|
+
edit: Modifier
|
29
|
+
delete: Supprimer
|
30
|
+
are_you_sure: Êtes-vous sûr ?
|
31
31
|
new:
|
32
|
-
title:
|
32
|
+
title: Nouvel Article de Blog
|
33
33
|
edit:
|
34
|
-
title:
|
34
|
+
title: Modifier l'Article de Blog
|
35
35
|
form:
|
36
|
-
create:
|
37
|
-
update:
|
38
|
-
cancel:
|
36
|
+
create: Créer l'Article
|
37
|
+
update: Modifier l'Article
|
38
|
+
cancel: Annuler
|
@@ -0,0 +1,38 @@
|
|
1
|
+
gr:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
comfy/blog/post: Δημοσίευση
|
5
|
+
attributes:
|
6
|
+
comfy/blog/post:
|
7
|
+
title: Τίτλος
|
8
|
+
slug: Slug
|
9
|
+
published_at: Δημοσιεύθηκε στο
|
10
|
+
is_published: Έχει Δημοσιευθεί
|
11
|
+
|
12
|
+
comfy:
|
13
|
+
admin:
|
14
|
+
cms:
|
15
|
+
base:
|
16
|
+
posts: Δημοσιεύσεις του Blog
|
17
|
+
blog:
|
18
|
+
posts:
|
19
|
+
created: Η Δημοσιεύση δημιουργήθηκε
|
20
|
+
create_failure: Αποτυχία δημιουργίας της δημοσίευσης
|
21
|
+
updated: Η Δημοσίευση ενημερώθηκε
|
22
|
+
update_failure: Αποτυχία ενημέρωσης της δημοσίευσης
|
23
|
+
deleted: Η Δημοσίεση διαγράφηκε
|
24
|
+
not_found: Η Δημοσίευση δεν βρέθηκε
|
25
|
+
index:
|
26
|
+
title: Δημοσιεύσεις του Blog
|
27
|
+
new_link: Νέα Δημοσίευση
|
28
|
+
edit: Επεξεργασία
|
29
|
+
delete: Διαγραφή
|
30
|
+
are_you_sure: Είστε σίγουροι;
|
31
|
+
new:
|
32
|
+
title: Νέα Δημοσίευση στο Blog
|
33
|
+
edit:
|
34
|
+
title: Επεξεργασία στο Blog
|
35
|
+
form:
|
36
|
+
create: Δημιουργία Δημοσίευσης
|
37
|
+
update: Ενημέρωση Δημοσίευσης
|
38
|
+
cancel: Ακύρωση
|
data/config/locales/tr.yml
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
tr:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
comfy/blog/post:
|
4
|
+
comfy/blog/post: Yazı
|
5
5
|
attributes:
|
6
6
|
comfy/blog/post:
|
7
|
-
title:
|
7
|
+
title: Başlık
|
8
8
|
slug: Slug
|
9
|
-
published_at:
|
10
|
-
is_published:
|
9
|
+
published_at: Yayınlanma tarihi
|
10
|
+
is_published: Yayında mı?
|
11
11
|
|
12
12
|
comfy:
|
13
13
|
admin:
|
14
14
|
cms:
|
15
15
|
base:
|
16
|
-
posts: Blog
|
16
|
+
posts: Blog Yazıları
|
17
17
|
blog:
|
18
18
|
posts:
|
19
|
-
created: Blog
|
20
|
-
create_failure:
|
21
|
-
updated: Blog
|
22
|
-
update_failure:
|
23
|
-
deleted: Blog
|
24
|
-
not_found: Blog
|
19
|
+
created: Blog Yazısı oluşturuldu
|
20
|
+
create_failure: Blog Yazıdı oluşturulamadı
|
21
|
+
updated: Blog Yazısı güncellendi
|
22
|
+
update_failure: Blog Yazısıp güncellenemedi
|
23
|
+
deleted: Blog Yazısı silindi
|
24
|
+
not_found: Blog Yazısı bulunamadı
|
25
25
|
index:
|
26
|
-
title: Blog
|
27
|
-
new_link:
|
28
|
-
edit:
|
29
|
-
delete:
|
30
|
-
are_you_sure:
|
26
|
+
title: Blog Yazıları
|
27
|
+
new_link: Yeni Blog Yazısı
|
28
|
+
edit: Düzenle
|
29
|
+
delete: Sil
|
30
|
+
are_you_sure: Emin misin?
|
31
31
|
new:
|
32
|
-
title:
|
32
|
+
title: Yeni Blog Yazısı
|
33
33
|
edit:
|
34
|
-
title:
|
34
|
+
title: Blog Yazısını Düzenle
|
35
35
|
form:
|
36
|
-
create:
|
37
|
-
update:
|
38
|
-
cancel:
|
36
|
+
create: Yazı Oluştur
|
37
|
+
update: Yazıyı Güncelle
|
38
|
+
cancel: İptal
|
data/config/locales/zh-CN.yml
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
zh-CN:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
comfy/blog/post:
|
4
|
+
comfy/blog/post: 博客
|
5
5
|
attributes:
|
6
6
|
comfy/blog/post:
|
7
|
-
title:
|
8
|
-
slug:
|
9
|
-
published_at:
|
10
|
-
is_published:
|
7
|
+
title: 标题
|
8
|
+
slug: 缩略路径
|
9
|
+
published_at: 发布于
|
10
|
+
is_published: 发布
|
11
11
|
|
12
12
|
comfy:
|
13
13
|
admin:
|
14
14
|
cms:
|
15
15
|
base:
|
16
|
-
posts:
|
16
|
+
posts: 博客
|
17
17
|
blog:
|
18
18
|
posts:
|
19
|
-
created:
|
20
|
-
create_failure:
|
21
|
-
updated:
|
22
|
-
update_failure:
|
23
|
-
deleted:
|
24
|
-
not_found:
|
19
|
+
created: 博客创建成功
|
20
|
+
create_failure: 博客创建失败
|
21
|
+
updated: 博客更新成功
|
22
|
+
update_failure: 博客更新失败
|
23
|
+
deleted: 博客删除成功
|
24
|
+
not_found: 博客不存在
|
25
25
|
index:
|
26
|
-
title:
|
27
|
-
new_link:
|
28
|
-
edit:
|
29
|
-
delete:
|
30
|
-
are_you_sure:
|
26
|
+
title: 博客
|
27
|
+
new_link: 创建新博客
|
28
|
+
edit: 编辑
|
29
|
+
delete: 删除
|
30
|
+
are_you_sure: 确定删除该博客吗?
|
31
31
|
new:
|
32
|
-
title:
|
32
|
+
title: 新博客
|
33
33
|
edit:
|
34
|
-
title:
|
34
|
+
title: 编辑博客
|
35
35
|
form:
|
36
|
-
create:
|
37
|
-
update:
|
38
|
-
cancel:
|
36
|
+
create: 创建博客
|
37
|
+
update: 更新博客
|
38
|
+
cancel: 取消
|
data/config/locales/zh-TW.yml
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
zh-TW:
|
2
2
|
activerecord:
|
3
3
|
models:
|
4
|
-
comfy/blog/post:
|
4
|
+
comfy/blog/post: 網誌
|
5
5
|
attributes:
|
6
6
|
comfy/blog/post:
|
7
|
-
title:
|
8
|
-
slug:
|
9
|
-
published_at:
|
10
|
-
is_published:
|
7
|
+
title: 標題
|
8
|
+
slug: 路徑名
|
9
|
+
published_at: 發佈于
|
10
|
+
is_published: 發佈
|
11
11
|
|
12
12
|
comfy:
|
13
13
|
admin:
|
14
14
|
cms:
|
15
15
|
base:
|
16
|
-
posts:
|
16
|
+
posts: 網誌
|
17
17
|
blog:
|
18
18
|
posts:
|
19
|
-
created:
|
20
|
-
create_failure:
|
21
|
-
updated:
|
22
|
-
update_failure:
|
23
|
-
deleted:
|
24
|
-
not_found:
|
19
|
+
created: 網誌創建成功
|
20
|
+
create_failure: 網誌創建失敗
|
21
|
+
updated: 網誌更新成功
|
22
|
+
update_failure: 網誌更新失敗
|
23
|
+
deleted: 網誌刪除成功
|
24
|
+
not_found: 網誌不存在
|
25
25
|
index:
|
26
|
-
title:
|
27
|
-
new_link:
|
28
|
-
edit:
|
29
|
-
delete:
|
30
|
-
are_you_sure:
|
26
|
+
title: 網誌
|
27
|
+
new_link: 創建新網誌
|
28
|
+
edit: 編輯
|
29
|
+
delete: 刪除
|
30
|
+
are_you_sure: 確定刪除該網誌嗎?
|
31
31
|
new:
|
32
|
-
title:
|
32
|
+
title: 新網誌
|
33
33
|
edit:
|
34
|
-
title:
|
34
|
+
title: 編輯網誌
|
35
35
|
form:
|
36
|
-
create:
|
37
|
-
update:
|
38
|
-
cancel:
|
36
|
+
create: 創建網誌
|
37
|
+
update: 跟新網誌
|
38
|
+
cancel: 取消
|
data/lib/comfy_blog/version.rb
CHANGED
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Khabarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-08 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.10
|
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.10
|
27
27
|
description: Simple Blog Engine for ComfortableMexicanSofa
|
28
28
|
email:
|
29
29
|
- oleg@khabarov.ca
|
@@ -70,12 +70,14 @@ files:
|
|
70
70
|
- config/environments/development.rb
|
71
71
|
- config/environments/test.rb
|
72
72
|
- config/initializers/comfy_blog.rb
|
73
|
+
- config/locales/ca.yml
|
73
74
|
- config/locales/cs.yml
|
74
75
|
- config/locales/da.yml
|
75
76
|
- config/locales/de.yml
|
76
77
|
- config/locales/en.yml
|
77
78
|
- config/locales/es.yml
|
78
79
|
- config/locales/fr.yml
|
80
|
+
- config/locales/gr.yml
|
79
81
|
- config/locales/it.yml
|
80
82
|
- config/locales/ja.yml
|
81
83
|
- config/locales/nb.yml
|
@@ -91,7 +93,6 @@ files:
|
|
91
93
|
- config/storage.yml
|
92
94
|
- db/migrate/00_create_cms.rb
|
93
95
|
- db/migrate/01_create_blog.rb
|
94
|
-
- doc/preview.jpg
|
95
96
|
- lib/comfy_blog.rb
|
96
97
|
- lib/comfy_blog/configuration.rb
|
97
98
|
- lib/comfy_blog/engine.rb
|
@@ -101,20 +102,6 @@ files:
|
|
101
102
|
- lib/comfy_blog/version.rb
|
102
103
|
- lib/generators/comfy/blog/README
|
103
104
|
- lib/generators/comfy/blog/blog_generator.rb
|
104
|
-
- test/controllers/comfy/admin/blog/posts_controller_test.rb
|
105
|
-
- test/controllers/comfy/admin/blog/revisions/post_controller_test.rb
|
106
|
-
- test/controllers/comfy/blog/posts_controller_test.rb
|
107
|
-
- test/fixtures/comfy/blog/posts.yml
|
108
|
-
- test/fixtures/comfy/cms/layouts.yml
|
109
|
-
- test/fixtures/comfy/cms/revisions.yml
|
110
|
-
- test/fixtures/comfy/cms/sites.yml
|
111
|
-
- test/fixtures/generators/blog/routes.rb
|
112
|
-
- test/gemfiles/Gemfile.rails.5.2
|
113
|
-
- test/generators/blog_generator_test.rb
|
114
|
-
- test/integration/i18n_test.rb
|
115
|
-
- test/lib/configuration_test.rb
|
116
|
-
- test/models/posts_test.rb
|
117
|
-
- test/test_helper.rb
|
118
105
|
homepage: http://github.com/comfy/comfy-blog
|
119
106
|
licenses:
|
120
107
|
- MIT
|
@@ -135,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
122
|
version: '0'
|
136
123
|
requirements: []
|
137
124
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.7.5
|
139
126
|
signing_key:
|
140
127
|
specification_version: 4
|
141
128
|
summary: Simple Blog Engine for ComfortableMexicanSofa
|
data/doc/preview.jpg
DELETED
Binary file
|
@@ -1,153 +0,0 @@
|
|
1
|
-
require_relative "../../../../test_helper"
|
2
|
-
|
3
|
-
class Comfy::Admin::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@post = comfy_blog_posts(:default)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_get_index
|
12
|
-
r :get, comfy_admin_blog_posts_path(@site)
|
13
|
-
assert_response :success
|
14
|
-
assert assigns(:posts)
|
15
|
-
assert_template :index
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_get_index_with_no_posts
|
19
|
-
Comfy::Blog::Post.delete_all
|
20
|
-
r :get, comfy_admin_blog_posts_path(@site)
|
21
|
-
assert_response :redirect
|
22
|
-
assert_redirected_to action: :new
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_get_index_with_category
|
26
|
-
category = @site.categories.create!(
|
27
|
-
label: "Test Category",
|
28
|
-
categorized_type: "Comfy::Blog::Post"
|
29
|
-
)
|
30
|
-
category.categorizations.create!(categorized: @post)
|
31
|
-
|
32
|
-
r :get, comfy_admin_blog_posts_path(@site), params: { categories: category.label }
|
33
|
-
assert_response :success
|
34
|
-
assert assigns(:posts)
|
35
|
-
assert_equal 1, assigns(:posts).count
|
36
|
-
assert assigns(:posts).first.categories.member? category
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_get_index_with_category_invalid
|
40
|
-
r :get, comfy_admin_blog_posts_path(@site), params: { categories: "invalid" }
|
41
|
-
assert_response :success
|
42
|
-
assert assigns(:posts)
|
43
|
-
assert_equal 0, assigns(:posts).count
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_get_new
|
47
|
-
r :get, new_comfy_admin_blog_post_path(@site)
|
48
|
-
assert_response :success
|
49
|
-
assert assigns(:post)
|
50
|
-
assert_template :new
|
51
|
-
assert_select "form[action='/admin/sites/#{@site.id}/blog-posts']"
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_creation
|
55
|
-
post_count = -> { Comfy::Blog::Post.count }
|
56
|
-
frag_count = -> { Comfy::Cms::Fragment.count }
|
57
|
-
assert_difference [post_count, frag_count] do
|
58
|
-
r :post, comfy_admin_blog_posts_path(@site), params: { post: {
|
59
|
-
title: "Test Post",
|
60
|
-
slug: "test-post",
|
61
|
-
published_at: 2.days.ago.to_s(:db),
|
62
|
-
is_published: "1",
|
63
|
-
layout_id: @layout,
|
64
|
-
fragments_attributes: [
|
65
|
-
{ identifier: "content",
|
66
|
-
content: "test text" }
|
67
|
-
]
|
68
|
-
} }
|
69
|
-
assert_response :redirect
|
70
|
-
assert_redirected_to action: :edit, id: assigns(:post)
|
71
|
-
assert_equal "Blog Post created", flash[:success]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_creation_failure
|
76
|
-
assert_no_difference -> { Comfy::Blog::Post.count } do
|
77
|
-
r :post, comfy_admin_blog_posts_path(@site), params: { post: {} }
|
78
|
-
assert_response :success
|
79
|
-
assert_template :new
|
80
|
-
assert assigns(:post)
|
81
|
-
assert_equal "Failed to create Blog Post", flash[:danger]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_get_edit
|
86
|
-
r :get, edit_comfy_admin_blog_post_path(@site, @post)
|
87
|
-
assert_response :success
|
88
|
-
assert_template :edit
|
89
|
-
assert assigns(:post)
|
90
|
-
assert_select "form[action='/admin/sites/#{@site.id}/blog-posts/#{@post.id}']"
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_get_edit_failure
|
94
|
-
r :get, edit_comfy_admin_blog_post_path(@site, "invalid")
|
95
|
-
assert_response :redirect
|
96
|
-
assert_redirected_to action: :index
|
97
|
-
assert_equal "Blog Post not found", flash[:danger]
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_update
|
101
|
-
r :put, comfy_admin_blog_post_path(@site, @post), params: { post: {
|
102
|
-
title: "Updated Post"
|
103
|
-
} }
|
104
|
-
assert_response :redirect
|
105
|
-
assert_redirected_to action: :edit, id: assigns(:post)
|
106
|
-
assert_equal "Blog Post updated", flash[:success]
|
107
|
-
|
108
|
-
@post.reload
|
109
|
-
assert_equal "Updated Post", @post.title
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_update_failure
|
113
|
-
r :put, comfy_admin_blog_post_path(@site, @post), params: { post: {
|
114
|
-
title: ""
|
115
|
-
} }
|
116
|
-
assert_response :success
|
117
|
-
assert_template :edit
|
118
|
-
assert_equal "Failed to update Blog Post", flash[:danger]
|
119
|
-
|
120
|
-
@post.reload
|
121
|
-
assert_not_equal "", @post.title
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_destroy
|
125
|
-
assert_difference -> { Comfy::Blog::Post.count }, -1 do
|
126
|
-
r :delete, comfy_admin_blog_post_path(@site, @post)
|
127
|
-
assert_response :redirect
|
128
|
-
assert_redirected_to action: :index
|
129
|
-
assert_equal "Blog Post removed", flash[:success]
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_get_form_fragments
|
134
|
-
r :get, form_fragments_comfy_admin_blog_post_path(site_id: @site, id: @post), xhr: true, params: {
|
135
|
-
layout_id: @layout.id
|
136
|
-
}
|
137
|
-
assert_response :success
|
138
|
-
assert assigns(:post)
|
139
|
-
assert_equal 1, assigns(:post).fragment_nodes.size
|
140
|
-
assert_template :form_fragments
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_get_form_fragments_for_new_post
|
144
|
-
r :get, form_fragments_comfy_admin_blog_post_path(site_id: @site, id: 0), xhr: true, params: {
|
145
|
-
layout_id: @layout.id
|
146
|
-
}
|
147
|
-
assert_response :success
|
148
|
-
assert assigns(:post)
|
149
|
-
assert_equal 1, assigns(:post).fragment_nodes.size
|
150
|
-
assert_template :form_fragments
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
@@ -1,67 +0,0 @@
|
|
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
|
-
def test_get_show_failure
|
41
|
-
r :get, comfy_admin_blog_post_revision_path(@site, @post, "invalid")
|
42
|
-
assert_response :redirect
|
43
|
-
assert assigns(:record)
|
44
|
-
assert_redirected_to edit_comfy_admin_blog_post_path(@site, assigns(:record))
|
45
|
-
assert_equal "Revision Not Found", flash[:danger]
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_revert
|
49
|
-
assert_difference -> { @post.revisions.count } do
|
50
|
-
r :patch, revert_comfy_admin_blog_post_revision_path(@site, @post, @revision)
|
51
|
-
assert_response :redirect
|
52
|
-
assert_redirected_to edit_comfy_admin_blog_post_path(@site, @post)
|
53
|
-
assert_equal "Content Reverted", flash[:success]
|
54
|
-
|
55
|
-
@post.reload
|
56
|
-
|
57
|
-
assert_equal [{
|
58
|
-
identifier: "content",
|
59
|
-
tag: "text",
|
60
|
-
content: "old content",
|
61
|
-
datetime: nil,
|
62
|
-
boolean: false
|
63
|
-
}], @post.fragments_attributes
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require_relative "../../../test_helper"
|
2
|
-
|
3
|
-
class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@post = comfy_blog_posts(:default)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_get_index
|
11
|
-
get comfy_blog_posts_path
|
12
|
-
assert_response :success
|
13
|
-
assert_template :index
|
14
|
-
assert assigns(:blog_posts)
|
15
|
-
assert_equal 1, assigns(:blog_posts).size
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_get_index_as_rss
|
19
|
-
get comfy_blog_posts_path, params: { format: :rss }
|
20
|
-
assert_response :success
|
21
|
-
assert_template :index
|
22
|
-
assert assigns(:blog_posts)
|
23
|
-
assert_equal 1, assigns(:blog_posts).size
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_get_index_with_unpublished
|
27
|
-
comfy_blog_posts(:default).update_column(:is_published, false)
|
28
|
-
get comfy_blog_posts_path
|
29
|
-
assert_response :success
|
30
|
-
assert_equal 0, assigns(:blog_posts).size
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_get_index_for_year_archive
|
34
|
-
get comfy_blog_posts_of_year_path(@site.path, 2012)
|
35
|
-
assert_response :success
|
36
|
-
assert_equal 1, assigns(:blog_posts).size
|
37
|
-
|
38
|
-
get comfy_blog_posts_of_year_path(@site.path, 1999)
|
39
|
-
assert_response :success
|
40
|
-
assert_equal 0, assigns(:blog_posts).size
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_get_index_for_month_archive
|
44
|
-
get comfy_blog_posts_of_month_path(@site.path, 2012, 1)
|
45
|
-
assert_response :success
|
46
|
-
assert_equal 1, assigns(:blog_posts).size
|
47
|
-
|
48
|
-
get comfy_blog_posts_of_month_path(@site.path, 2012, 12)
|
49
|
-
assert_response :success
|
50
|
-
assert_equal 0, assigns(:blog_posts).size
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_get_index_with_category
|
54
|
-
category = @site.categories.create!(
|
55
|
-
label: "Test Category",
|
56
|
-
categorized_type: "Comfy::Blog::Post"
|
57
|
-
)
|
58
|
-
category.categorizations.create!(categorized: @post)
|
59
|
-
|
60
|
-
get comfy_blog_posts_path, params: { category: category.label }
|
61
|
-
|
62
|
-
assert_response :success
|
63
|
-
assert assigns(:blog_posts)
|
64
|
-
assert_equal 1, assigns(:blog_posts).count
|
65
|
-
assert assigns(:blog_posts).first.categories.member? category
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_get_index_with_category_invalid
|
69
|
-
get comfy_blog_posts_path, params: { category: "invalid" }
|
70
|
-
assert_response :success
|
71
|
-
assert assigns(:blog_posts)
|
72
|
-
assert_equal 0, assigns(:blog_posts).count
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_get_show
|
76
|
-
@post.update_column(:content_cache, "blog post content")
|
77
|
-
get comfy_blog_post_path(@site.path, @post.year, @post.month, @post.slug)
|
78
|
-
assert_response :success
|
79
|
-
assert_equal "blog post content", response.body
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_get_show_unpublished
|
83
|
-
@post.update_attribute(:is_published, false)
|
84
|
-
assert_exception_raised ComfortableMexicanSofa::MissingPage do
|
85
|
-
get comfy_blog_post_path(@site.path, @post.year, @post.month, @post.slug)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_get_show_with_date_invalid
|
90
|
-
assert_exception_raised ComfortableMexicanSofa::MissingPage do
|
91
|
-
get comfy_blog_post_path(@site.path, 1234, 99, @post.slug)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gemspec path: "../../"
|
4
|
-
|
5
|
-
gem 'kaminari', '>= 0.14.0'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem "rubocop", "~> 0.51.0", require: false
|
9
|
-
gem "sqlite3"
|
10
|
-
gem "coveralls", require: false
|
11
|
-
gem "mocha", require: false
|
12
|
-
gem "rails-controller-testing"
|
13
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
require_relative "../../lib/generators/comfy/blog/blog_generator"
|
3
|
-
|
4
|
-
class CmsGeneratorTest < Rails::Generators::TestCase
|
5
|
-
|
6
|
-
tests Comfy::Generators::BlogGenerator
|
7
|
-
|
8
|
-
def test_generator
|
9
|
-
run_generator
|
10
|
-
|
11
|
-
assert_migration "db/migrate/create_blog.rb"
|
12
|
-
|
13
|
-
assert_file "config/initializers/comfy_blog.rb"
|
14
|
-
|
15
|
-
assert_file "config/routes.rb", read_file("blog/routes.rb")
|
16
|
-
|
17
|
-
assert_directory "app/views/comfy/blog"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class I18nIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
def collect_combined_keys(hash, ns = nil)
|
6
|
-
hash.collect do |k, v|
|
7
|
-
keys = []
|
8
|
-
keys << collect_combined_keys(v, "#{ns}.#{k}") if v.is_a?(Hash)
|
9
|
-
keys << "#{ns}.#{k}"
|
10
|
-
end.flatten
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_translations
|
14
|
-
locales_path = File.expand_path("../../../config/locales", __FILE__)
|
15
|
-
locales = Dir.glob("#{locales_path}/*.yml").collect do |file_path|
|
16
|
-
File.basename(file_path, ".yml")
|
17
|
-
end
|
18
|
-
|
19
|
-
# collecting all locales
|
20
|
-
locale_keys = {}
|
21
|
-
locales.each do |locale|
|
22
|
-
translations = YAML.load_file("#{locales_path}/#{locale}.yml")
|
23
|
-
locale_keys[locale] = collect_combined_keys(translations[locale])
|
24
|
-
end
|
25
|
-
|
26
|
-
# Using en as reference
|
27
|
-
reference = locale_keys[locales.delete("en")]
|
28
|
-
assert reference.present?
|
29
|
-
|
30
|
-
locale_keys.each do |locale, keys|
|
31
|
-
missing = reference - keys
|
32
|
-
assert missing.blank?, "#{locale} locale is missing: #{missing.join(', ')}"
|
33
|
-
extra = keys - reference
|
34
|
-
assert extra.blank?, "#{locale} locale has extra: #{extra.join(', ')}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class ConfigurationTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_configuration
|
6
|
-
assert config = ComfyBlog.configuration
|
7
|
-
assert_equal 10, config.posts_per_page
|
8
|
-
assert_equal "comfy/blog/application", config.app_layout
|
9
|
-
assert_equal "blog", config.public_blog_path
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_initialization_overrides
|
13
|
-
ComfyBlog.config.posts_per_page = 5
|
14
|
-
assert_equal 5, ComfyBlog.config.posts_per_page
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/test/models/posts_test.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class BlogPostsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@layout = comfy_cms_layouts(:default)
|
8
|
-
@post = comfy_blog_posts(:default)
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_fixtures_validity
|
12
|
-
Comfy::Blog::Post.all.each do |post|
|
13
|
-
assert post.valid?, post.errors.full_messages.to_s
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_validations
|
18
|
-
post = Comfy::Blog::Post.new
|
19
|
-
assert post.invalid?
|
20
|
-
assert_errors_on post, :site, :title, :slug, :layout
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_validation_of_slug_uniqueness
|
24
|
-
@post.update_attributes!(published_at: Time.now)
|
25
|
-
post = @site.blog_posts.new(
|
26
|
-
title: @post.title,
|
27
|
-
layout: @layout
|
28
|
-
)
|
29
|
-
assert post.invalid?
|
30
|
-
assert_errors_on post, [:slug]
|
31
|
-
|
32
|
-
@post.update_attributes!(published_at: 1.year.ago)
|
33
|
-
assert post.valid?
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_validation_of_slug_format
|
37
|
-
post = @site.blog_posts.new(
|
38
|
-
title: "Test Title",
|
39
|
-
slug: "test%slug",
|
40
|
-
layout: @layout
|
41
|
-
)
|
42
|
-
assert post.valid?
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_creation
|
46
|
-
assert_difference -> { Comfy::Blog::Post.count } do
|
47
|
-
post = @site.blog_posts.create!(
|
48
|
-
title: "Test Post",
|
49
|
-
layout: @layout
|
50
|
-
)
|
51
|
-
assert_equal "test-post", post.slug
|
52
|
-
assert_equal Time.zone.now.year, post.year
|
53
|
-
assert_equal Time.zone.now.month, post.month
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_set_slug
|
58
|
-
post = Comfy::Blog::Post.new(title: "Test Title")
|
59
|
-
post.send(:set_slug)
|
60
|
-
assert_equal "test-title", post.slug
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_set_date
|
64
|
-
post = Comfy::Blog::Post.new
|
65
|
-
post.send(:set_published_at)
|
66
|
-
post.send(:set_date)
|
67
|
-
assert_equal post.published_at.year, post.year
|
68
|
-
assert_equal post.published_at.month, post.month
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_set_published_at
|
72
|
-
post = Comfy::Blog::Post.new
|
73
|
-
post.send(:set_published_at)
|
74
|
-
assert post.published_at.present?
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_scope_published
|
78
|
-
assert @post.is_published?
|
79
|
-
assert_equal 1, Comfy::Blog::Post.published.count
|
80
|
-
|
81
|
-
@post.update_attribute(:is_published, false)
|
82
|
-
assert_equal 0, Comfy::Blog::Post.published.count
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_scope_for_year
|
86
|
-
assert_equal 1, Comfy::Blog::Post.for_year(2012).count
|
87
|
-
assert_equal 0, Comfy::Blog::Post.for_year(2013).count
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_scope_for_month
|
91
|
-
assert_equal 1, Comfy::Blog::Post.for_month(1).count
|
92
|
-
assert_equal 0, Comfy::Blog::Post.for_month(2).count
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_url
|
96
|
-
assert_equal "//test.host/blog/2012/1/default-title", @post.url
|
97
|
-
assert_equal "/blog/2012/1/default-title", @post.url(relative: true)
|
98
|
-
|
99
|
-
ComfyBlog.config.public_blog_path = "test-blog"
|
100
|
-
assert_equal "//test.host/test-blog/2012/1/default-title", @post.url
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
|
3
|
-
require "simplecov"
|
4
|
-
require "coveralls"
|
5
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter "lib/generators"
|
8
|
-
add_filter "lib/comfy_blog/engine.rb "
|
9
|
-
end
|
10
|
-
require_relative "../config/environment"
|
11
|
-
|
12
|
-
require "rails/test_help"
|
13
|
-
require "rails/generators"
|
14
|
-
|
15
|
-
Rails.backtrace_cleaner.remove_silencers!
|
16
|
-
|
17
|
-
class ActiveSupport::TestCase
|
18
|
-
|
19
|
-
fixtures :all
|
20
|
-
|
21
|
-
setup :reset_config
|
22
|
-
|
23
|
-
def reset_config
|
24
|
-
ComfyBlog.configure do |config|
|
25
|
-
config.posts_per_page = 10
|
26
|
-
config.app_layout = "comfy/blog/application"
|
27
|
-
config.public_blog_path = "blog"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Example usage:
|
32
|
-
# assert_has_errors_on @record, :field_1, :field_2
|
33
|
-
def assert_errors_on(record, *fields)
|
34
|
-
unmatched = record.errors.keys - fields.flatten
|
35
|
-
assert unmatched.blank?, "#{record.class} has errors on '#{unmatched.join(', ')}'"
|
36
|
-
unmatched = fields.flatten - record.errors.keys
|
37
|
-
assert unmatched.blank?, "#{record.class} doesn't have errors on '#{unmatched.join(', ')}'"
|
38
|
-
end
|
39
|
-
|
40
|
-
# Example usage:
|
41
|
-
# assert_exception_raised do ... end
|
42
|
-
# assert_exception_raised ActiveRecord::RecordInvalid do ... end
|
43
|
-
# assert_exception_raised Plugin::Error, 'error_message' do ... end
|
44
|
-
def assert_exception_raised(exception_class = nil, error_message = nil)
|
45
|
-
exception_raised = nil
|
46
|
-
yield
|
47
|
-
rescue StandardError => exception_raised
|
48
|
-
exception_raised
|
49
|
-
ensure
|
50
|
-
if exception_raised
|
51
|
-
if exception_class
|
52
|
-
assert_equal exception_class, exception_raised.class, exception_raised.to_s
|
53
|
-
else
|
54
|
-
assert true
|
55
|
-
end
|
56
|
-
assert_equal error_message, exception_raised.to_s if error_message
|
57
|
-
else
|
58
|
-
flunk "Exception was not raised"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
class ActionDispatch::IntegrationTest
|
65
|
-
|
66
|
-
setup :setup_host
|
67
|
-
|
68
|
-
def setup_host
|
69
|
-
host! "test.host"
|
70
|
-
end
|
71
|
-
|
72
|
-
# Attaching http_auth stuff with request. Example use:
|
73
|
-
# r :get, '/cms-admin/pages'
|
74
|
-
def r(method, path, options = {})
|
75
|
-
headers = options[:headers] || {}
|
76
|
-
headers["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(
|
77
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.username,
|
78
|
-
ComfortableMexicanSofa::AccessControl::AdminAuthentication.password
|
79
|
-
)
|
80
|
-
options[:headers] = headers
|
81
|
-
send(method, path, options)
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
class Rails::Generators::TestCase
|
87
|
-
|
88
|
-
destination File.expand_path("../tmp", File.dirname(__FILE__))
|
89
|
-
|
90
|
-
setup :prepare_destination,
|
91
|
-
:prepare_files
|
92
|
-
|
93
|
-
def prepare_files
|
94
|
-
config_path = File.join(destination_root, "config")
|
95
|
-
routes_path = File.join(config_path, "routes.rb")
|
96
|
-
FileUtils.mkdir_p(config_path)
|
97
|
-
FileUtils.touch(routes_path)
|
98
|
-
File.open(routes_path, "w") do |f|
|
99
|
-
f.write("Test::Application.routes.draw do\n\nend")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def read_file(filename)
|
104
|
-
File.read(
|
105
|
-
File.join(
|
106
|
-
File.expand_path("fixtures/generators", File.dirname(__FILE__)),
|
107
|
-
filename
|
108
|
-
)
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|