comfy_blog 1.12.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -15
- data/Gemfile +7 -6
- data/LICENSE +1 -1
- data/README.md +14 -9
- data/Rakefile +1 -32
- data/app/controllers/comfy/admin/blog/posts_controller.rb +26 -22
- data/app/controllers/comfy/blog/posts_controller.rb +31 -38
- data/app/models/comfy/blog/post.rb +34 -36
- data/app/views/comfy/admin/blog/partials/_navigation.html.haml +4 -6
- data/app/views/comfy/admin/blog/posts/_form.html.haml +23 -11
- data/app/views/comfy/admin/blog/posts/edit.html.haml +2 -2
- data/app/views/comfy/admin/blog/posts/index.html.haml +29 -25
- data/app/views/comfy/admin/blog/posts/new.html.haml +2 -2
- data/app/views/comfy/blog/posts/index.html.haml +25 -10
- data/app/views/comfy/blog/posts/index.rss.builder +12 -12
- data/app/views/layouts/comfy/blog/application.html.erb +22 -0
- data/comfy_blog.gemspec +3 -1
- data/config/application.rb +13 -7
- data/config/blog_routes.rb +2 -2
- data/config/environments/development.rb +37 -4
- data/config/environments/test.rb +13 -4
- data/config/initializers/comfy_blog.rb +3 -7
- data/config/locales/cs.yml +38 -0
- data/config/locales/da.yml +38 -0
- data/config/locales/de.yml +38 -0
- data/config/locales/en.yml +38 -0
- data/config/locales/es.yml +38 -0
- data/config/locales/fr.yml +38 -0
- data/config/locales/it.yml +38 -0
- data/config/locales/ja.yml +38 -0
- data/config/locales/nb.yml +38 -0
- data/config/locales/nl.yml +38 -0
- data/config/locales/pl.yml +38 -0
- data/config/locales/pt-BR.yml +38 -0
- data/config/locales/ru.yml +38 -0
- data/config/locales/sv.yml +38 -0
- data/config/locales/tr.yml +38 -0
- data/config/locales/uk.yml +38 -0
- data/config/locales/zh-CN.yml +38 -0
- data/config/locales/zh-TW.yml +38 -0
- data/config/storage.yml +35 -0
- data/db/migrate/00_create_cms.rb +144 -116
- data/db/migrate/01_create_blog.rb +15 -43
- data/lib/comfy_blog/configuration.rb +9 -9
- data/lib/comfy_blog/engine.rb +7 -7
- data/lib/comfy_blog/routes/blog.rb +12 -13
- data/lib/comfy_blog/routes/blog_admin.rb +7 -12
- data/lib/comfy_blog/version.rb +1 -1
- data/lib/generators/comfy/blog/blog_generator.rb +16 -14
- data/test/controllers/comfy/admin/blog/posts_controller_test.rb +83 -59
- data/test/controllers/comfy/blog/posts_controller_test.rb +56 -42
- data/test/fixtures/comfy/blog/posts.yml +3 -4
- data/test/fixtures/comfy/cms/layouts.yml +10 -0
- data/test/fixtures/comfy/cms/sites.yml +1 -1
- data/test/fixtures/generators/blog/routes.rb +2 -3
- data/test/gemfiles/Gemfile.rails.5.2 +22 -0
- data/test/generators/blog_generator_test.rb +7 -7
- data/test/integration/i18n_test.rb +37 -0
- data/test/lib/configuration_test.rb +4 -5
- data/test/models/posts_test.rb +35 -30
- data/test/test_helper.rb +40 -29
- metadata +29 -35
- data/app/controllers/comfy/admin/blog/base_controller.rb +0 -12
- data/app/controllers/comfy/admin/blog/blogs_controller.rb +0 -51
- data/app/controllers/comfy/admin/blog/comments_controller.rb +0 -33
- data/app/controllers/comfy/blog/base_controller.rb +0 -33
- data/app/controllers/comfy/blog/comments_controller.rb +0 -33
- data/app/models/comfy/blog/blog.rb +0 -31
- data/app/models/comfy/blog/comment.rb +0 -29
- data/app/views/comfy/admin/blog/blogs/_form.html.haml +0 -11
- data/app/views/comfy/admin/blog/blogs/edit.html.haml +0 -5
- data/app/views/comfy/admin/blog/blogs/index.html.haml +0 -26
- data/app/views/comfy/admin/blog/blogs/new.html.haml +0 -5
- data/app/views/comfy/admin/blog/comments/_comment.html.haml +0 -17
- data/app/views/comfy/admin/blog/comments/index.html.haml +0 -17
- data/app/views/comfy/admin/blog/comments/toggle_publish.js.erb +0 -1
- data/app/views/comfy/blog/comments/_form.html.haml +0 -10
- data/app/views/comfy/blog/posts/show.html.haml +0 -18
- data/app/views/layouts/comfy/blog/application.html.haml +0 -7
- data/config/initializers/secret_token.rb +0 -15
- data/test/controllers/comfy/admin/blog/blogs_controller_test.rb +0 -94
- data/test/controllers/comfy/admin/blog/comments_controller_test.rb +0 -57
- data/test/controllers/comfy/blog/comments_controller_test.rb +0 -36
- data/test/fixtures/comfy/blog/blogs.yml +0 -7
- data/test/fixtures/comfy/blog/comments.yml +0 -6
- data/test/gemfiles/Gemfile.rails.4.0 +0 -10
- data/test/gemfiles/Gemfile.rails.4.1 +0 -10
- data/test/gemfiles/Gemfile.rails.4.2 +0 -10
- data/test/gemfiles/Gemfile.rails.master +0 -10
- data/test/models/blog_test.rb +0 -59
- data/test/models/comments_test.rb +0 -45
@@ -1,57 +0,0 @@
|
|
1
|
-
require_relative '../../../../test_helper'
|
2
|
-
|
3
|
-
class Comfy::Admin::Blog::CommentsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@site = comfy_cms_sites(:default)
|
7
|
-
@blog = comfy_blog_blogs(:default)
|
8
|
-
@post = comfy_blog_posts(:default)
|
9
|
-
@comment = comfy_blog_comments(:default)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_index
|
13
|
-
get :index, :site_id => @site, :blog_id => @blog
|
14
|
-
assert_response :success
|
15
|
-
assert_template :index
|
16
|
-
assert assigns(:comments)
|
17
|
-
assert !assigns(:post)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_get_index_for_post
|
21
|
-
get :index, :site_id => @site, :blog_id => @blog, :post_id => @post
|
22
|
-
assert_response :success
|
23
|
-
assert_template :index
|
24
|
-
assert assigns(:post)
|
25
|
-
assert assigns(:comments)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_publish
|
29
|
-
assert @comment.is_published?
|
30
|
-
xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment
|
31
|
-
assert_response :success
|
32
|
-
@comment.reload
|
33
|
-
assert !@comment.is_published?
|
34
|
-
|
35
|
-
xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment
|
36
|
-
assert_response :success
|
37
|
-
@comment.reload
|
38
|
-
assert @comment.is_published?
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_destroy
|
42
|
-
assert_difference 'Comfy::Blog::Comment.count', -1 do
|
43
|
-
delete :destroy, :site_id => @site, :blog_id => @blog, :id => @comment
|
44
|
-
assert_response :redirect
|
45
|
-
assert_redirected_to :action => :index
|
46
|
-
assert_equal 'Comment deleted', flash[:success]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_destroy_failure
|
51
|
-
delete :destroy, :site_id => @site, :blog_id => @blog, :id => 'invalid'
|
52
|
-
assert_response :redirect
|
53
|
-
assert_redirected_to :action => :index
|
54
|
-
assert_equal 'Comment not found', flash[:error]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require_relative '../../../test_helper'
|
2
|
-
|
3
|
-
class Comfy::Blog::CommentsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@blog = comfy_blog_blogs(:default)
|
7
|
-
@post = comfy_blog_posts(:default)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_creation
|
11
|
-
assert_difference 'Comfy::Blog::Comment.count' do
|
12
|
-
post :create, :slug => @post.slug, :comment => {
|
13
|
-
:author => 'Test',
|
14
|
-
:email => 'test@test.test',
|
15
|
-
:content => 'Test Content'
|
16
|
-
}
|
17
|
-
assert_response :redirect
|
18
|
-
assert_redirected_to comfy_blog_post_path
|
19
|
-
assert_equal 'Comment created', flash[:success]
|
20
|
-
|
21
|
-
comment = Comfy::Blog::Comment.last
|
22
|
-
assert_equal 'Test', comment.author
|
23
|
-
assert_equal @post, comment.post
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_creation_failure
|
28
|
-
assert_no_difference 'Comfy::Blog::Comment.count' do
|
29
|
-
post :create, :slug => @post.slug, :comment => { }
|
30
|
-
assert_response :success
|
31
|
-
assert_template :show
|
32
|
-
assert_equal 'Failed to create Comment', flash[:error]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
data/test/models/blog_test.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class BlogTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_site_association
|
6
|
-
assert_equal [comfy_blog_blogs(:default)], comfy_cms_sites(:default).blogs
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_fixtures_validity
|
10
|
-
Comfy::Blog::Blog.all.each do |blog|
|
11
|
-
assert blog.valid?, blog.errors.inspect
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_validation
|
16
|
-
blog = Comfy::Blog::Blog.new
|
17
|
-
assert blog.invalid?
|
18
|
-
assert_errors_on blog, :site_id, :label, :identifier, :path
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_validation_path_presence
|
22
|
-
blog_a = comfy_blog_blogs(:default)
|
23
|
-
refute blog_a.path.present?
|
24
|
-
|
25
|
-
blog_b = comfy_cms_sites(:default).blogs.new(
|
26
|
-
:label => 'Test Blog A',
|
27
|
-
:identifier => 'test-blog-a'
|
28
|
-
)
|
29
|
-
assert blog_b.invalid?
|
30
|
-
assert_errors_on blog_b, :path
|
31
|
-
|
32
|
-
blog_a.update_column(:path, 'blog-a')
|
33
|
-
assert blog_b.invalid?
|
34
|
-
assert_errors_on blog_b, :path
|
35
|
-
|
36
|
-
blog_b.path = 'blog-a'
|
37
|
-
assert blog_b.invalid?
|
38
|
-
assert_errors_on blog_b, :path
|
39
|
-
|
40
|
-
blog_b.path = 'blog-b'
|
41
|
-
assert blog_b.valid?
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_creation
|
45
|
-
assert_difference 'Comfy::Blog::Blog.count' do
|
46
|
-
comfy_cms_sites(:default).blogs.create(
|
47
|
-
:label => 'Test Blog',
|
48
|
-
:identifier => 'test-blog',
|
49
|
-
:path => 'test-blog'
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_destroy
|
55
|
-
assert_difference ['Comfy::Blog::Blog.count', 'Comfy::Blog::Post.count'], -1 do
|
56
|
-
comfy_blog_blogs(:default).destroy
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class BlogCommentsTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def test_fixtures_validity
|
6
|
-
Comfy::Blog::Comment.all.each do |comment|
|
7
|
-
assert comment.valid?, comment.errors.full_messages.to_s
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_validations
|
12
|
-
comment = Comfy::Blog::Comment.new
|
13
|
-
assert comment.invalid?
|
14
|
-
assert_errors_on comment, [:post_id, :content, :author, :email]
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_creation
|
18
|
-
assert_difference 'Comfy::Blog::Comment.count' do
|
19
|
-
comment = comfy_blog_posts(:default).comments.create(
|
20
|
-
:content => 'Test Content',
|
21
|
-
:author => 'Tester',
|
22
|
-
:email => 'test@test.test'
|
23
|
-
)
|
24
|
-
assert !comment.is_published?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_creation_with_auto_publishing
|
29
|
-
ComfyBlog.config.auto_publish_comments = true
|
30
|
-
|
31
|
-
comment = comfy_blog_posts(:default).comments.create(
|
32
|
-
:content => 'Test Content',
|
33
|
-
:author => 'Tester',
|
34
|
-
:email => 'test@test.test'
|
35
|
-
)
|
36
|
-
assert comment.is_published?
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_scope_published
|
40
|
-
assert_equal 1, Comfy::Blog::Comment.published.count
|
41
|
-
comfy_blog_comments(:default).update_attribute(:is_published, false)
|
42
|
-
assert_equal 0, Comfy::Blog::Comment.published.count
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|