refinerycms-blog 3.0.2 → 4.0.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.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +2 -0
- data/.travis.yml +1 -3
- data/Gemfile +8 -8
- data/app/controllers/refinery/blog/admin/categories_controller.rb +2 -2
- data/app/controllers/refinery/blog/admin/posts_controller.rb +15 -12
- data/app/controllers/refinery/blog/blog_controller.rb +1 -1
- data/app/controllers/refinery/blog/posts_controller.rb +15 -13
- data/app/helpers/refinery/blog/posts_helper.rb +4 -4
- data/app/models/refinery/blog/category.rb +3 -0
- data/app/models/refinery/blog/post.rb +43 -16
- data/app/views/refinery/blog/admin/categories/_category.html.erb +4 -10
- data/app/views/refinery/blog/admin/comments/_comment.html.erb +4 -14
- data/app/views/refinery/blog/admin/posts/_form.html.erb +5 -1
- data/app/views/refinery/blog/admin/posts/_post.html.erb +7 -12
- data/app/views/refinery/blog/posts/_comment.html.erb +3 -3
- data/app/views/refinery/blog/posts/_comments.html.erb +6 -6
- data/app/views/refinery/blog/posts/_post.html.erb +7 -7
- data/app/views/refinery/blog/posts/index.rss.builder +8 -2
- data/app/views/refinery/blog/shared/_categories.html.erb +2 -2
- data/app/views/refinery/blog/shared/_post.html.erb +9 -7
- data/app/views/refinery/blog/shared/_posts.html.erb +1 -1
- data/app/views/refinery/blog/shared/_tags.html.erb +1 -1
- data/bin/rails +9 -3
- data/certs/parndt.pem +25 -0
- data/config/locales/ru.yml +1 -1
- data/config/locales/uk.yml +172 -0
- data/db/migrate/20110803223522_create_blog_structure.rb +1 -1
- data/db/migrate/20110803223523_add_user_id_to_blog_posts.rb +1 -1
- data/db/migrate/20110803223524_acts_as_taggable_on_migration.rb +1 -1
- data/db/migrate/20110803223526_add_cached_slugs.rb +1 -1
- data/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb +1 -1
- data/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb +1 -1
- data/db/migrate/20110803223529_add_primary_key_to_categorizations.rb +1 -1
- data/db/migrate/20120103055909_add_source_url_to_blog_posts.rb +2 -2
- data/db/migrate/20120223022021_add_access_count_to_posts.rb +4 -4
- data/db/migrate/20120227022021_add_slug_to_posts_and_categories.rb +2 -2
- data/db/migrate/20120530102901_create_blog_translations.rb +1 -1
- data/db/migrate/20120531113632_delete_cached_slugs.rb +1 -1
- data/db/migrate/20120601151114_create_category_translations.rb +1 -1
- data/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb +1 -1
- data/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +1 -1
- data/db/migrate/20160602042848_add_username_to_blog_posts.rb +5 -0
- data/db/migrate/20161223024527_create_multi_user_model.rb +13 -0
- data/db/migrate/20180420132008_remove_translated_columns_to_refinery_blog_categories.rb +5 -0
- data/lib/generators/refinery/blog/templates/config/initializers/refinery/blog.rb.erb +2 -1
- data/lib/refinery/blog.rb +2 -0
- data/lib/refinery/blog/configuration.rb +3 -3
- data/lib/refinery/blog/engine.rb +1 -0
- data/readme.md +2 -2
- data/refinerycms-blog.gemspec +15 -8
- data/spec/controllers/refinery/blog/admin/comments_controller_spec.rb +10 -14
- data/spec/controllers/refinery/blog/admin/posts_controller_spec.rb +5 -5
- data/spec/controllers/refinery/blog/posts_controller_spec.rb +4 -4
- data/spec/factories/blog_categories.rb +1 -1
- data/spec/factories/blog_comments.rb +1 -1
- data/spec/factories/blog_posts.rb +6 -2
- data/spec/factories/blog_test_users.rb +6 -0
- data/spec/features/refinery/blog/admin/categories_spec.rb +3 -3
- data/spec/features/refinery/blog/admin/comments_spec.rb +5 -5
- data/spec/features/refinery/blog/admin/menu_spec.rb +2 -2
- data/spec/features/refinery/blog/admin/posts_spec.rb +34 -20
- data/spec/features/refinery/blog/categories_spec.rb +2 -3
- data/spec/features/refinery/blog/posts_spec.rb +17 -30
- data/spec/models/refinery/blog/category_spec.rb +12 -13
- data/spec/models/refinery/blog/comment_spec.rb +1 -1
- data/spec/models/refinery/blog/post_spec.rb +38 -31
- data/spec/spec_helper.rb +1 -0
- data/spec/support/refinery_blog_test_user.rb +2 -0
- metadata +85 -33
- metadata.gz.sig +0 -0
- data/spec/factories/user.rb +0 -27
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddPrimaryKeyToCategorizations < ActiveRecord::Migration
|
1
|
+
class AddPrimaryKeyToCategorizations < ActiveRecord::Migration[4.2]
|
2
2
|
def up
|
3
3
|
unless Refinery::Blog::Categorization.column_names.include?("id")
|
4
4
|
add_column Refinery::Blog::Categorization.table_name, :id, :primary_key
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class AddSourceUrlToBlogPosts < ActiveRecord::Migration
|
1
|
+
class AddSourceUrlToBlogPosts < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column Refinery::Blog::Post.table_name, :source_url, :string
|
4
4
|
add_column Refinery::Blog::Post.table_name, :source_url_title, :string
|
5
|
-
|
5
|
+
|
6
6
|
end
|
7
7
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class AddAccessCountToPosts < ActiveRecord::Migration
|
1
|
+
class AddAccessCountToPosts < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column Refinery::Blog::Post.table_name, :access_count, :integer, :default => 0
|
4
|
-
|
4
|
+
|
5
5
|
add_index Refinery::Blog::Post.table_name, :access_count
|
6
|
-
|
6
|
+
|
7
7
|
end
|
8
|
-
end
|
8
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddSlugToPostsAndCategories < ActiveRecord::Migration
|
1
|
+
class AddSlugToPostsAndCategories < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
add_column Refinery::Blog::Post.table_name, :slug, :string
|
4
4
|
add_index Refinery::Blog::Post.table_name, :slug
|
@@ -6,4 +6,4 @@ class AddSlugToPostsAndCategories < ActiveRecord::Migration
|
|
6
6
|
add_column Refinery::Blog::Category.table_name, :slug, :string
|
7
7
|
add_index Refinery::Blog::Category.table_name, :slug
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
data/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# This migration comes from acts_as_taggable_on_engine (originally 3)
|
2
|
-
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
2
|
+
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]
|
3
3
|
def self.up
|
4
4
|
add_column :tags, :taggings_count, :integer, default: 0
|
5
5
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateMultiUserModel < ActiveRecord::Migration[4.2]
|
2
|
+
def up
|
3
|
+
return unless Rails.env.test?
|
4
|
+
create_table :refinery_blog_test_users do |t|
|
5
|
+
t.string :username
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
return unless Rails.env.test?
|
11
|
+
drop_table :refinery_blog_test_users
|
12
|
+
end
|
13
|
+
end
|
@@ -10,7 +10,8 @@ Refinery::Blog.configure do |config|
|
|
10
10
|
# config.share_this_key = <%= Refinery::Blog.share_this_key.inspect %>
|
11
11
|
|
12
12
|
# config.page_url = <%= Refinery::Blog.page_url.inspect %>
|
13
|
-
|
13
|
+
|
14
14
|
# If you're grafting onto an existing app, change this to your User class
|
15
|
+
# (eg: Refinery::Blog.user_class = "Refinery::Authentication::Devise::User" )
|
15
16
|
# Refinery::Blog.user_class = <%= Refinery::Blog.user_class.to_s.inspect %>
|
16
17
|
end
|
data/lib/refinery/blog.rb
CHANGED
@@ -11,7 +11,7 @@ module Refinery
|
|
11
11
|
self.post_teaser_length = 250
|
12
12
|
self.share_this_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
13
13
|
self.page_url = "/blog"
|
14
|
-
|
14
|
+
|
15
15
|
# Refinery::User isn't available when this line gets hit, so we use static methods instead
|
16
16
|
@@user_class_name = nil
|
17
17
|
class << self
|
@@ -26,9 +26,9 @@ module Refinery
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def user_class
|
29
|
-
class_name = @@user_class_name
|
29
|
+
class_name = @@user_class_name
|
30
30
|
begin
|
31
|
-
Object.const_get(class_name)
|
31
|
+
Object.const_get(class_name) if class_name.present?
|
32
32
|
rescue NameError
|
33
33
|
class_name.constantize
|
34
34
|
end
|
data/lib/refinery/blog/engine.rb
CHANGED
data/readme.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Simple blog engine for [Refinery CMS](http://refinerycms.com). It supports posts, categories and comments.
|
4
4
|
|
5
|
-
This version of `refinerycms-blog` supports Refinery
|
5
|
+
This version of `refinerycms-blog` supports Refinery 4.x and Rails 5.1.x (Ruby 2.2+). To use Rails 4.x / Refinery 3.1.x / Ruby 2.1 or older use the [refinerycms-blog "Refinery CMS 3-0 stable branch"](http://github.com/refinery/refinerycms-blog/tree/3-0-stable).
|
6
6
|
|
7
7
|
Options:
|
8
8
|
|
@@ -11,7 +11,7 @@ Options:
|
|
11
11
|
|
12
12
|
## Requirements
|
13
13
|
|
14
|
-
Refinery CMS version
|
14
|
+
Refinery CMS version 4.0.0 or above (Ruby 2.2 or above).
|
15
15
|
|
16
16
|
## Install
|
17
17
|
|
data/refinerycms-blog.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Encoding:
|
1
|
+
# Encoding: utf-8
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{refinerycms-blog}
|
5
|
-
s.version = %q{
|
5
|
+
s.version = %q{4.0.0}
|
6
6
|
s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with Refinery CMS.}
|
7
7
|
s.summary = %q{Ruby on Rails blogging engine for Refinery CMS.}
|
8
8
|
s.email = %q{info@refinerycms.com}
|
@@ -15,13 +15,20 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
16
|
|
17
17
|
# Runtime dependencies
|
18
|
-
s.add_dependency 'refinerycms-core', '~>
|
19
|
-
s.add_dependency 'refinerycms-settings', '~>
|
18
|
+
s.add_dependency 'refinerycms-core', '~> 4.0'
|
19
|
+
s.add_dependency 'refinerycms-settings', '~> 4.0'
|
20
20
|
s.add_dependency 'filters_spam', '~> 0.2'
|
21
21
|
s.add_dependency 'acts-as-taggable-on'
|
22
|
-
s.add_dependency 'seo_meta', '
|
22
|
+
s.add_dependency 'seo_meta', ['>=3.0.0', '~>3.0']
|
23
23
|
s.add_dependency 'rails_autolink', '~> 1.1.3'
|
24
|
-
s.add_dependency 'friendly_id', ['
|
25
|
-
s.add_dependency 'globalize',
|
26
|
-
s.add_dependency '
|
24
|
+
s.add_dependency 'friendly_id', ['< 5.3', '>= 5.1.0']
|
25
|
+
s.add_dependency 'globalize', '~> 5.1.0'
|
26
|
+
s.add_dependency 'activemodel-serializers-xml', '~> 1.0', '>= 1.0.1'
|
27
|
+
s.add_dependency 'responders', '~> 2.0'
|
28
|
+
|
29
|
+
|
30
|
+
s.cert_chain = [File.expand_path('certs/parndt.pem', __dir__)]
|
31
|
+
if $PROGRAM_NAME =~ /gem\z/ && ARGV.include?('build') && ARGV.include?(__FILE__)
|
32
|
+
s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
|
33
|
+
end
|
27
34
|
end
|
@@ -4,14 +4,10 @@ module Refinery
|
|
4
4
|
module Blog
|
5
5
|
module Admin
|
6
6
|
describe CommentsController, type: :controller do
|
7
|
-
|
8
|
-
|
9
|
-
before do
|
10
|
-
logged_in_user.plugins = logged_in_user.plugins | %w(refinerycms_blog)
|
11
|
-
end
|
7
|
+
refinery_login
|
12
8
|
|
13
9
|
describe "#index" do
|
14
|
-
let!(:comment) {
|
10
|
+
let!(:comment) { FactoryBot.create(:blog_comment) }
|
15
11
|
|
16
12
|
it "succeeds" do
|
17
13
|
get :index
|
@@ -26,7 +22,7 @@ module Refinery
|
|
26
22
|
end
|
27
23
|
|
28
24
|
describe "#approved" do
|
29
|
-
let!(:comment) {
|
25
|
+
let!(:comment) { FactoryBot.create(:approved_comment) }
|
30
26
|
|
31
27
|
it "succeeds" do
|
32
28
|
get :approved
|
@@ -41,21 +37,21 @@ module Refinery
|
|
41
37
|
end
|
42
38
|
|
43
39
|
describe "#approve" do
|
44
|
-
let!(:comment) {
|
40
|
+
let!(:comment) { FactoryBot.create(:blog_comment) }
|
45
41
|
|
46
42
|
it "redirects on success" do
|
47
|
-
post :approve, :id
|
43
|
+
post :approve, params: { id: comment.id }
|
48
44
|
expect(response).to be_redirect
|
49
45
|
end
|
50
46
|
|
51
47
|
it "approves the comment" do
|
52
|
-
post :approve, :id => comment.id
|
48
|
+
post :approve, params: { :id => comment.id }
|
53
49
|
expect(Refinery::Blog::Comment.approved.count).to eq(1)
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
53
|
describe "#rejected" do
|
58
|
-
let!(:comment) {
|
54
|
+
let!(:comment) { FactoryBot.create(:rejected_comment) }
|
59
55
|
|
60
56
|
it "succeeds" do
|
61
57
|
get :rejected
|
@@ -70,15 +66,15 @@ module Refinery
|
|
70
66
|
end
|
71
67
|
|
72
68
|
describe "#reject" do
|
73
|
-
let!(:comment) {
|
69
|
+
let!(:comment) { FactoryBot.create(:blog_comment) }
|
74
70
|
|
75
71
|
it "redirects on success" do
|
76
|
-
post :reject, :id => comment.id
|
72
|
+
post :reject, params: { :id => comment.id }
|
77
73
|
expect(response).to be_redirect
|
78
74
|
end
|
79
75
|
|
80
76
|
it "rejects the comment" do
|
81
|
-
post :reject, :id => comment.id
|
77
|
+
post :reject, params:{ :id => comment.id }
|
82
78
|
expect(Refinery::Blog::Comment.rejected.count).to eq(1)
|
83
79
|
end
|
84
80
|
end
|
@@ -4,10 +4,10 @@ module Refinery
|
|
4
4
|
module Blog
|
5
5
|
module Admin
|
6
6
|
describe PostsController, type: :controller do
|
7
|
-
|
7
|
+
refinery_login
|
8
8
|
|
9
9
|
describe "#delete_translation" do
|
10
|
-
let!(:blog_post) {
|
10
|
+
let!(:blog_post) { FactoryBot.create(:blog_post) }
|
11
11
|
|
12
12
|
before do
|
13
13
|
blog_post.translations.create(:locale => :fr, :title => 'Un titre francais', :body => "La baguette, c'est bon. Mangez-en.")
|
@@ -15,17 +15,17 @@ module Refinery
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "destroys the translation" do
|
18
|
-
post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
|
18
|
+
post :delete_translation, params: { :id => blog_post.id, :locale_to_delete => :fr }
|
19
19
|
expect(blog_post.translations.exists?(:locale => :fr)).to be_falsey
|
20
20
|
end
|
21
21
|
|
22
22
|
it "does not destroy other translations" do
|
23
|
-
post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
|
23
|
+
post :delete_translation, params: { :id => blog_post.id, :locale_to_delete => :fr }
|
24
24
|
expect(blog_post.translations.exists?(:locale => :es)).to be_truthy
|
25
25
|
end
|
26
26
|
|
27
27
|
it "redirects on success" do
|
28
|
-
post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
|
28
|
+
post :delete_translation, params: { :id => blog_post.id, :locale_to_delete => :fr }
|
29
29
|
expect(response).to be_redirect
|
30
30
|
end
|
31
31
|
end
|
@@ -4,9 +4,9 @@ module Refinery
|
|
4
4
|
module Blog
|
5
5
|
describe PostsController, type: :controller do
|
6
6
|
before do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
FactoryBot.create(:blog_post, :title => "blogpost_one")
|
8
|
+
FactoryBot.create(:blog_post, :title => "blogpost_two")
|
9
|
+
FactoryBot.create(:blog_post, :title => "blogpost_three")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should not limit rss feed" do
|
@@ -15,7 +15,7 @@ module Refinery
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should limit rss feed" do
|
18
|
-
get :index, :format => :rss, :max_results => 2
|
18
|
+
get :index, :format => :rss, params: { :max_results => 2 }
|
19
19
|
expect(assigns[:posts].count).to eq(2)
|
20
20
|
end
|
21
21
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :blog_post, :class => Refinery::Blog::Post do
|
3
3
|
sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
|
4
4
|
body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
|
5
5
|
draft false
|
6
6
|
published_at Time.now
|
7
|
-
|
7
|
+
username "John Doe"
|
8
8
|
|
9
9
|
factory :blog_post_draft do
|
10
10
|
draft true
|
11
11
|
end
|
12
|
+
|
13
|
+
factory :blog_post_authentication_devise_refinery_user_author do
|
14
|
+
author { FactoryBot.create(:blog_test_user) }
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
@@ -5,7 +5,7 @@ module Refinery
|
|
5
5
|
module Blog
|
6
6
|
module Admin
|
7
7
|
describe Category, type: :feature do
|
8
|
-
|
8
|
+
refinery_login
|
9
9
|
|
10
10
|
let(:title) { "lol" }
|
11
11
|
|
@@ -25,7 +25,7 @@ module Refinery
|
|
25
25
|
context "with translations" do
|
26
26
|
before do
|
27
27
|
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
|
28
|
-
blog_page = Globalize.with_locale(:en) {
|
28
|
+
blog_page = Globalize.with_locale(:en) { FactoryBot.create(:page, :link_url => "/blog", :title => "Blog") }
|
29
29
|
Globalize.with_locale(:ru) do
|
30
30
|
blog_page.title = 'блог'
|
31
31
|
blog_page.save
|
@@ -84,7 +84,7 @@ module Refinery
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it "suceeds" do
|
87
|
-
expect(page).to have_content("'#{@c.
|
87
|
+
expect(page).to have_content("'#{@c.title_translations['ru']}' was successfully added.")
|
88
88
|
expect(Refinery::Blog::Category.count).to eq(1)
|
89
89
|
end
|
90
90
|
|
@@ -4,7 +4,7 @@ module Refinery
|
|
4
4
|
module Blog
|
5
5
|
module Admin
|
6
6
|
describe Comment, type: :feature do
|
7
|
-
|
7
|
+
refinery_login
|
8
8
|
|
9
9
|
describe "#index" do
|
10
10
|
context "when has no new unapproved comments" do
|
@@ -20,7 +20,7 @@ module Refinery
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
context "when has new unapproved comments" do
|
23
|
-
let!(:blog_comment) {
|
23
|
+
let!(:blog_comment) { FactoryBot.create(:blog_comment) }
|
24
24
|
before { visit refinery.blog_admin_comments_path }
|
25
25
|
|
26
26
|
it "should list comments" do
|
@@ -55,7 +55,7 @@ module Refinery
|
|
55
55
|
end
|
56
56
|
context "when has approved comments" do
|
57
57
|
let!(:blog_comment) do
|
58
|
-
|
58
|
+
FactoryBot.create(:blog_comment, :state => 'approved')
|
59
59
|
end
|
60
60
|
before { visit refinery.approved_blog_admin_comments_path }
|
61
61
|
|
@@ -85,7 +85,7 @@ module Refinery
|
|
85
85
|
end
|
86
86
|
context "when has rejected comments" do
|
87
87
|
let!(:blog_comment) do
|
88
|
-
|
88
|
+
FactoryBot.create(:blog_comment, :state => 'rejected')
|
89
89
|
end
|
90
90
|
before { visit refinery.rejected_blog_admin_comments_path }
|
91
91
|
|
@@ -103,7 +103,7 @@ module Refinery
|
|
103
103
|
end
|
104
104
|
|
105
105
|
describe "#show" do
|
106
|
-
let!(:blog_comment) {
|
106
|
+
let!(:blog_comment) { FactoryBot.create(:blog_comment) }
|
107
107
|
before { visit refinery.blog_admin_comment_path(blog_comment) }
|
108
108
|
it "should display the comment" do
|
109
109
|
expect(page).to have_content(blog_comment.body)
|