refinerycms-blog 1.1 → 1.2

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 (51) hide show
  1. data/app/controllers/admin/blog/posts_controller.rb +53 -0
  2. data/app/controllers/admin/blog/settings_controller.rb +14 -2
  3. data/app/controllers/blog/posts_controller.rb +18 -7
  4. data/app/helpers/blog_posts_helper.rb +23 -7
  5. data/app/models/blog_category.rb +4 -11
  6. data/app/models/blog_comment.rb +11 -3
  7. data/app/models/blog_post.rb +35 -14
  8. data/app/models/categorization.rb +5 -0
  9. data/app/views/admin/blog/_submenu.html.erb +37 -27
  10. data/app/views/admin/blog/categories/_category.html.erb +3 -3
  11. data/app/views/admin/blog/categories/_form.html.erb +1 -1
  12. data/app/views/admin/blog/categories/index.html.erb +2 -6
  13. data/app/views/admin/blog/comments/_comment.html.erb +2 -2
  14. data/app/views/admin/blog/posts/_form.html.erb +1 -1
  15. data/app/views/admin/blog/posts/_post.html.erb +5 -5
  16. data/app/views/admin/blog/posts/index.html.erb +2 -6
  17. data/app/views/admin/blog/posts/uncategorized.html.erb +26 -0
  18. data/app/views/admin/blog/settings/notification_recipients.html.erb +1 -1
  19. data/app/views/blog/posts/_nav.html.erb +9 -11
  20. data/app/views/blog/posts/_post.html.erb +5 -7
  21. data/app/views/blog/posts/archive.html.erb +8 -6
  22. data/app/views/blog/posts/index.html.erb +10 -7
  23. data/app/views/blog/posts/show.html.erb +5 -4
  24. data/app/views/blog/shared/_categories.html.erb +10 -8
  25. data/app/views/blog/shared/_post.html.erb +9 -7
  26. data/app/views/blog/shared/_posts.html.erb +10 -8
  27. data/app/views/blog/shared/_rss_feed.html.erb +1 -1
  28. data/changelog.md +24 -0
  29. data/config/locales/de.yml +128 -0
  30. data/config/locales/en.yml +17 -3
  31. data/config/locales/es.yml +122 -0
  32. data/config/locales/fr.yml +125 -0
  33. data/config/locales/it.yml +1 -0
  34. data/config/locales/pl.yml +134 -0
  35. data/config/locales/pt-BR.yml +125 -0
  36. data/config/locales/ru.yml +125 -0
  37. data/config/routes.rb +5 -2
  38. data/features/authors.feature +15 -0
  39. data/features/support/factories/blog_categories.rb +1 -1
  40. data/features/support/factories/blog_posts.rb +3 -1
  41. data/features/support/step_definitions/authors_steps.rb +7 -0
  42. data/lib/gemspec.rb +1 -0
  43. data/lib/generators/refinerycms_blog/templates/db/migrate/migration_number_add_user_id_to_blog_posts.rb +11 -0
  44. data/lib/generators/refinerycms_blog_generator.rb +14 -7
  45. data/lib/refinerycms-blog.rb +2 -6
  46. data/public/javascripts/refinery/refinerycms-blog.js +3 -3
  47. data/spec/models/blog_categories_spec.rb +28 -8
  48. data/spec/models/blog_posts_spec.rb +167 -7
  49. metadata +16 -20
  50. data/Gemfile +0 -2
  51. data/Gemfile.lock +0 -11
@@ -2,15 +2,175 @@ require 'spec_helper'
2
2
  Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
3
 
4
4
  describe BlogPost do
5
- context "wiring up" 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 => "")).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 - 2.minutes)
59
+ blog_post2 = Factory(:post, :published_at => Time.now - 1.minute)
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 - 1.month)
70
+ blog_post2 = Factory(:post, :published_at => Time.now - 1.month)
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 - 2.minutes)
80
+ blog_post2 = Factory(:post, :published_at => Time.now - 1.minute)
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
6
87
 
7
- before(:each) do
8
- @post = Factory(:post)
9
- end
88
+ describe "next scope" do
89
+ it "returns next article based on given article" do
90
+ blog_post1 = Factory(:post)
91
+ blog_post2 = Factory(:post, :published_at => Time.now + 1.minute)
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)
99
+ blog_post2 = Factory(:post, :published_at => Time.now + 1.minute)
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 + 1.minute).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)
133
+ blog_post = Factory(:post, :published_at => Time.now + 1.minute)
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 - 1.minute)
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
10
160
 
11
- it "saves to the database" do
12
- @post.should_not be_nil
13
- end
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
14
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
15
174
  end
175
+ end
16
176
  end
metadata CHANGED
@@ -1,11 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-blog
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 1
8
- version: "1.1"
4
+ prerelease:
5
+ version: "1.2"
9
6
  platform: ruby
10
7
  authors:
11
8
  - Resolve Digital
@@ -14,7 +11,7 @@ autorequire:
14
11
  bindir: bin
15
12
  cert_chain: []
16
13
 
17
- date: 2010-12-03 00:00:00 +13:00
14
+ date: 2011-03-02 00:00:00 +13:00
18
15
  default_executable:
19
16
  dependencies:
20
17
  - !ruby/object:Gem::Dependency
@@ -25,10 +22,6 @@ dependencies:
25
22
  requirements:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 9
31
- - 8
32
25
  version: 0.9.8
33
26
  type: :runtime
34
27
  version_requirements: *id001
@@ -40,9 +33,6 @@ dependencies:
40
33
  requirements:
41
34
  - - ~>
42
35
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- - 2
46
36
  version: "0.2"
47
37
  type: :runtime
48
38
  version_requirements: *id002
@@ -68,6 +58,7 @@ files:
68
58
  - app/models/blog_category.rb
69
59
  - app/models/blog_comment.rb
70
60
  - app/models/blog_post.rb
61
+ - app/models/categorization.rb
71
62
  - app/views/admin/blog/_submenu.html.erb
72
63
  - app/views/admin/blog/categories/_category.html.erb
73
64
  - app/views/admin/blog/categories/_form.html.erb
@@ -87,6 +78,7 @@ files:
87
78
  - app/views/admin/blog/posts/edit.html.erb
88
79
  - app/views/admin/blog/posts/index.html.erb
89
80
  - app/views/admin/blog/posts/new.html.erb
81
+ - app/views/admin/blog/posts/uncategorized.html.erb
90
82
  - app/views/admin/blog/settings/notification_recipients.html.erb
91
83
  - app/views/blog/categories/show.html.erb
92
84
  - app/views/blog/comment_mailer/notification.html.erb
@@ -101,21 +93,29 @@ files:
101
93
  - app/views/blog/shared/_post.html.erb
102
94
  - app/views/blog/shared/_posts.html.erb
103
95
  - app/views/blog/shared/_rss_feed.html.erb
96
+ - changelog.md
97
+ - config/locales/de.yml
104
98
  - config/locales/en.yml
99
+ - config/locales/es.yml
100
+ - config/locales/fr.yml
105
101
  - config/locales/it.yml
106
102
  - config/locales/nb.yml
107
103
  - config/locales/nl.yml
104
+ - config/locales/pl.yml
105
+ - config/locales/pt-BR.yml
106
+ - config/locales/ru.yml
108
107
  - config/routes.rb
108
+ - features/authors.feature
109
109
  - features/support/factories/blog_categories.rb
110
110
  - features/support/factories/blog_comments.rb
111
111
  - features/support/factories/blog_posts.rb
112
112
  - features/support/paths.rb
113
- - Gemfile
114
- - Gemfile.lock
113
+ - features/support/step_definitions/authors_steps.rb
115
114
  - generators/refinerycms_blog/refinerycms_blog_generator.rb
116
115
  - generators/refinerycms_blog/templates/db/migrate/migration.rb
117
116
  - generators/refinerycms_blog/templates/db/seeds/seed.rb
118
117
  - lib/gemspec.rb
118
+ - lib/generators/refinerycms_blog/templates/db/migrate/migration_number_add_user_id_to_blog_posts.rb
119
119
  - lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
120
120
  - lib/generators/refinerycms_blog/templates/db/seeds/seed.rb
121
121
  - lib/generators/refinerycms_blog_generator.rb
@@ -157,21 +157,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
- segments:
161
- - 0
162
160
  version: "0"
163
161
  required_rubygems_version: !ruby/object:Gem::Requirement
164
162
  none: false
165
163
  requirements:
166
164
  - - ">="
167
165
  - !ruby/object:Gem::Version
168
- segments:
169
- - 0
170
166
  version: "0"
171
167
  requirements: []
172
168
 
173
169
  rubyforge_project:
174
- rubygems_version: 1.3.7
170
+ rubygems_version: 1.5.2
175
171
  signing_key:
176
172
  specification_version: 3
177
173
  summary: Ruby on Rails blogging engine for RefineryCMS.
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- gem 'filters_spam', '~> 0.3'
2
- gem "will_paginate", ">= 2.3.14"
data/Gemfile.lock DELETED
@@ -1,11 +0,0 @@
1
- GEM
2
- specs:
3
- filters_spam (0.3)
4
- will_paginate (2.3.14)
5
-
6
- PLATFORMS
7
- ruby
8
-
9
- DEPENDENCIES
10
- filters_spam (~> 0.3)
11
- will_paginate (>= 2.3.14)