refinerycms-blog 2.1.0 → 3.0.1

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -23
  3. data/Gemfile +15 -7
  4. data/Rakefile +0 -1
  5. data/app/assets/javascripts/refinery/blog/backend.js +18 -59
  6. data/app/assets/stylesheets/refinery/blog/backend.css.scss +4 -55
  7. data/app/assets/stylesheets/refinery/blog/frontend.css.scss +2 -2
  8. data/app/controllers/refinery/blog/admin/categories_controller.rb +6 -0
  9. data/app/controllers/refinery/blog/admin/posts_controller.rb +25 -3
  10. data/app/controllers/refinery/blog/blog_controller.rb +31 -5
  11. data/app/controllers/refinery/blog/categories_controller.rb +10 -3
  12. data/app/controllers/refinery/blog/posts_controller.rb +16 -6
  13. data/app/helpers/refinery/blog/controller_helper.rb +1 -22
  14. data/app/models/refinery/blog/categorization.rb +0 -1
  15. data/app/models/refinery/blog/category.rb +3 -6
  16. data/app/models/refinery/blog/comment.rb +15 -17
  17. data/app/models/refinery/blog/post.rb +44 -43
  18. data/app/views/refinery/blog/admin/_submenu.html.erb +1 -3
  19. data/app/views/refinery/blog/admin/categories/_category.html.erb +14 -5
  20. data/app/views/refinery/blog/admin/posts/_form.html.erb +13 -6
  21. data/app/views/refinery/blog/admin/posts/_form_part.html.erb +1 -1
  22. data/app/views/refinery/blog/admin/posts/_post.html.erb +12 -5
  23. data/app/views/refinery/blog/admin/posts/_teaser_part.html.erb +1 -1
  24. data/app/views/refinery/blog/posts/index.html.erb +2 -2
  25. data/app/views/refinery/blog/shared/_categories.html.erb +3 -3
  26. data/app/views/refinery/shared/admin/_autocomplete.html.erb +45 -0
  27. data/bin/rails +5 -0
  28. data/bin/refinerycms +62 -0
  29. data/changelog.md +4 -1
  30. data/config/locales/cs.yml +2 -2
  31. data/config/locales/en.yml +3 -0
  32. data/config/locales/fr.yml +6 -4
  33. data/config/locales/nb.yml +154 -14
  34. data/config/locales/nl.yml +21 -0
  35. data/config/locales/pl.yml +2 -2
  36. data/config/locales/ru.yml +25 -14
  37. data/config/locales/zh-CN.yml +32 -1
  38. data/config/locales/zh-TW.yml +160 -0
  39. data/config/routes.rb +6 -3
  40. data/db/migrate/20110803223522_create_blog_structure.rb +4 -4
  41. data/db/migrate/20120531113632_delete_cached_slugs.rb +2 -2
  42. data/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  43. data/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  44. data/db/seeds.rb +4 -4
  45. data/lib/refinery/blog.rb +1 -1
  46. data/lib/refinery/blog/configuration.rb +1 -1
  47. data/lib/refinery/blog/engine.rb +8 -3
  48. data/readme.md +21 -6
  49. data/refinerycms-blog.gemspec +9 -7
  50. data/script/rails +1 -3
  51. data/spec/controllers/refinery/blog/admin/comments_controller_spec.rb +23 -19
  52. data/spec/controllers/refinery/blog/admin/posts_controller_spec.rb +35 -0
  53. data/spec/controllers/refinery/blog/posts_controller_spec.rb +3 -3
  54. data/spec/factories/blog_posts.rb +1 -1
  55. data/spec/factories/user.rb +27 -0
  56. data/spec/features/refinery/blog/admin/categories_spec.rb +106 -104
  57. data/spec/features/refinery/blog/admin/comments_spec.rb +18 -18
  58. data/spec/features/refinery/blog/admin/menu_spec.rb +14 -8
  59. data/spec/features/refinery/blog/admin/posts_spec.rb +99 -86
  60. data/spec/features/refinery/blog/categories_spec.rb +20 -18
  61. data/spec/features/refinery/blog/posts_spec.rb +128 -124
  62. data/spec/helpers/refinery/blog/posts_helper_spec.rb +13 -13
  63. data/spec/lib/refinery/blog/engine_spec.rb +1 -11
  64. data/spec/models/refinery/blog/category_spec.rb +10 -10
  65. data/spec/models/refinery/blog/comment_spec.rb +3 -3
  66. data/spec/models/refinery/blog/post_spec.rb +59 -33
  67. data/spec/spec_helper.rb +2 -3
  68. metadata +75 -50
  69. data/app/assets/images/refinery/blog/icons/add.png +0 -0
  70. data/app/assets/images/refinery/blog/icons/cog.png +0 -0
  71. data/app/assets/images/refinery/blog/icons/comment.png +0 -0
  72. data/app/assets/images/refinery/blog/icons/comment_cross.png +0 -0
  73. data/app/assets/images/refinery/blog/icons/comment_tick.png +0 -0
  74. data/app/assets/images/refinery/blog/icons/comments.png +0 -0
  75. data/app/assets/images/refinery/blog/icons/down.gif +0 -0
  76. data/app/assets/images/refinery/blog/icons/folder.png +0 -0
  77. data/app/assets/images/refinery/blog/icons/folder_add.png +0 -0
  78. data/app/assets/images/refinery/blog/icons/folder_edit.png +0 -0
  79. data/app/assets/images/refinery/blog/icons/page.png +0 -0
  80. data/app/assets/images/refinery/blog/icons/page_add.png +0 -0
  81. data/app/assets/images/refinery/blog/icons/page_copy.png +0 -0
  82. data/app/assets/images/refinery/blog/icons/up.gif +0 -0
  83. data/spec/helpers/refinery/blog/controller_helper_spec.rb +0 -27
  84. data/todo.md +0 -5
@@ -1,28 +1,30 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe "BlogCategories" do
5
- refinery_login_with :refinery_user
4
+ module Blog
5
+ describe Category, type: :feature do
6
+ refinery_login_with_devise :authentication_devise_refinery_user
6
7
 
7
- context "has one category and post" do
8
- before do
9
- post = Globalize.with_locale(:en) do
10
- FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post")
8
+ context "has one category and post" do
9
+ before do
10
+ post = Globalize.with_locale(:en) do
11
+ FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post")
12
+ end
13
+ @category = Globalize.with_locale(:en) do
14
+ FactoryGirl.create(:blog_category, :title => "Video Games")
15
+ end
16
+ post.categories << @category
17
+ post.save!
11
18
  end
12
- @category = Globalize.with_locale(:en) do
13
- FactoryGirl.create(:blog_category, :title => "Video Games")
14
- end
15
- post.categories << @category
16
- post.save!
17
- end
18
19
 
19
- describe "show categories blog posts" do
20
- it "should displays categories blog posts" do
21
- visit refinery.blog_category_path(@category)
22
- page.should have_content("Refinery CMS blog post")
23
- page.should have_content("Video Games")
20
+ describe "show categories blog posts" do
21
+ it "should displays categories blog posts" do
22
+ visit refinery.blog_category_path(@category)
23
+ expect(page).to have_content("Refinery CMS blog post")
24
+ expect(page).to have_content("Video Games")
25
+ end
24
26
  end
25
27
  end
26
28
  end
27
29
  end
28
- end
30
+ end
@@ -1,178 +1,182 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe "Blog::Posts" do
5
- refinery_login_with :refinery_user
4
+ module Blog
5
+ describe Post, type: :feature do
6
+ refinery_login_with_devise :authentication_devise_refinery_user
6
7
 
7
- context "when has blog posts" do
8
- let!(:blog_post) do
9
- Globalize.with_locale(:en) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") }
10
- end
8
+ context "when has blog posts" do
9
+ let!(:blog_post) do
10
+ Globalize.with_locale(:en) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") }
11
+ end
11
12
 
12
- it "should display blog post" do
13
- visit refinery.blog_post_path(blog_post)
13
+ it "should display blog post" do
14
+ visit refinery.blog_post_path(blog_post)
14
15
 
15
- page.should have_content(blog_post.title)
16
- end
16
+ expect(page).to have_content(blog_post.title)
17
+ end
17
18
 
18
- describe "visit blog" do
19
+ describe "visit blog" do
19
20
 
20
- before do
21
- FactoryGirl.create(:page, :link_url => "/")
22
- FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog")
23
- end
21
+ before do
22
+ FactoryGirl.create(:page, :link_url => "/")
23
+ FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog")
24
+ end
24
25
 
25
- it "shows blog link in menu" do
26
- visit "/"
27
- within "#menu" do
28
- page.should have_content("Blog")
29
- page.should have_selector("a[href='/blog']")
26
+ it "shows blog link in menu" do
27
+ visit "/"
28
+ within "#menu" do
29
+ expect(page).to have_content("Blog")
30
+ expect(page).to have_selector("a[href='/blog']")
31
+ end
32
+ end
33
+
34
+ it "shows blog posts" do
35
+ visit refinery.blog_root_path
36
+ expect(page).to have_content blog_post.title
30
37
  end
31
- end
32
38
 
33
- it "shows blog posts" do
34
- visit refinery.blog_root_path
35
- page.should have_content blog_post.title
36
39
  end
37
40
 
38
41
  end
39
42
 
40
- end
41
-
42
- describe "list tagged posts" do
43
- context "when has tagged blog posts" do
44
- before do
45
- @tag_name = "chicago"
46
- @post = FactoryGirl.create(:blog_post,
47
- :title => "I Love my city",
48
- :tag_list => @tag_name)
49
- @tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
50
- end
51
- it "should have one tagged post" do
52
- visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
53
-
54
- page.should have_content(@tag_name)
55
- page.should have_content(@post.title)
43
+ describe "list tagged posts" do
44
+ context "when has tagged blog posts" do
45
+ let!(:tag_name) { "chicago" }
46
+ let!(:post) {
47
+ FactoryGirl.create(:blog_post,
48
+ :title => "I Love my city",
49
+ :tag_list => tag_name
50
+ )
51
+ }
52
+ let!(:tag) { ::Refinery::Blog::Post.tag_counts_on(:tags).first }
53
+
54
+ it "should have one tagged post" do
55
+ visit refinery.blog_tagged_posts_path(tag.id, tag_name.parameterize)
56
+
57
+ expect(page).to have_content(tag_name)
58
+ expect(page).to have_content(post.title)
59
+ end
56
60
  end
57
61
  end
58
- end
59
62
 
60
- describe "#show" do
61
- context "when has no comments" do
62
- let(:blog_post) { FactoryGirl.create(:blog_post) }
63
+ describe "#show" do
64
+ context "when has no comments" do
65
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
63
66
 
64
- it "should display the blog post" do
65
- visit refinery.blog_post_path(blog_post)
66
- page.should have_content(blog_post.title)
67
- page.should have_content(blog_post.body)
67
+ it "should display the blog post" do
68
+ visit refinery.blog_post_path(blog_post)
69
+ expect(page).to have_content(blog_post.title)
70
+ expect(page).to have_content(blog_post.body)
71
+ end
68
72
  end
69
- end
70
- context "when has approved comments" do
71
- let(:approved_comment) { FactoryGirl.create(:approved_comment) }
73
+ context "when has approved comments" do
74
+ let!(:approved_comment) { FactoryGirl.create(:approved_comment) }
72
75
 
73
- it "should display the comments" do
74
- visit refinery.blog_post_path(approved_comment.post)
76
+ it "should display the comments" do
77
+ visit refinery.blog_post_path(approved_comment.post)
75
78
 
76
- page.should have_content(approved_comment.body)
77
- page.should have_content("Posted by #{approved_comment.name}")
79
+ expect(page).to have_content(approved_comment.body)
80
+ expect(page).to have_content("Posted by #{approved_comment.name}")
81
+ end
78
82
  end
79
- end
80
- context "when has rejected comments" do
81
- let(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
83
+ context "when has rejected comments" do
84
+ let!(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
82
85
 
83
- it "should not display the comments" do
84
- visit refinery.blog_post_path(rejected_comment.post)
86
+ it "should not display the comments" do
87
+ visit refinery.blog_post_path(rejected_comment.post)
85
88
 
86
- page.should_not have_content(rejected_comment.body)
89
+ expect(page).not_to have_content(rejected_comment.body)
90
+ end
87
91
  end
88
- end
89
- context "when has new comments" do
90
- let(:blog_comment) { FactoryGirl.create(:blog_comment) }
92
+ context "when has new comments" do
93
+ let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
91
94
 
92
- it "should not display the comments" do
93
- visit refinery.blog_post_path(blog_comment.post)
95
+ it "should not display the comments" do
96
+ visit refinery.blog_post_path(blog_comment.post)
94
97
 
95
- page.should_not have_content(blog_comment.body)
98
+ expect(page).not_to have_content(blog_comment.body)
99
+ end
96
100
  end
97
- end
98
101
 
99
- context "when posting comments" do
100
- let(:blog_post) { FactoryGirl.create(:blog_post) }
101
- let(:name) { "pete" }
102
- let(:email) { "pete@mcawesome.com" }
103
- let(:body) { "Witty comment." }
102
+ context "when posting comments" do
103
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
104
+ let(:name) { "pete" }
105
+ let(:email) { "pete@mcawesome.com" }
106
+ let(:body) { "Witty comment." }
104
107
 
105
- before do
106
- visit refinery.blog_post_path(blog_post)
108
+ before do
109
+ visit refinery.blog_post_path(blog_post)
107
110
 
108
- fill_in "Name", :with => name
109
- fill_in "Email", :with => email
110
- fill_in "Message", :with => body
111
- click_button "Send comment"
112
- end
111
+ fill_in "Name", :with => name
112
+ fill_in "Email", :with => email
113
+ fill_in "Message", :with => body
114
+ click_button "Send comment"
115
+ end
113
116
 
114
- it "creates the comment" do
115
- comment = blog_post.reload.comments.last
117
+ it "creates the comment" do
118
+ comment = blog_post.reload.comments.last
116
119
 
117
- comment.name.should eq(name)
118
- comment.email.should eq(email)
119
- comment.body.should eq(body)
120
+ expect(comment.name).to eq(name)
121
+ expect(comment.email).to eq(email)
122
+ expect(comment.body).to eq(body)
123
+ end
120
124
  end
121
- end
122
125
 
123
- context "post popular" do
124
- let(:blog_post) { FactoryGirl.create(:blog_post) }
125
- let(:blog_post2) { FactoryGirl.create(:blog_post) }
126
+ context "post popular" do
127
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
128
+ let!(:blog_post2) { FactoryGirl.create(:blog_post) }
126
129
 
127
- before do
128
- visit refinery.blog_post_path(blog_post)
129
- end
130
+ before do
131
+ visit refinery.blog_post_path(blog_post)
132
+ end
130
133
 
131
- it "should increment access count" do
132
- blog_post.reload.access_count.should eq(1)
133
- visit refinery.blog_post_path(blog_post)
134
- blog_post.reload.access_count.should eq(2)
135
- end
134
+ it "should increment access count" do
135
+ expect(blog_post.reload.access_count).to eq(1)
136
+ visit refinery.blog_post_path(blog_post)
137
+ expect(blog_post.reload.access_count).to eq(2)
138
+ end
136
139
 
137
- it "should be most popular" do
138
- Refinery::Blog::Post.popular(2).first.should eq(blog_post)
140
+ it "should be most popular" do
141
+ expect(Refinery::Blog::Post.popular(2).first).to eq(blog_post)
142
+ end
139
143
  end
140
- end
141
144
 
142
- context "post recent" do
143
- let!(:blog_post) { FactoryGirl.create(:blog_post, :published_at => Time.now - 5.minutes) }
144
- let!(:blog_post2) { FactoryGirl.create(:blog_post, :published_at => Time.now - 2.minutes) }
145
+ context "post recent" do
146
+ let!(:blog_post) { FactoryGirl.create(:blog_post, :published_at => Time.now - 5.minutes) }
147
+ let!(:blog_post2) { FactoryGirl.create(:blog_post, :published_at => Time.now - 2.minutes) }
145
148
 
146
- it "should be the most recent" do
147
- Refinery::Blog::Post.recent(2).first.id.should eq(blog_post2.id)
149
+ it "should be the most recent" do
150
+ expect(Refinery::Blog::Post.recent(2).first.id).to eq(blog_post2.id)
151
+ end
148
152
  end
149
- end
150
153
 
151
- end
154
+ end
152
155
 
153
- describe "#show draft preview" do
154
- let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
156
+ describe "#show draft preview" do
157
+ let!(:blog_post) { FactoryGirl.create(:blog_post_draft) }
155
158
 
156
- context "when logged in as admin" do
157
- it "should display the draft notification" do
158
- visit refinery.blog_post_path(blog_post)
159
+ context "when logged in as admin" do
160
+ it "should display the draft notification" do
161
+ visit refinery.blog_post_path(blog_post)
159
162
 
160
- page.should have_content('This page is NOT live for public viewing.')
163
+ expect(page).to have_content('This page is NOT live for public viewing.')
164
+ end
161
165
  end
162
- end
163
166
 
164
- context "when not logged in as an admin" do
165
- before do
166
- # TODO: remove Refinery::Pages::Engine.load_seed dependency.
167
- # It's here to temporary fix the issue with 404 after visiting logout path.
168
- Refinery::Pages::Engine.load_seed
169
- visit refinery.logout_path
170
- end
167
+ context "when not logged in as an admin" do
168
+ before do
169
+ # TODO: remove Refinery::Pages::Engine.load_seed dependency.
170
+ # It's here to temporary fix the issue with 404 after visiting logout path.
171
+ Refinery::Pages::Engine.load_seed
172
+ visit refinery.logout_path
173
+ end
171
174
 
172
- it "should not display the blog post" do
173
- visit refinery.blog_post_path(blog_post)
175
+ it "should not display the blog post" do
176
+ visit refinery.blog_post_path(blog_post)
174
177
 
175
- page.should have_content("The page you requested was not found.")
178
+ expect(page).to have_content("The page you requested was not found.")
179
+ end
176
180
  end
177
181
  end
178
182
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  module Refinery
4
4
  module Blog
5
- describe PostsHelper do
6
- describe "#blog_archive_widget" do
5
+ describe PostsHelper, :type => :helper do
6
+ describe "#blog_archive_widget", type: :helper do
7
7
  let(:html) { helper.blog_archive_widget(dates) }
8
8
  let(:links) { Capybara.string(html).find("#blog_archive_widget ul") }
9
9
 
@@ -11,7 +11,7 @@ module Refinery
11
11
  let(:dates) { [] }
12
12
 
13
13
  it "does not display anything" do
14
- html.should be_blank
14
+ expect(html).to be_blank
15
15
  end
16
16
  end
17
17
 
@@ -29,18 +29,18 @@ module Refinery
29
29
  month = Date::MONTHNAMES[recent_post.month]
30
30
  year = recent_post.year
31
31
 
32
- links.should have_link("#{month} #{year} (3)")
32
+ expect(links).to have_link("#{month} #{year} (3)")
33
33
  end
34
34
 
35
35
  it "has a link for the year of dates older than one year" do
36
36
  year = old_post.year
37
37
 
38
- links.should have_link("#{year} (3)")
38
+ expect(links).to have_link("#{year} (3)")
39
39
  end
40
40
 
41
41
  it "sorts recent links before old links" do
42
- links.find("li:first").should have_content(recent_post.year.to_s)
43
- links.find("li:last").should have_content(old_post.year.to_s)
42
+ expect(links.find("li:first")).to have_content(recent_post.year.to_s)
43
+ expect(links.find("li:last")).to have_content(old_post.year.to_s)
44
44
  end
45
45
  end
46
46
 
@@ -50,8 +50,8 @@ module Refinery
50
50
  it "sorts by the more recent date" do
51
51
  first, second = dates.map {|p| Date::MONTHNAMES[p.month] }
52
52
 
53
- links.find("li:first").should have_content(second)
54
- links.find("li:last").should have_content(first)
53
+ expect(links.find("li:first")).to have_content(second)
54
+ expect(links.find("li:last")).to have_content(first)
55
55
  end
56
56
  end
57
57
 
@@ -61,8 +61,8 @@ module Refinery
61
61
  it "sorts by the more recent date" do
62
62
  first, second = dates.map {|p| p.year.to_s }
63
63
 
64
- links.find("li:first").should have_content(second)
65
- links.find("li:last").should have_content(first)
64
+ expect(links.find("li:first")).to have_content(second)
65
+ expect(links.find("li:last")).to have_content(first)
66
66
  end
67
67
  end
68
68
  end
@@ -71,11 +71,11 @@ module Refinery
71
71
  let(:email) { "test@test.com" }
72
72
 
73
73
  it "returns gravatar url" do
74
- helper.avatar_url(email).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
74
+ expect(helper.avatar_url(email)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
75
75
  end
76
76
 
77
77
  it "accepts options hash to change default size" do
78
- helper.avatar_url(email, :size => 55).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
78
+ expect(helper.avatar_url(email, :size => 55)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
79
79
  end
80
80
  end
81
81
  end
@@ -3,22 +3,12 @@ require 'spec_helper'
3
3
  module Refinery
4
4
  module Blog
5
5
  describe Engine do
6
- describe "plugin activity" do
7
- let(:activity) do
8
- Refinery::Plugins.registered.find_by_name("refinerycms_blog").activity.first
9
- end
10
-
11
- it "sets the correct path for activity entries" do
12
- activity.url.should eq("refinery.edit_blog_admin_post_path")
13
- end
14
- end
15
-
16
6
  describe ".load_seed" do
17
7
  it "is idempotent" do
18
8
  Engine.load_seed
19
9
  Engine.load_seed
20
10
 
21
- Refinery::Page.where(:link_url => '/blog').count.should eq(1)
11
+ expect(Refinery::Page.where(:link_url => '/blog').count).to eq(1)
22
12
  end
23
13
  end
24
14
  end