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,21 +1,21 @@
|
|
1
1
|
module ComfyBlog
|
2
2
|
class Configuration
|
3
3
|
|
4
|
+
# Application layout to be used to index blog posts.
|
5
|
+
# Default is 'comfy/blog/application'
|
6
|
+
attr_accessor :app_layout
|
7
|
+
|
4
8
|
# Number of posts per page. Default is 10
|
5
9
|
attr_accessor :posts_per_page
|
6
10
|
|
7
|
-
#
|
8
|
-
|
9
|
-
attr_accessor :auto_publish_comments
|
10
|
-
|
11
|
-
# A default author can be specified for posts
|
12
|
-
attr_accessor :default_author
|
11
|
+
# Auto-setting parameter derived from the routes
|
12
|
+
attr_accessor :public_blog_path
|
13
13
|
|
14
14
|
# Configuration defaults
|
15
15
|
def initialize
|
16
|
-
@posts_per_page
|
17
|
-
@
|
18
|
-
@
|
16
|
+
@posts_per_page = 10
|
17
|
+
@app_layout = 'comfy/blog/application'
|
18
|
+
@public_blog_path = nil
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
data/lib/comfy_blog/engine.rb
CHANGED
@@ -4,16 +4,16 @@ require 'comfortable_mexican_sofa'
|
|
4
4
|
require 'comfy_blog'
|
5
5
|
|
6
6
|
module ComfyBlog
|
7
|
-
|
7
|
+
|
8
8
|
module CmsSiteExtensions
|
9
9
|
extend ActiveSupport::Concern
|
10
|
-
included do
|
11
|
-
has_many :
|
12
|
-
:
|
13
|
-
:
|
10
|
+
included do
|
11
|
+
has_many :blog_posts,
|
12
|
+
class_name: 'Blog::Post',
|
13
|
+
dependent: :destroy
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
class Engine < ::Rails::Engine
|
18
18
|
initializer 'comfy_blog.configuration' do |app|
|
19
19
|
ComfortableMexicanSofa::ViewHooks.add(:navigation, '/comfy/admin/blog/partials/navigation')
|
@@ -22,4 +22,4 @@ module ComfyBlog
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
class ActionDispatch::Routing::Mapper
|
2
2
|
|
3
3
|
def comfy_route_blog(options = {})
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
o.get ':year
|
12
|
-
o.get ':year/:month
|
4
|
+
|
5
|
+
ComfyBlog.configuration.public_blog_path = options[:path] || 'blog'
|
6
|
+
path = ['(:cms_path)', ComfyBlog.configuration.public_blog_path].join('/')
|
7
|
+
|
8
|
+
scope module: :comfy, as: :comfy do
|
9
|
+
namespace :blog, path: path do
|
10
|
+
with_options constraints: {year: /\d{4}/, month: /\d{1,2}/} do |o|
|
11
|
+
o.get ':year', to: 'posts#index', as: :posts_of_year
|
12
|
+
o.get ':year/:month', to: 'posts#index', as: :posts_of_month
|
13
|
+
o.get ':year/:month/:slug', to: 'posts#show', as: :post
|
14
|
+
o.get '/', to: 'posts#index', as: :posts
|
13
15
|
end
|
14
|
-
post ':slug/comments' => 'comments#create', :as => :comments
|
15
|
-
get ':slug' => 'posts#serve', :as => :post
|
16
|
-
get '/' => 'posts#serve', :as => :posts
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
|
-
end
|
19
|
+
end
|
@@ -1,20 +1,15 @@
|
|
1
1
|
class ActionDispatch::Routing::Mapper
|
2
|
-
|
2
|
+
|
3
3
|
def comfy_route_blog_admin(options = {})
|
4
4
|
options[:path] ||= 'admin'
|
5
5
|
path = [options[:path], 'sites', ':site_id'].join('/')
|
6
|
-
|
7
|
-
scope :
|
8
|
-
scope :
|
9
|
-
namespace :blog, :
|
10
|
-
resources :
|
11
|
-
resources :posts
|
12
|
-
resources :comments, :only => [:index, :destroy] do
|
13
|
-
patch :toggle_publish, :on => :member
|
14
|
-
end
|
15
|
-
end
|
6
|
+
|
7
|
+
scope module: :comfy, as: :comfy do
|
8
|
+
scope module: :admin do
|
9
|
+
namespace :blog, as: :admin, path: path, except: [:show] do
|
10
|
+
resources :posts, as: :blog_posts, path: "blog-posts"
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
19
14
|
end
|
20
|
-
end
|
15
|
+
end
|
data/lib/comfy_blog/version.rb
CHANGED
@@ -3,47 +3,49 @@ require 'rails/generators/active_record'
|
|
3
3
|
module Comfy
|
4
4
|
module Generators
|
5
5
|
class BlogGenerator < Rails::Generators::Base
|
6
|
-
|
6
|
+
|
7
7
|
include Rails::Generators::Migration
|
8
8
|
include Thor::Actions
|
9
|
-
|
9
|
+
|
10
10
|
source_root File.expand_path('../../../../..', __FILE__)
|
11
|
-
|
11
|
+
|
12
12
|
def self.next_migration_number(dirname)
|
13
13
|
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def generate_migration
|
17
17
|
destination = File.expand_path('db/migrate/01_create_blog.rb', self.destination_root)
|
18
18
|
migration_dir = File.dirname(destination)
|
19
19
|
destination = self.class.migration_exists?(migration_dir, 'create_blog')
|
20
|
-
|
20
|
+
|
21
21
|
if destination
|
22
22
|
puts "\e[0m\e[31mFound existing create_blog migration. Remove it if you want to regenerate.\e[0m"
|
23
23
|
else
|
24
24
|
migration_template 'db/migrate/01_create_blog.rb', 'db/migrate/create_blog.rb'
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def generate_initialization
|
29
29
|
copy_file 'config/initializers/comfy_blog.rb',
|
30
30
|
'config/initializers/comfy_blog.rb'
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def generate_routing
|
34
|
-
route_string
|
35
|
-
|
36
|
-
|
34
|
+
route_string = <<-RUBY.strip_heredoc
|
35
|
+
comfy_route :blog_admin, path: "/admin"
|
36
|
+
comfy_route :blog, path: "/blog"
|
37
|
+
RUBY
|
38
|
+
route route_string
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
def generate_views
|
40
42
|
directory 'app/views/comfy/blog', 'app/views/comfy/blog'
|
41
43
|
end
|
42
|
-
|
44
|
+
|
43
45
|
def show_readme
|
44
46
|
readme 'lib/generators/comfy/blog/README'
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
end
|
48
50
|
end
|
49
|
-
end
|
51
|
+
end
|
@@ -1,108 +1,132 @@
|
|
1
1
|
require_relative '../../../../test_helper'
|
2
2
|
|
3
|
-
class Comfy::Admin::Blog::PostsControllerTest <
|
4
|
-
|
5
|
-
|
6
|
-
@site
|
7
|
-
@
|
8
|
-
@post
|
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
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_get_index
|
12
|
-
|
12
|
+
r :get, comfy_admin_blog_posts_path(@site)
|
13
13
|
assert_response :success
|
14
14
|
assert assigns(:posts)
|
15
15
|
assert_template :index
|
16
16
|
end
|
17
|
-
|
18
|
-
def
|
19
|
-
|
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}
|
20
33
|
assert_response :success
|
21
|
-
assert assigns(:
|
22
|
-
|
23
|
-
|
34
|
+
assert assigns(:posts)
|
35
|
+
assert_equal 1, assigns(:posts).count
|
36
|
+
assert assigns(:posts).first.categories.member? category
|
24
37
|
end
|
25
|
-
|
26
|
-
def
|
27
|
-
|
28
|
-
|
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)
|
29
48
|
assert_response :success
|
30
49
|
assert assigns(:post)
|
31
|
-
|
50
|
+
assert_template :new
|
51
|
+
assert_select "form[action='/admin/sites/#{@site.id}/blog-posts']"
|
32
52
|
end
|
33
|
-
|
53
|
+
|
34
54
|
def test_creation
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
|
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
|
+
}}
|
44
69
|
assert_response :redirect
|
45
|
-
assert_redirected_to :
|
70
|
+
assert_redirected_to action: :edit, id: assigns(:post)
|
46
71
|
assert_equal 'Blog Post created', flash[:success]
|
47
72
|
end
|
48
73
|
end
|
49
|
-
|
74
|
+
|
50
75
|
def test_creation_failure
|
51
|
-
assert_no_difference
|
52
|
-
|
76
|
+
assert_no_difference ->{Comfy::Blog::Post.count} do
|
77
|
+
r :post, comfy_admin_blog_posts_path(@site), params: {post: {}}
|
53
78
|
assert_response :success
|
54
79
|
assert_template :new
|
55
80
|
assert assigns(:post)
|
56
|
-
assert_equal 'Failed to create Blog Post', flash[:
|
81
|
+
assert_equal 'Failed to create Blog Post', flash[:danger]
|
57
82
|
end
|
58
83
|
end
|
59
|
-
|
84
|
+
|
60
85
|
def test_get_edit
|
61
|
-
|
86
|
+
r :get, edit_comfy_admin_blog_post_path(@site, @post)
|
62
87
|
assert_response :success
|
63
88
|
assert_template :edit
|
64
89
|
assert assigns(:post)
|
65
|
-
assert_select "form[action='/admin/sites/#{@site.id}/
|
90
|
+
assert_select "form[action='/admin/sites/#{@site.id}/blog-posts/#{@post.id}']"
|
66
91
|
end
|
67
|
-
|
92
|
+
|
68
93
|
def test_get_edit_failure
|
69
|
-
|
94
|
+
r :get, edit_comfy_admin_blog_post_path(@site, 'invalid')
|
70
95
|
assert_response :redirect
|
71
|
-
assert_redirected_to :
|
72
|
-
assert_equal 'Blog Post not found', flash[:
|
96
|
+
assert_redirected_to action: :index
|
97
|
+
assert_equal 'Blog Post not found', flash[:danger]
|
73
98
|
end
|
74
|
-
|
99
|
+
|
75
100
|
def test_update
|
76
|
-
|
77
|
-
:
|
78
|
-
}
|
101
|
+
r :put, comfy_admin_blog_post_path(@site, @post), params: {post: {
|
102
|
+
title: 'Updated Post'
|
103
|
+
}}
|
79
104
|
assert_response :redirect
|
80
|
-
assert_redirected_to :
|
105
|
+
assert_redirected_to action: :edit, id: assigns(:post)
|
81
106
|
assert_equal 'Blog Post updated', flash[:success]
|
82
|
-
|
107
|
+
|
83
108
|
@post.reload
|
84
109
|
assert_equal 'Updated Post', @post.title
|
85
110
|
end
|
86
|
-
|
111
|
+
|
87
112
|
def test_update_failure
|
88
|
-
|
89
|
-
:
|
90
|
-
}
|
113
|
+
r :put, comfy_admin_blog_post_path(@site, @post), params: {post: {
|
114
|
+
title: ''
|
115
|
+
}}
|
91
116
|
assert_response :success
|
92
117
|
assert_template :edit
|
93
|
-
assert_equal 'Failed to update Blog Post', flash[:
|
94
|
-
|
118
|
+
assert_equal 'Failed to update Blog Post', flash[:danger]
|
119
|
+
|
95
120
|
@post.reload
|
96
121
|
assert_not_equal '', @post.title
|
97
122
|
end
|
98
|
-
|
123
|
+
|
99
124
|
def test_destroy
|
100
|
-
assert_difference
|
101
|
-
|
125
|
+
assert_difference -> {Comfy::Blog::Post.count}, -1 do
|
126
|
+
r :delete, comfy_admin_blog_post_path(@site, @post)
|
102
127
|
assert_response :redirect
|
103
|
-
assert_redirected_to :
|
128
|
+
assert_redirected_to action: :index
|
104
129
|
assert_equal 'Blog Post removed', flash[:success]
|
105
130
|
end
|
106
131
|
end
|
107
|
-
|
108
|
-
end
|
132
|
+
end
|
@@ -1,80 +1,94 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
2
|
|
3
|
-
class Comfy::Blog::PostsControllerTest <
|
4
|
-
|
3
|
+
class Comfy::Blog::PostsControllerTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
5
|
def setup
|
6
|
-
@
|
6
|
+
@site = comfy_cms_sites(:default)
|
7
7
|
@post = comfy_blog_posts(:default)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def test_get_index
|
11
|
-
get
|
11
|
+
get comfy_blog_posts_path
|
12
12
|
assert_response :success
|
13
13
|
assert_template :index
|
14
|
-
assert assigns(:
|
15
|
-
assert_equal 1, assigns(:
|
14
|
+
assert assigns(:blog_posts)
|
15
|
+
assert_equal 1, assigns(:blog_posts).size
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def test_get_index_as_rss
|
19
|
-
get
|
19
|
+
get comfy_blog_posts_path, params: {format: :rss}
|
20
20
|
assert_response :success
|
21
21
|
assert_template :index
|
22
|
-
assert assigns(:
|
23
|
-
assert_equal 1, assigns(:
|
22
|
+
assert assigns(:blog_posts)
|
23
|
+
assert_equal 1, assigns(:blog_posts).size
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def test_get_index_with_unpublished
|
27
27
|
comfy_blog_posts(:default).update_column(:is_published, false)
|
28
|
-
get
|
28
|
+
get comfy_blog_posts_path
|
29
29
|
assert_response :success
|
30
|
-
assert_equal 0, assigns(:
|
30
|
+
assert_equal 0, assigns(:blog_posts).size
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def test_get_index_for_year_archive
|
34
|
-
get
|
34
|
+
get comfy_blog_posts_of_year_path(@site.path, 2012)
|
35
35
|
assert_response :success
|
36
|
-
assert_equal 1, assigns(:
|
37
|
-
|
38
|
-
get
|
36
|
+
assert_equal 1, assigns(:blog_posts).size
|
37
|
+
|
38
|
+
get comfy_blog_posts_of_year_path(@site.path, 1999)
|
39
39
|
assert_response :success
|
40
|
-
assert_equal 0, assigns(:
|
40
|
+
assert_equal 0, assigns(:blog_posts).size
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def test_get_index_for_month_archive
|
44
|
-
get
|
44
|
+
get comfy_blog_posts_of_month_path(@site.path, 2012, 1)
|
45
45
|
assert_response :success
|
46
|
-
assert_equal 1, assigns(:
|
47
|
-
|
48
|
-
get
|
46
|
+
assert_equal 1, assigns(:blog_posts).size
|
47
|
+
|
48
|
+
get comfy_blog_posts_of_month_path(@site.path, 2012, 12)
|
49
49
|
assert_response :success
|
50
|
-
assert_equal 0, assigns(:
|
50
|
+
assert_equal 0, assigns(:blog_posts).size
|
51
51
|
end
|
52
|
-
|
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
|
+
|
53
75
|
def test_get_show
|
54
|
-
|
76
|
+
@post.update_column(:content_cache, "blog post content")
|
77
|
+
get comfy_blog_post_path(@site.path, @post.year, @post.month, @post.slug)
|
55
78
|
assert_response :success
|
56
|
-
|
57
|
-
assert assigns(:post)
|
79
|
+
assert_equal "blog post content", response.body
|
58
80
|
end
|
59
|
-
|
81
|
+
|
60
82
|
def test_get_show_unpublished
|
61
83
|
@post.update_attribute(:is_published, false)
|
62
84
|
assert_exception_raised ComfortableMexicanSofa::MissingPage do
|
63
|
-
get
|
85
|
+
get comfy_blog_post_path(@site.path, @post.year, @post.month, @post.slug)
|
64
86
|
end
|
65
87
|
end
|
66
|
-
|
67
|
-
def test_get_show_with_date
|
68
|
-
get :show, :year => @post.year, :month => @post.month, :slug => @post.slug
|
69
|
-
assert_response :success
|
70
|
-
assert_template :show
|
71
|
-
assert assigns(:post)
|
72
|
-
end
|
73
|
-
|
88
|
+
|
74
89
|
def test_get_show_with_date_invalid
|
75
90
|
assert_exception_raised ComfortableMexicanSofa::MissingPage do
|
76
|
-
get
|
91
|
+
get comfy_blog_post_path(@site.path, 1234, 99, @post.slug)
|
77
92
|
end
|
78
93
|
end
|
79
|
-
|
80
94
|
end
|