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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -23
- data/Gemfile +15 -7
- data/Rakefile +0 -1
- data/app/assets/javascripts/refinery/blog/backend.js +18 -59
- data/app/assets/stylesheets/refinery/blog/backend.css.scss +4 -55
- data/app/assets/stylesheets/refinery/blog/frontend.css.scss +2 -2
- data/app/controllers/refinery/blog/admin/categories_controller.rb +6 -0
- data/app/controllers/refinery/blog/admin/posts_controller.rb +25 -3
- data/app/controllers/refinery/blog/blog_controller.rb +31 -5
- data/app/controllers/refinery/blog/categories_controller.rb +10 -3
- data/app/controllers/refinery/blog/posts_controller.rb +16 -6
- data/app/helpers/refinery/blog/controller_helper.rb +1 -22
- data/app/models/refinery/blog/categorization.rb +0 -1
- data/app/models/refinery/blog/category.rb +3 -6
- data/app/models/refinery/blog/comment.rb +15 -17
- data/app/models/refinery/blog/post.rb +44 -43
- data/app/views/refinery/blog/admin/_submenu.html.erb +1 -3
- data/app/views/refinery/blog/admin/categories/_category.html.erb +14 -5
- data/app/views/refinery/blog/admin/posts/_form.html.erb +13 -6
- data/app/views/refinery/blog/admin/posts/_form_part.html.erb +1 -1
- data/app/views/refinery/blog/admin/posts/_post.html.erb +12 -5
- data/app/views/refinery/blog/admin/posts/_teaser_part.html.erb +1 -1
- data/app/views/refinery/blog/posts/index.html.erb +2 -2
- data/app/views/refinery/blog/shared/_categories.html.erb +3 -3
- data/app/views/refinery/shared/admin/_autocomplete.html.erb +45 -0
- data/bin/rails +5 -0
- data/bin/refinerycms +62 -0
- data/changelog.md +4 -1
- data/config/locales/cs.yml +2 -2
- data/config/locales/en.yml +3 -0
- data/config/locales/fr.yml +6 -4
- data/config/locales/nb.yml +154 -14
- data/config/locales/nl.yml +21 -0
- data/config/locales/pl.yml +2 -2
- data/config/locales/ru.yml +25 -14
- data/config/locales/zh-CN.yml +32 -1
- data/config/locales/zh-TW.yml +160 -0
- data/config/routes.rb +6 -3
- data/db/migrate/20110803223522_create_blog_structure.rb +4 -4
- data/db/migrate/20120531113632_delete_cached_slugs.rb +2 -2
- data/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
- data/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
- data/db/seeds.rb +4 -4
- data/lib/refinery/blog.rb +1 -1
- data/lib/refinery/blog/configuration.rb +1 -1
- data/lib/refinery/blog/engine.rb +8 -3
- data/readme.md +21 -6
- data/refinerycms-blog.gemspec +9 -7
- data/script/rails +1 -3
- data/spec/controllers/refinery/blog/admin/comments_controller_spec.rb +23 -19
- data/spec/controllers/refinery/blog/admin/posts_controller_spec.rb +35 -0
- data/spec/controllers/refinery/blog/posts_controller_spec.rb +3 -3
- data/spec/factories/blog_posts.rb +1 -1
- data/spec/factories/user.rb +27 -0
- data/spec/features/refinery/blog/admin/categories_spec.rb +106 -104
- data/spec/features/refinery/blog/admin/comments_spec.rb +18 -18
- data/spec/features/refinery/blog/admin/menu_spec.rb +14 -8
- data/spec/features/refinery/blog/admin/posts_spec.rb +99 -86
- data/spec/features/refinery/blog/categories_spec.rb +20 -18
- data/spec/features/refinery/blog/posts_spec.rb +128 -124
- data/spec/helpers/refinery/blog/posts_helper_spec.rb +13 -13
- data/spec/lib/refinery/blog/engine_spec.rb +1 -11
- data/spec/models/refinery/blog/category_spec.rb +10 -10
- data/spec/models/refinery/blog/comment_spec.rb +3 -3
- data/spec/models/refinery/blog/post_spec.rb +59 -33
- data/spec/spec_helper.rb +2 -3
- metadata +75 -50
- data/app/assets/images/refinery/blog/icons/add.png +0 -0
- data/app/assets/images/refinery/blog/icons/cog.png +0 -0
- data/app/assets/images/refinery/blog/icons/comment.png +0 -0
- data/app/assets/images/refinery/blog/icons/comment_cross.png +0 -0
- data/app/assets/images/refinery/blog/icons/comment_tick.png +0 -0
- data/app/assets/images/refinery/blog/icons/comments.png +0 -0
- data/app/assets/images/refinery/blog/icons/down.gif +0 -0
- data/app/assets/images/refinery/blog/icons/folder.png +0 -0
- data/app/assets/images/refinery/blog/icons/folder_add.png +0 -0
- data/app/assets/images/refinery/blog/icons/folder_edit.png +0 -0
- data/app/assets/images/refinery/blog/icons/page.png +0 -0
- data/app/assets/images/refinery/blog/icons/page_add.png +0 -0
- data/app/assets/images/refinery/blog/icons/page_copy.png +0 -0
- data/app/assets/images/refinery/blog/icons/up.gif +0 -0
- data/spec/helpers/refinery/blog/controller_helper_spec.rb +0 -27
- data/todo.md +0 -5
@@ -1,28 +1,30 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
module Refinery
|
4
|
-
|
5
|
-
|
4
|
+
module Blog
|
5
|
+
describe Category, type: :feature do
|
6
|
+
refinery_login_with_devise :authentication_devise_refinery_user
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
5
|
-
|
4
|
+
module Blog
|
5
|
+
describe Post, type: :feature do
|
6
|
+
refinery_login_with_devise :authentication_devise_refinery_user
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
13
|
+
it "should display blog post" do
|
14
|
+
visit refinery.blog_post_path(blog_post)
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
expect(page).to have_content(blog_post.title)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
+
describe "visit blog" do
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
before do
|
22
|
+
FactoryGirl.create(:page, :link_url => "/")
|
23
|
+
FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog")
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
+
describe "#show" do
|
64
|
+
context "when has no comments" do
|
65
|
+
let!(:blog_post) { FactoryGirl.create(:blog_post) }
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
70
|
-
|
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
|
-
|
74
|
-
|
76
|
+
it "should display the comments" do
|
77
|
+
visit refinery.blog_post_path(approved_comment.post)
|
75
78
|
|
76
|
-
|
77
|
-
|
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
|
-
|
80
|
-
|
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
|
-
|
84
|
-
|
86
|
+
it "should not display the comments" do
|
87
|
+
visit refinery.blog_post_path(rejected_comment.post)
|
85
88
|
|
86
|
-
|
89
|
+
expect(page).not_to have_content(rejected_comment.body)
|
90
|
+
end
|
87
91
|
end
|
88
|
-
|
89
|
-
|
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
|
-
|
93
|
-
|
95
|
+
it "should not display the comments" do
|
96
|
+
visit refinery.blog_post_path(blog_comment.post)
|
94
97
|
|
95
|
-
|
98
|
+
expect(page).not_to have_content(blog_comment.body)
|
99
|
+
end
|
96
100
|
end
|
97
|
-
end
|
98
101
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
106
|
-
|
108
|
+
before do
|
109
|
+
visit refinery.blog_post_path(blog_post)
|
107
110
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
115
|
-
|
117
|
+
it "creates the comment" do
|
118
|
+
comment = blog_post.reload.comments.last
|
116
119
|
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
124
|
-
|
125
|
-
|
126
|
+
context "post popular" do
|
127
|
+
let!(:blog_post) { FactoryGirl.create(:blog_post) }
|
128
|
+
let!(:blog_post2) { FactoryGirl.create(:blog_post) }
|
126
129
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
before do
|
131
|
+
visit refinery.blog_post_path(blog_post)
|
132
|
+
end
|
130
133
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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
|
-
|
138
|
-
|
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
|
-
|
143
|
-
|
144
|
-
|
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
|
-
|
147
|
-
|
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
|
-
|
154
|
+
end
|
152
155
|
|
153
|
-
|
154
|
-
|
156
|
+
describe "#show draft preview" do
|
157
|
+
let!(:blog_post) { FactoryGirl.create(:blog_post_draft) }
|
155
158
|
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
163
|
+
expect(page).to have_content('This page is NOT live for public viewing.')
|
164
|
+
end
|
161
165
|
end
|
162
|
-
end
|
163
166
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
-
|
173
|
-
|
175
|
+
it "should not display the blog post" do
|
176
|
+
visit refinery.blog_post_path(blog_post)
|
174
177
|
|
175
|
-
|
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.
|
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.
|
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.
|
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").
|
43
|
-
links.find("li:last").
|
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").
|
54
|
-
links.find("li:last").
|
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").
|
65
|
-
links.find("li:last").
|
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).
|
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).
|
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.
|
11
|
+
expect(Refinery::Page.where(:link_url => '/blog').count).to eq(1)
|
22
12
|
end
|
23
13
|
end
|
24
14
|
end
|