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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{refinerycms-blog}
5
- s.version = %q{2.1.0}
5
+ s.version = %q{3.0.1}
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,11 +15,13 @@ 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', '~> 2.1.0'
19
- s.add_dependency 'refinerycms-settings', '~> 2.1.0'
20
- s.add_dependency 'filters_spam', '~> 0.2'
18
+ s.add_dependency 'refinerycms-core', '~> 3.0.0'
19
+ s.add_dependency 'refinerycms-settings', '~> 3.0.0'
20
+ s.add_dependency 'filters_spam', '~> 0.2'
21
21
  s.add_dependency 'acts-as-taggable-on'
22
- s.add_dependency 'seo_meta', '~> 1.4.0'
23
- s.add_dependency 'rails_autolink', '~> 1.0.7'
24
- s.add_dependency 'friendly_id', '~> 4.0.4'
22
+ s.add_dependency 'seo_meta', '~> 2.0.0.rc.1'
23
+ s.add_dependency 'rails_autolink', '~> 1.1.3'
24
+ s.add_dependency 'friendly_id', '~> 5.1.0'
25
+ s.add_dependency 'globalize', ['>= 4.0.0', '< 5.2']
26
+ s.add_dependency 'jquery-ui-rails', '~> 5.0.0'
25
27
  end
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- #!/usr/bin/env ruby
3
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
4
2
 
5
3
  ENGINE_PATH = File.expand_path('../..', __FILE__)
6
- load File.expand_path('../../spec/dummy/script/rails', __FILE__)
4
+ load File.expand_path('../../spec/dummy/bin/rails', __FILE__)
@@ -3,21 +3,25 @@ require "spec_helper"
3
3
  module Refinery
4
4
  module Blog
5
5
  module Admin
6
- describe CommentsController do
7
- refinery_login_with :refinery_user
6
+ describe CommentsController, type: :controller do
7
+ refinery_login_with_devise [:refinery, :superuser]
8
+
9
+ before do
10
+ logged_in_user.plugins = logged_in_user.plugins | %w(refinerycms_blog)
11
+ end
8
12
 
9
13
  describe "#index" do
10
14
  let!(:comment) { FactoryGirl.create(:blog_comment) }
11
-
15
+
12
16
  it "succeeds" do
13
17
  get :index
14
- response.should be_success
15
- response.should render_template(:index)
18
+ expect(response).to be_success
19
+ expect(response).to render_template(:index)
16
20
  end
17
21
 
18
22
  it "assigns unmoderated comments" do
19
23
  get :index
20
- assigns(:comments).first.should eq(comment)
24
+ expect(assigns(:comments).first).to eq(comment)
21
25
  end
22
26
  end
23
27
 
@@ -26,13 +30,13 @@ module Refinery
26
30
 
27
31
  it "succeeds" do
28
32
  get :approved
29
- response.should be_success
30
- response.should render_template(:index)
33
+ expect(response).to be_success
34
+ expect(response).to render_template(:index)
31
35
  end
32
36
 
33
37
  it "assigns approved comments" do
34
38
  get :approved
35
- assigns(:comments).first.should eq(comment)
39
+ expect(assigns(:comments).first).to eq(comment)
36
40
  end
37
41
  end
38
42
 
@@ -41,27 +45,27 @@ module Refinery
41
45
 
42
46
  it "redirects on success" do
43
47
  post :approve, :id => comment.id
44
- response.should be_redirect
48
+ expect(response).to be_redirect
45
49
  end
46
-
50
+
47
51
  it "approves the comment" do
48
52
  post :approve, :id => comment.id
49
- Refinery::Blog::Comment.approved.count.should eq(1)
53
+ expect(Refinery::Blog::Comment.approved.count).to eq(1)
50
54
  end
51
55
  end
52
-
56
+
53
57
  describe "#rejected" do
54
58
  let!(:comment) { FactoryGirl.create(:rejected_comment) }
55
59
 
56
60
  it "succeeds" do
57
61
  get :rejected
58
- response.should be_success
59
- response.should render_template(:index)
62
+ expect(response).to be_success
63
+ expect(response).to render_template(:index)
60
64
  end
61
65
 
62
66
  it "assigns rejected comments" do
63
67
  get :rejected
64
- assigns(:comments).first.should eq(comment)
68
+ expect(assigns(:comments).first).to eq(comment)
65
69
  end
66
70
  end
67
71
 
@@ -70,12 +74,12 @@ module Refinery
70
74
 
71
75
  it "redirects on success" do
72
76
  post :reject, :id => comment.id
73
- response.should be_redirect
77
+ expect(response).to be_redirect
74
78
  end
75
-
79
+
76
80
  it "rejects the comment" do
77
81
  post :reject, :id => comment.id
78
- Refinery::Blog::Comment.rejected.count.should eq(1)
82
+ expect(Refinery::Blog::Comment.rejected.count).to eq(1)
79
83
  end
80
84
  end
81
85
  end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ module Refinery
4
+ module Blog
5
+ module Admin
6
+ describe PostsController, type: :controller do
7
+ refinery_login_with_devise [:refinery, :superuser]
8
+
9
+ describe "#delete_translation" do
10
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
11
+
12
+ before do
13
+ blog_post.translations.create(:locale => :fr, :title => 'Un titre francais', :body => "La baguette, c'est bon. Mangez-en.")
14
+ blog_post.translations.create(:locale => :es, :title => 'Un titulo espanol', :body => "Mi casa e su casa.")
15
+ end
16
+
17
+ it "destroys the translation" do
18
+ post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
19
+ expect(blog_post.translations.exists?(:locale => :fr)).to be_falsey
20
+ end
21
+
22
+ it "does not destroy other translations" do
23
+ post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
24
+ expect(blog_post.translations.exists?(:locale => :es)).to be_truthy
25
+ end
26
+
27
+ it "redirects on success" do
28
+ post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
29
+ expect(response).to be_redirect
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  module Refinery
4
4
  module Blog
5
- describe PostsController do
5
+ describe PostsController, type: :controller do
6
6
  before do
7
7
  FactoryGirl.create(:blog_post, :title => "blogpost_one")
8
8
  FactoryGirl.create(:blog_post, :title => "blogpost_two")
@@ -11,12 +11,12 @@ module Refinery
11
11
 
12
12
  it "should not limit rss feed" do
13
13
  get :index, :format => :rss
14
- assigns[:posts].size.should == 3
14
+ expect(assigns[:posts].size).to eq(3)
15
15
  end
16
16
 
17
17
  it "should limit rss feed" do
18
18
  get :index, :format => :rss, :max_results => 2
19
- assigns[:posts].count.should == 2
19
+ expect(assigns[:posts].count).to eq(2)
20
20
  end
21
21
  end
22
22
  end
@@ -4,7 +4,7 @@ FactoryGirl.define do
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
- author { FactoryGirl.create(:refinery_user) }
7
+ author { FactoryGirl.create(:authentication_devise_refinery_user) }
8
8
 
9
9
  factory :blog_post_draft do
10
10
  draft true
@@ -0,0 +1,27 @@
1
+ FactoryGirl.define do
2
+ factory :authentication_devise_user, :class => Refinery::Authentication::Devise::User do
3
+ sequence(:username) { |n| "refinery#{n}" }
4
+ sequence(:email) { |n| "refinery#{n}@example.com" }
5
+ password "refinerycms"
6
+ password_confirmation "refinerycms"
7
+ end
8
+
9
+ factory :authentication_devise_refinery_user, :parent => :authentication_devise_user do
10
+ roles { [ ::Refinery::Authentication::Devise::Role[:refinery] ] }
11
+
12
+ after(:create) do |user|
13
+ ::Refinery::Plugins.registered.each_with_index do |plugin, index|
14
+ user.plugins.create(:name => plugin.name, :position => index)
15
+ end
16
+ end
17
+ end
18
+
19
+ factory :authentication_devise_refinery_superuser, :parent => :authentication_devise_refinery_user do
20
+ roles {
21
+ [
22
+ ::Refinery::Authentication::Devise::Role[:refinery],
23
+ ::Refinery::Authentication::Devise::Role[:superuser]
24
+ ]
25
+ }
26
+ end
27
+ end
@@ -1,119 +1,121 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe "Categories admin" do
5
- refinery_login_with :refinery_user
4
+ module Refinery
5
+ module Blog
6
+ module Admin
7
+ describe Category, type: :feature do
8
+ refinery_login_with_devise :authentication_devise_refinery_superuser
6
9
 
7
- let(:title) { "lol" }
10
+ let(:title) { "lol" }
8
11
 
9
- it "can create categories" do
10
- visit refinery.admin_root_path
12
+ it "can create categories" do
13
+ visit refinery.admin_root_path
11
14
 
12
- within("nav#menu") { click_link "Blog" }
13
- within("nav.multilist") { click_link "Create new category" }
15
+ within("nav#menu") { click_link "Blog" }
16
+ within("nav.multilist") { click_link "Create new category" }
14
17
 
15
- fill_in "Title", :with => title
16
- click_button "Save"
18
+ fill_in "Title", :with => title
19
+ click_button "Save"
17
20
 
18
- category = Refinery::Blog::Category.first
19
- category.title.should eq(title)
20
- end
21
-
22
- context "with translations" do
23
- before do
24
- Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
25
- blog_page = Globalize.with_locale(:en) { FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog") }
26
- Globalize.with_locale(:ru) do
27
- blog_page.title = 'блог'
28
- blog_page.save
29
- end
30
- end
31
-
32
- describe "add a category with title for default locale" do
33
- before do
34
- Globalize.locale = :en
35
- visit refinery.blog_admin_posts_path
36
- click_link "Create new category"
37
- fill_in "Title", :with => "Testing Category"
38
- click_button "Save"
39
- @c = Refinery::Blog::Category.find_by_title("Testing Category")
40
- end
41
-
42
- it "suceeds" do
43
- page.should have_content("'#{@c.title}' was successfully added.")
44
- Refinery::Blog::Category.count.should eq(1)
45
- end
46
-
47
- it "shows locale flag for category" do
48
- click_link "Manage"
49
- within "#category_#{@c.id}" do
50
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
51
- end
52
- end
53
-
54
- it "shows up in blog page for default locale" do
55
- visit refinery.blog_root_path
56
- within "#categories" do
57
- page.should have_selector('li')
58
- end
59
- end
60
-
61
- it "does not show up in blog page for secondary locale" do
62
- visit refinery.blog_root_path(:locale => :ru)
63
- page.should_not have_selector('#categories')
64
- end
65
-
66
- end
67
-
68
- describe "add a category with title for secondary locale" do
69
-
70
- let(:ru_category_title) { 'категория' }
71
-
72
- before do
73
- visit refinery.blog_admin_posts_path
74
- click_link "Create new category"
75
- within "#switch_locale_picker" do
76
- click_link "Ru"
77
- end
78
- fill_in "Title", :with => ru_category_title
79
- click_button "Save"
80
- @c = Refinery::Blog::Category.find_by_title(ru_category_title)
81
- end
82
-
83
- it "suceeds" do
84
- page.should have_content("'#{@c.title}' was successfully added.")
85
- Refinery::Blog::Category.count.should eq(1)
86
- end
87
-
88
- it "shows locale flag for category" do
89
- click_link "Manage"
90
- within "#category_#{@c.id}" do
91
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
92
- end
93
- end
94
-
95
- it "does not show locale flag for primary locale" do
96
- click_link "Manage"
97
- within "#category_#{@c.id}" do
98
- page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
21
+ category = Refinery::Blog::Category.first
22
+ expect(category.title).to eq(title)
99
23
  end
100
- end
101
-
102
- it "does not shows up in blog page for default locale" do
103
- visit refinery.blog_root_path
104
- page.should_not have_selector('#categories')
105
- end
106
24
 
107
- it "shows up in blog page for secondary locale" do
108
- visit refinery.blog_root_path(:locale => :ru)
109
- within "#categories" do
110
- page.should have_selector('li')
25
+ context "with translations" do
26
+ before do
27
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
28
+ blog_page = Globalize.with_locale(:en) { FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog") }
29
+ Globalize.with_locale(:ru) do
30
+ blog_page.title = 'блог'
31
+ blog_page.save
32
+ end
33
+ end
34
+
35
+ describe "add a category with title for default locale" do
36
+ before do
37
+ Globalize.locale = :en
38
+ visit refinery.blog_admin_posts_path
39
+ click_link "Create new category"
40
+ fill_in "Title", :with => "Testing Category"
41
+ expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1)
42
+ @c = Refinery::Blog::Category.by_title("Testing Category")
43
+ end
44
+
45
+ it "suceeds" do
46
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
47
+ expect(Refinery::Blog::Category.count).to eq(1)
48
+ end
49
+
50
+ it "shows locale for category" do
51
+ click_link "Manage"
52
+ within "#category_#{@c.id}" do
53
+ expect(page).to have_css(".locale .en")
54
+ end
55
+ end
56
+
57
+ it "shows up in blog page for default locale" do
58
+ visit refinery.blog_root_path
59
+ within "#categories" do
60
+ expect(page).to have_selector('li')
61
+ end
62
+ end
63
+
64
+ it "does not show up in blog page for secondary locale" do
65
+ visit refinery.blog_root_path(:locale => :ru)
66
+ expect(page).not_to have_selector('#categories')
67
+ end
68
+
69
+ end
70
+
71
+ describe "add a category with title for secondary locale" do
72
+
73
+ let(:ru_category_title) { 'категория' }
74
+
75
+ before do
76
+ visit refinery.blog_admin_posts_path
77
+ click_link "Create new category"
78
+ within "#switch_locale_picker" do
79
+ click_link "RU"
80
+ end
81
+ fill_in "Title", :with => ru_category_title
82
+ expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1)
83
+ @c = Refinery::Blog::Category.by_title(ru_category_title)
84
+ end
85
+
86
+ it "suceeds" do
87
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
88
+ expect(Refinery::Blog::Category.count).to eq(1)
89
+ end
90
+
91
+ it "shows locale for category" do
92
+ click_link "Manage"
93
+ within "#category_#{@c.id}" do
94
+ expect(page).to have_css(".locale .ru")
95
+ end
96
+ end
97
+
98
+ it "does not show locale for primary locale" do
99
+ click_link "Manage"
100
+ within "#category_#{@c.id}" do
101
+ expect(page).not_to have_css(".locale .en")
102
+ end
103
+ end
104
+
105
+ it "does not shows up in blog page for default locale" do
106
+ visit refinery.blog_root_path
107
+ expect(page).not_to have_selector('#categories')
108
+ end
109
+
110
+ it "shows up in blog page for secondary locale" do
111
+ visit refinery.blog_root_path(:locale => :ru)
112
+ within "#categories" do
113
+ expect(page).to have_selector('li')
114
+ end
115
+ end
116
+ end
111
117
  end
112
118
  end
113
-
114
-
115
119
  end
116
-
117
-
118
120
  end
119
121
  end