refinerycms-blog 1.3.2 → 1.4.0

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.
Files changed (39) hide show
  1. data/app/controllers/blog/posts_controller.rb +14 -1
  2. data/app/models/blog_post.rb +15 -9
  3. data/app/models/categorization.rb +2 -0
  4. data/app/views/admin/blog/posts/_form.html.erb +8 -1
  5. data/app/views/blog/posts/_post.html.erb +2 -4
  6. data/app/views/blog/posts/archive.html.erb +1 -2
  7. data/app/views/blog/posts/index.html.erb +1 -0
  8. data/app/views/blog/posts/show.html.erb +1 -0
  9. data/app/views/blog/posts/tagged.html.erb +22 -0
  10. data/app/views/blog/shared/_post.html.erb +7 -3
  11. data/app/views/blog/shared/_tags.html.erb +8 -0
  12. data/changelog.md +6 -1
  13. data/config/locales/cs.yml +128 -0
  14. data/config/locales/en.yml +5 -0
  15. data/config/locales/nb.yml +7 -0
  16. data/config/locales/nl.yml +120 -10
  17. data/config/locales/pt-BR.yml +3 -0
  18. data/config/locales/sk.yml +128 -0
  19. data/config/locales/zh-CN.yml +128 -0
  20. data/config/routes.rb +2 -1
  21. data/db/migrate/3_acts_as_taggable_on_migration.rb +28 -0
  22. data/db/migrate/4_create_seo_meta_for_blog.rb +25 -0
  23. data/db/seeds/refinerycms_blog.rb +18 -14
  24. data/features/authors.feature +4 -4
  25. data/features/support/factories/blog_categories.rb +2 -1
  26. data/features/support/factories/blog_comments.rb +2 -4
  27. data/features/support/factories/blog_posts.rb +3 -0
  28. data/features/support/step_definitions/tags_steps.rb +11 -0
  29. data/features/tags.feature +26 -0
  30. data/lib/gemspec.rb +12 -6
  31. data/lib/refinery/blog/version.rb +17 -0
  32. data/lib/refinerycms-blog.rb +10 -9
  33. data/readme.md +1 -1
  34. data/spec/models/blog_category_spec.rb +41 -0
  35. data/spec/models/{blog_comments_spec.rb → blog_comment_spec.rb} +0 -0
  36. data/spec/models/blog_post_spec.rb +187 -0
  37. metadata +53 -10
  38. data/spec/models/blog_categories_spec.rb +0 -41
  39. data/spec/models/blog_posts_spec.rb +0 -176
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
- Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
-
4
- describe BlogCategory do
5
- before(:each) do
6
- @attr = { :title => "RefineryCMS" }
7
- end
8
-
9
- describe "validations" do
10
- it "requires title" do
11
- BlogCategory.new(@attr.merge(:title => "")).should_not be_valid
12
- end
13
-
14
- it "won't allow duplicate titles" do
15
- BlogCategory.create!(@attr)
16
- BlogCategory.new(@attr).should_not be_valid
17
- end
18
- end
19
-
20
- describe "blog posts association" do
21
- it "has a posts attribute" do
22
- BlogCategory.new.should respond_to(:posts)
23
- end
24
-
25
- it "returns posts by published_at date in descending order" do
26
- @category = BlogCategory.create!(@attr)
27
- @first_post = @category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday })
28
- @latest_post = @category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now })
29
- @category.posts.first.should == @latest_post
30
- end
31
-
32
- end
33
-
34
- describe "#post_count" do
35
- it "returns post count in category" do
36
- Factory(:post, :categories => [Factory(:blog_category)])
37
- Factory(:post, :categories => [Factory(:blog_category)])
38
- BlogCategory.first.post_count.should == 2
39
- end
40
- end
41
- end
@@ -1,176 +0,0 @@
1
- require 'spec_helper'
2
- Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
-
4
- describe BlogPost do
5
- describe "validations" do
6
- before(:each) do
7
- @attr = { :title => "RefineryCMS", :body => "Some random text ..." }
8
- end
9
-
10
- it "requires title" do
11
- BlogPost.new(@attr.merge(:title => "")).should_not be_valid
12
- end
13
-
14
- it "won't allow duplicate titles" do
15
- BlogPost.create!(@attr)
16
- BlogPost.new(@attr).should_not be_valid
17
- end
18
-
19
- it "requires body" do
20
- BlogPost.new(@attr.merge(:body => nil)).should_not be_valid
21
- end
22
- end
23
-
24
- describe "comments association" do
25
- before(:each) do
26
- @blog_post = Factory(:post)
27
- end
28
-
29
- it "have a comments attribute" do
30
- @blog_post.should respond_to(:comments)
31
- end
32
-
33
- it "destroys associated comments" do
34
- Factory(:blog_comment, :blog_post_id => @blog_post)
35
- @blog_post.destroy
36
- BlogComment.find_by_blog_post_id(@blog_post).should be_nil
37
- end
38
- end
39
-
40
- describe "categories association" do
41
- before(:each) do
42
- @blog_post = Factory(:post)
43
- end
44
-
45
- it "have categories attribute" do
46
- @blog_post.should respond_to(:categories)
47
- end
48
- end
49
-
50
- describe "authors" do
51
- it "are authored" do
52
- BlogPost.instance_methods.map(&:to_sym).include? :author
53
- end
54
- end
55
-
56
- describe "by_archive scope" do
57
- it "returns all posts from specified month" do
58
- blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2))
59
- blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
60
- Factory(:post, :published_at => Time.now - 2.months)
61
- date = "#{Time.now.month}/#{Time.now.year}"
62
- BlogPost.by_archive(Time.parse(date)).count.should == 2
63
- BlogPost.by_archive(Time.parse(date)).should == [blog_post2, blog_post1]
64
- end
65
- end
66
-
67
- describe "all_previous scope" do
68
- it "returns all posts from previous months" do
69
- blog_post1 = Factory(:post, :published_at => Time.now.advance(:months => -2))
70
- blog_post2 = Factory(:post, :published_at => Time.now.advance(:months => -1))
71
- Factory(:post, :published_at => Time.now)
72
- BlogPost.all_previous.count.should == 2
73
- BlogPost.all_previous.should == [blog_post2, blog_post1]
74
- end
75
- end
76
-
77
- describe "live scope" do
78
- it "returns all posts which aren't in draft and pub date isn't in future" do
79
- blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2))
80
- blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
81
- Factory(:post, :draft => true)
82
- Factory(:post, :published_at => Time.now + 1.minute)
83
- BlogPost.live.count.should == 2
84
- BlogPost.live.should == [blog_post2, blog_post1]
85
- end
86
- end
87
-
88
- describe "next scope" do
89
- it "returns next article based on given article" do
90
- blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
91
- blog_post2 = Factory(:post)
92
- BlogPost.next(blog_post1).should == [blog_post2]
93
- end
94
- end
95
-
96
- describe "previous scope" do
97
- it "returns previous article based on given article" do
98
- blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
99
- blog_post2 = Factory(:post)
100
- BlogPost.previous(blog_post2).should == [blog_post1]
101
- end
102
- end
103
-
104
- describe "uncategorized scope" do
105
- it "returns uncategorized posts if they exist" do
106
- uncategorized_blog_post = Factory(:post)
107
- categorized_blog_post = Factory(:post)
108
-
109
- categorized_blog_post.categories << Factory(:blog_category)
110
-
111
- BlogPost.uncategorized.should include uncategorized_blog_post
112
- BlogPost.uncategorized.should_not include categorized_blog_post
113
- end
114
- end
115
-
116
- describe "#live?" do
117
- it "returns true if post is not in draft and it's published" do
118
- Factory(:post).live?.should be_true
119
- end
120
-
121
- it "returns false if post is in draft" do
122
- Factory(:post, :draft => true).live?.should be_false
123
- end
124
-
125
- it "returns false if post pub date is in future" do
126
- Factory(:post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
127
- end
128
- end
129
-
130
- describe "#next" do
131
- it "returns next article when called on current article" do
132
- Factory(:post, :published_at => Time.now.advance(:minutes => -1))
133
- blog_post = Factory(:post)
134
- blog_posts = BlogPost.all
135
- blog_posts.last.next.should == blog_post
136
- end
137
- end
138
-
139
- describe "#prev" do
140
- it "returns previous article when called on current article" do
141
- Factory(:post)
142
- blog_post = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
143
- blog_posts = BlogPost.all
144
- blog_posts.first.prev.should == blog_post
145
- end
146
- end
147
-
148
- describe "#category_ids=" do
149
- before(:each) do
150
- @blog_post = Factory(:post)
151
- @cat1 = Factory(:blog_category, :id => 1)
152
- @cat2 = Factory(:blog_category, :id => 2)
153
- @cat3 = Factory(:blog_category, :id => 3)
154
- @blog_post.category_ids = [1,2,"","",3]
155
- end
156
-
157
- it "rejects blank category ids" do
158
- @blog_post.categories.count.should == 3
159
- end
160
-
161
- it "returns array of categories based on given ids" do
162
- @blog_post.categories.should == [@cat1, @cat2, @cat3]
163
- end
164
- end
165
-
166
- describe ".comments_allowed?" do
167
- it "returns true if comments_allowed setting is set to true" do
168
- BlogPost.comments_allowed?.should be_true
169
- end
170
-
171
- it "returns false if comments_allowed setting is set to false" do
172
- RefinerySetting.set(:comments_allowed, {:scoping => 'blog', :value => false})
173
- BlogPost.comments_allowed?.should be_false
174
- end
175
- end
176
- end