comfy_blog 1.12.2 → 1.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Rakefile +14 -4
- data/app/controllers/comfy/blog/base_controller.rb +8 -6
- data/app/controllers/comfy/blog/posts_controller.rb +7 -7
- data/app/models/comfy/blog/post.rb +1 -1
- data/comfy_blog.gemspec +1 -1
- data/config/environments/test.rb +2 -0
- data/db/migrate/01_create_blog.rb +8 -8
- data/lib/comfy_blog/version.rb +1 -1
- data/test/gemfiles/Gemfile.rails.4.0 +1 -1
- data/test/gemfiles/Gemfile.rails.4.1 +1 -1
- data/test/gemfiles/Gemfile.rails.4.2 +1 -1
- data/test/gemfiles/Gemfile.rails.master +1 -1
- data/test/models/posts_test.rb +18 -9
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09145ea32c2a6b0cfd5b35c66dfa9d59af182c04
|
4
|
+
data.tar.gz: 0efe6fd8ebed393e88d9f255448e54d7ca8fc9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93531bcfed2ee3d3c2cffce8a90503e487ae7e49aa7f0c9269f0f02f6791ca913faef0ec93e628adf2a6b8fe4d4d125b2d561ebe60434473885e52114c0c55b3
|
7
|
+
data.tar.gz: 5f16da3322937f76771c5b2a94b21348db82bbf7470fe2955f6e03b52967dd965b6023a62350cac483789667190637e0c64986d3d8bc661a3df0a72286c92d9f
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,21 +1,31 @@
|
|
1
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:ci) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
2
11
|
|
12
|
+
require_relative 'config/application'
|
3
13
|
ComfyBlog::Application.load_tasks
|
4
14
|
|
5
15
|
namespace :test do
|
6
|
-
|
16
|
+
|
7
17
|
Rake::TestTask.new(:lib) do |t|
|
8
18
|
t.libs << 'test'
|
9
19
|
t.pattern = 'test/lib/**/*_test.rb'
|
10
20
|
t.verbose = true
|
11
21
|
end
|
12
|
-
|
22
|
+
|
13
23
|
Rake::TestTask.new(:generators) do |t|
|
14
24
|
t.libs << 'test'
|
15
25
|
t.pattern = 'test/generators/**/*_test.rb'
|
16
26
|
t.verbose = true
|
17
27
|
end
|
18
|
-
|
28
|
+
|
19
29
|
end
|
20
30
|
|
21
31
|
Rake::Task[:test].enhance do
|
@@ -1,31 +1,33 @@
|
|
1
1
|
class Comfy::Blog::BaseController < Comfy::Cms::BaseController
|
2
|
-
|
2
|
+
|
3
|
+
include Comfy::Paginate
|
4
|
+
|
3
5
|
layout :set_blog_layout
|
4
6
|
|
5
7
|
before_action :load_blog
|
6
8
|
|
7
9
|
protected
|
8
|
-
|
10
|
+
|
9
11
|
def load_cms_site
|
10
12
|
super
|
11
13
|
if @cms_site.path.blank? && params[:cms_path].present?
|
12
14
|
raise ActionController::RoutingError.new('Site Not Found')
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
def load_blog
|
17
19
|
@blog = if @cms_site.blogs.count <= 1
|
18
20
|
@cms_site.blogs.first!
|
19
21
|
else
|
20
22
|
@cms_site.blogs.where(:path => params[:blog_path]).first!
|
21
23
|
end
|
22
|
-
|
24
|
+
|
23
25
|
rescue ActiveRecord::RecordNotFound
|
24
26
|
raise ActionController::RoutingError.new('Blog Not Found')
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def set_blog_layout
|
28
30
|
@blog.app_layout
|
29
31
|
end
|
30
|
-
|
32
|
+
|
31
33
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class Comfy::Blog::PostsController < Comfy::Blog::BaseController
|
2
|
-
|
2
|
+
|
3
3
|
skip_before_action :load_blog, :only => [:serve]
|
4
|
-
|
4
|
+
|
5
5
|
# due to fancy routing it's hard to say if we need show or index
|
6
6
|
# action. let's figure it out here.
|
7
7
|
def serve
|
8
8
|
# if there are more than one blog, blog_path is expected
|
9
|
-
if @cms_site.blogs.count >= 2
|
9
|
+
if @cms_site.blogs.count >= 2
|
10
10
|
params[:blog_path] = params.delete(:slug) if params[:blog_path].blank?
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
load_blog
|
14
|
-
|
14
|
+
|
15
15
|
if params[:slug].present?
|
16
16
|
show && render(:show)
|
17
17
|
else
|
@@ -30,14 +30,14 @@ class Comfy::Blog::PostsController < Comfy::Blog::BaseController
|
|
30
30
|
limit = ComfyBlog.config.posts_per_page
|
31
31
|
respond_to do |format|
|
32
32
|
format.html do
|
33
|
-
@posts = scope
|
33
|
+
@posts = comfy_paginate(scope, limit)
|
34
34
|
end
|
35
35
|
format.rss do
|
36
36
|
@posts = scope.limit(limit)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def show
|
42
42
|
@post = if params[:slug] && params[:year] && params[:month]
|
43
43
|
@blog.posts.published.where(:year => params[:year], :month => params[:month], :slug => params[:slug]).first!
|
@@ -13,7 +13,7 @@ class Comfy::Blog::Post < ActiveRecord::Base
|
|
13
13
|
:presence => true
|
14
14
|
validates :slug,
|
15
15
|
:uniqueness => { :scope => [:blog_id, :year, :month] },
|
16
|
-
:format
|
16
|
+
:format => { :with => /\A%*\w[a-z0-9_\-\%]*\z/i }
|
17
17
|
|
18
18
|
# -- Scopes ---------------------------------------------------------------
|
19
19
|
default_scope -> {
|
data/comfy_blog.gemspec
CHANGED
data/config/environments/test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateBlog < ActiveRecord::Migration
|
2
|
-
|
2
|
+
|
3
3
|
def self.up
|
4
4
|
create_table :comfy_blogs do |t|
|
5
5
|
t.integer :site_id, :null => false
|
@@ -11,7 +11,7 @@ class CreateBlog < ActiveRecord::Migration
|
|
11
11
|
end
|
12
12
|
add_index :comfy_blogs, [:site_id, :path]
|
13
13
|
add_index :comfy_blogs, :identifier
|
14
|
-
|
14
|
+
|
15
15
|
create_table :comfy_blog_posts do |t|
|
16
16
|
t.integer :blog_id, :null => false
|
17
17
|
t.string :title, :null => false
|
@@ -29,7 +29,7 @@ class CreateBlog < ActiveRecord::Migration
|
|
29
29
|
:name => 'index_blog_posts_on_published_year_month_slug'
|
30
30
|
add_index :comfy_blog_posts, [:is_published, :created_at]
|
31
31
|
add_index :comfy_blog_posts, :created_at
|
32
|
-
|
32
|
+
|
33
33
|
create_table :comfy_blog_comments do |t|
|
34
34
|
t.integer :post_id, :null => false
|
35
35
|
t.string :author, :null => false
|
@@ -42,11 +42,11 @@ class CreateBlog < ActiveRecord::Migration
|
|
42
42
|
add_index :comfy_blog_comments, [:post_id, :is_published, :created_at],
|
43
43
|
:name => 'index_blog_comments_on_post_published_created'
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def self.down
|
47
47
|
drop_table :comfy_blogs
|
48
|
-
drop_table :
|
49
|
-
drop_table :
|
48
|
+
drop_table :comfy_blog_posts
|
49
|
+
drop_table :comfy_blog_comments
|
50
50
|
end
|
51
|
-
|
52
|
-
end
|
51
|
+
|
52
|
+
end
|
data/lib/comfy_blog/version.rb
CHANGED
data/test/models/posts_test.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
class BlogPostsTest < ActiveSupport::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
def test_fixtures_validity
|
6
6
|
Comfy::Blog::Post.all.each do |post|
|
7
7
|
assert post.valid?, post.errors.full_messages.to_s
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_validations
|
12
12
|
post = Comfy::Blog::Post.new
|
13
13
|
assert post.invalid?
|
14
14
|
assert_errors_on post, :blog_id, :title, :slug, :content
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_validation_of_slug_uniqueness
|
18
18
|
old_post = comfy_blog_posts(:default)
|
19
19
|
old_post.update_attributes!(:published_at => Time.now)
|
@@ -27,7 +27,16 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
27
27
|
old_post.update_attributes!(:published_at => 1.year.ago)
|
28
28
|
assert post.valid?
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
def test_validation_of_slug_format
|
32
|
+
post = comfy_blog_blogs(:default).posts.new(
|
33
|
+
:title => 'Test Title',
|
34
|
+
:slug => 'test%slug',
|
35
|
+
:content => 'Test Content'
|
36
|
+
)
|
37
|
+
assert post.valid?
|
38
|
+
end
|
39
|
+
|
31
40
|
def test_creation
|
32
41
|
assert_difference 'Comfy::Blog::Post.count' do
|
33
42
|
post = comfy_blog_blogs(:default).posts.create!(
|
@@ -39,13 +48,13 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
39
48
|
assert_equal Time.now.month, post.month
|
40
49
|
end
|
41
50
|
end
|
42
|
-
|
51
|
+
|
43
52
|
def test_set_slug
|
44
53
|
post = Comfy::Blog::Post.new(:title => 'Test Title')
|
45
54
|
post.send(:set_slug)
|
46
55
|
assert_equal 'test-title', post.slug
|
47
56
|
end
|
48
|
-
|
57
|
+
|
49
58
|
def test_set_date
|
50
59
|
post = Comfy::Blog::Post.new
|
51
60
|
post.send(:set_published_at)
|
@@ -53,13 +62,13 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
53
62
|
assert_equal post.published_at.year, post.year
|
54
63
|
assert_equal post.published_at.month, post.month
|
55
64
|
end
|
56
|
-
|
65
|
+
|
57
66
|
def test_set_published_at
|
58
67
|
post = Comfy::Blog::Post.new
|
59
68
|
post.send(:set_published_at)
|
60
69
|
assert post.published_at.present?
|
61
70
|
end
|
62
|
-
|
71
|
+
|
63
72
|
def test_destroy
|
64
73
|
assert_difference ['Comfy::Blog::Post.count', 'Comfy::Blog::Comment.count'], -1 do
|
65
74
|
comfy_blog_posts(:default).destroy
|
@@ -84,5 +93,5 @@ class BlogPostsTest < ActiveSupport::TestCase
|
|
84
93
|
assert_equal 1, Comfy::Blog::Post.for_month(1).count
|
85
94
|
assert_equal 0, Comfy::Blog::Post.for_month(2).count
|
86
95
|
end
|
87
|
-
|
96
|
+
|
88
97
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comfy_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Khabarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: comfortable_mexican_sofa
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.12.
|
19
|
+
version: 1.12.7
|
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: 1.12.
|
26
|
+
version: 1.12.7
|
27
27
|
description: Simple Blog Engine for ComfortableMexicanSofa
|
28
28
|
email:
|
29
29
|
- oleg@khabarov.ca
|