bcms_blog 1.1.0 → 1.1.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.
- data/app/models/blog.rb +2 -2
- data/app/models/blog_observer.rb +3 -2
- data/app/views/layouts/templates/default.html.erb +17 -0
- data/app/views/partials/_blog_post.html.erb +3 -44
- data/app/views/portlets/blog_post/render.html.erb +3 -7
- data/doc/release_notes.txt +9 -4
- data/test/blog_test_helper.rb +52 -0
- data/test/factories.rb +0 -31
- data/test/functional/blog_controller_test.rb +63 -0
- data/test/functional/blog_post_controller_test.rb +31 -0
- data/test/functional/cms/blog_posts_controller_test.rb +3 -2
- data/test/functional/cms/blogs_controller_test.rb +3 -3
- data/test/test_helper.rb +8 -71
- data/test/unit/blog_comment_test.rb +1 -1
- data/test/unit/blog_observer_test.rb +1 -1
- data/test/unit/blog_post_test.rb +1 -1
- data/test/unit/blog_test.rb +1 -1
- metadata +26 -13
- data/app/views/partials/_blog_post.html.haml +0 -91
- data/test/functional/blog_post_test.rb +0 -37
- data/test/functional/blog_test.rb +0 -67
- data/test/functional/feeds_controller_test.rb +0 -8
data/app/models/blog.rb
CHANGED
@@ -25,8 +25,8 @@ class Blog < ActiveRecord::Base
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.posts_finder(finder, options)
|
28
|
-
if options[:
|
29
|
-
finder = finder.tagged_with(options[:
|
28
|
+
if options[:tag]
|
29
|
+
finder = finder.tagged_with(options[:tag])
|
30
30
|
end
|
31
31
|
if options[:exclude_tags]
|
32
32
|
finder = finder.not_tagged_with(options[:exclude_tags])
|
data/app/models/blog_observer.rb
CHANGED
@@ -111,11 +111,12 @@ class BlogObserver < ActiveRecord::Observer
|
|
111
111
|
|
112
112
|
def create_route(page, name, pattern)
|
113
113
|
route = page.page_routes.build(:name => name, :pattern => pattern, :code => "")
|
114
|
-
route.
|
114
|
+
route.send(:create_without_callbacks)
|
115
|
+
route.add_condition(:method, "get").save
|
115
116
|
route.add_requirement(:year, '\d{4,}') if pattern.include?(":year")
|
116
117
|
route.add_requirement(:month, '\d{2,}') if pattern.include?(":month")
|
117
118
|
route.add_requirement(:day, '\d{2,}') if pattern.include?(":day")
|
118
|
-
route.
|
119
|
+
route.requirements.each(&:save)
|
119
120
|
end
|
120
121
|
|
121
122
|
def create_portlet(page, name, portlet_class)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
5
|
+
<title><%= page_title %></title>
|
6
|
+
<%= yield :html_head %>
|
7
|
+
</head>
|
8
|
+
<body style="margin: 0; padding: 0; text-align: center;">
|
9
|
+
<%= cms_toolbar %>
|
10
|
+
<div id="wrapper" style="width: 700px; margin: 0 auto; text-align: left; padding: 30px">
|
11
|
+
Breadcrumbs: <%= render_breadcrumbs %>
|
12
|
+
Main Menu: <%= render_menu %>
|
13
|
+
<h1><%= page_title %></h1>
|
14
|
+
<%= container :main %>
|
15
|
+
</div>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -1,44 +1,3 @@
|
|
1
|
-
<style>
|
2
|
-
.blog_post {
|
3
|
-
border-bottom: 1px solid #ccc;
|
4
|
-
margin-bottom: 20px;
|
5
|
-
}
|
6
|
-
|
7
|
-
.blog_post h2 {
|
8
|
-
margin-bottom: 0
|
9
|
-
}
|
10
|
-
|
11
|
-
.blog_post h2,
|
12
|
-
.blog_post h2 a {
|
13
|
-
font: normal 30px/28px 'arial black', arial, sans-serif !important;
|
14
|
-
text-decoration: none !important;
|
15
|
-
}
|
16
|
-
.blog_post h2 a:hover {
|
17
|
-
text-decoration: underline !important;
|
18
|
-
}
|
19
|
-
|
20
|
-
.blog_post .image {
|
21
|
-
float: left;
|
22
|
-
border: 1px solid #ccc;
|
23
|
-
margin: 10px;
|
24
|
-
margin-top: 0;
|
25
|
-
}
|
26
|
-
.blog_post .date {
|
27
|
-
color: #666;
|
28
|
-
}
|
29
|
-
.blog_post .read_more {
|
30
|
-
font-weight: bold;
|
31
|
-
}
|
32
|
-
|
33
|
-
.blog_post .comment + .comment {
|
34
|
-
border-top: 1px dashed #ccc;
|
35
|
-
}
|
36
|
-
|
37
|
-
.clear {
|
38
|
-
clear: both;
|
39
|
-
}
|
40
|
-
</style>
|
41
|
-
|
42
1
|
<%
|
43
2
|
# _counter is defined only if we pass :collection to the partial
|
44
3
|
if defined?(blog_post_counter)
|
@@ -48,8 +7,7 @@
|
|
48
7
|
blog_post_counter = 0
|
49
8
|
end
|
50
9
|
%>
|
51
|
-
|
52
|
-
<div id="blog_post_<%= blog_post.id %>" class="blog_post clear">
|
10
|
+
<div id="blog_post_<%= blog_post.id %>" class="blog_post">
|
53
11
|
<% if blog_post.attachment %>
|
54
12
|
<div class="image">
|
55
13
|
<%= image_tag blog_post.attachment.file_path %>
|
@@ -87,7 +45,8 @@
|
|
87
45
|
|
88
46
|
<%= link_to h(pluralize(blog_post.comments.published.count, "Comment")), "#{_blog_post_path(blog_post)}#comments" %>
|
89
47
|
</div>
|
90
|
-
|
48
|
+
|
49
|
+
<br />
|
91
50
|
|
92
51
|
<% comments = blog_post.comments.published.reject(&:new_record?) %>
|
93
52
|
<% if showing_individual_post and comments.any? -%>
|
@@ -1,10 +1,6 @@
|
|
1
1
|
<% page_title @blog_post.name %>
|
2
2
|
<%= render :partial => "partials/blog_post", :object => @blog_post %>
|
3
3
|
|
4
|
-
<style>
|
5
|
-
@import url('/stylesheets/cms/form_layout.css');
|
6
|
-
</style>
|
7
|
-
|
8
4
|
<div class="blog_comment_form">
|
9
5
|
<% form_for @blog_comment, :url => cms_handler_path(@portlet, "create_comment") do |f| %>
|
10
6
|
<%= f.hidden_field :post_id %>
|
@@ -13,15 +9,15 @@
|
|
13
9
|
<%= f.label :author, 'Name *' %>
|
14
10
|
<%= f.text_field :author %>
|
15
11
|
</div>
|
16
|
-
<div class="fields text_fields
|
12
|
+
<div class="fields text_fields">
|
17
13
|
<%= f.label :email, 'E-mail address' %>
|
18
14
|
<%= f.text_field :email %>
|
19
15
|
</div>
|
20
|
-
<div class="fields text_fields
|
16
|
+
<div class="fields text_fields">
|
21
17
|
<%= f.label :url, 'Web site' %>
|
22
18
|
<%= f.text_field :url %>
|
23
19
|
</div>
|
24
|
-
<div class="fields text_editor_fields
|
20
|
+
<div class="fields text_editor_fields">
|
25
21
|
<%= f.label :body, 'Body *' %>
|
26
22
|
<br/>
|
27
23
|
<%= f.text_area :body, :size => "50x5", :style => 'height: auto' %>
|
data/doc/release_notes.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
v1.1.1
|
2
|
+
|
3
|
+
- Blog partials and templates no longer include any css style declarations
|
4
|
+
- Fixed browsing by tags, categories and dates
|
5
|
+
- Fixed bug on page route conditions and requirements when creating a blog
|
6
|
+
- Tests refactoring. Tests now depend on bcms_support gem
|
7
|
+
|
8
|
+
|
1
9
|
v1.1.0
|
2
10
|
|
3
11
|
This version introduces significant changes and improvements over version 1.0.0
|
@@ -34,7 +42,4 @@ https://browsermedia.lighthouseapp.com/projects/28481/tickets/163-review-and-int
|
|
34
42
|
Contributors:
|
35
43
|
=============
|
36
44
|
Tyler Rick
|
37
|
-
Jon Leighton
|
38
|
-
|
39
|
-
|
40
|
-
v1.0.0
|
45
|
+
Jon Leighton
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module BlogTestHelper
|
2
|
+
|
3
|
+
# Seeds all data created by this module's migrations
|
4
|
+
def seed_blog_data
|
5
|
+
@content_type_group = ContentTypeGroup.create!(:name => "Blog")
|
6
|
+
CategoryType.create!(:name => "Blog Post")
|
7
|
+
ContentType.create!(:name => "Blog", :content_type_group => @content_type_group)
|
8
|
+
ContentType.create!(:name => "BlogPost", :content_type_group => @content_type_group)
|
9
|
+
ContentType.create!(:name => "BlogComment", :content_type_group => @content_type_group)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Creates data specifically used on tests
|
13
|
+
def create_test_data
|
14
|
+
template = %q[<% page_title @page_title || @blog.name %><%= render :partial => "partials/blog_post", :collection => @blog_posts %>"]
|
15
|
+
@blog = Blog.create!(:name => "MyBlog", :template => template)
|
16
|
+
|
17
|
+
@category_type = CategoryType.find_by_name("Blog Post")
|
18
|
+
|
19
|
+
@stuff = Category.create!(:name => "Stuff", :category_type => @category_type)
|
20
|
+
@general = Category.create!(:name => "General", :category_type => @category_type)
|
21
|
+
|
22
|
+
opts = {:blog => @blog, :publish_on_save => true}
|
23
|
+
@first_post = Factory(:blog_post, opts.merge(:category => @general, :published_at => Time.utc(2008, 7, 5, 6), :name => "The first Post"))
|
24
|
+
@foo_post_1 = Factory(:blog_post, opts.merge(:category => @stuff, :published_at => Time.utc(2008, 7, 5, 12), :tag_list => "foo stuff"))
|
25
|
+
@foo_post_2 = Factory(:blog_post, opts.merge(:category => @general, :published_at => Time.utc(2008, 7, 21)))
|
26
|
+
@bar_post_1 = Factory(:blog_post, opts.merge(:category => @stuff, :published_at => Time.utc(2008, 9, 2), :tag_list => "foo stuff"))
|
27
|
+
@bar_post_2 = Factory(:blog_post, opts.merge(:category => @general, :published_at => Time.utc(2009, 3, 18)))
|
28
|
+
|
29
|
+
publish_all_pages
|
30
|
+
end
|
31
|
+
|
32
|
+
def setup_blog_stubs
|
33
|
+
Blog.any_instance.stubs(:reload_routes)
|
34
|
+
@section = Section.new
|
35
|
+
Section.stubs(:create! => @section)
|
36
|
+
@section.stubs(:groups => [], :save! => true)
|
37
|
+
Page.stubs(:create! => Page.new)
|
38
|
+
Page.any_instance.stubs(:create_connector)
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_group
|
42
|
+
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
43
|
+
@group.permissions << Factory(:permission, :name => "edit_content")
|
44
|
+
@group.permissions << Factory(:permission, :name => "publish_content")
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_user(opts = {})
|
48
|
+
create_group
|
49
|
+
@group.permissions << Factory(:permission, :name => "administrate") if opts[:admin]
|
50
|
+
@user = Factory(:user, :groups => [@group])
|
51
|
+
end
|
52
|
+
end
|
data/test/factories.rb
CHANGED
@@ -1,34 +1,3 @@
|
|
1
|
-
Factory.define :category_type do |m|
|
2
|
-
m.name "Blog Post"
|
3
|
-
end
|
4
|
-
|
5
|
-
Factory.define :group do |m|
|
6
|
-
m.sequence(:name) {|n| "TestGroup#{n}" }
|
7
|
-
m.association :group_type
|
8
|
-
end
|
9
|
-
|
10
|
-
Factory.define :group_type do |m|
|
11
|
-
m.sequence(:name) {|n| "TestGroupType#{n}" }
|
12
|
-
end
|
13
|
-
|
14
|
-
Factory.define :permission do |m|
|
15
|
-
m.name "edit_content"
|
16
|
-
end
|
17
|
-
|
18
|
-
Factory.define :user do |m|
|
19
|
-
m.first_name "Test"
|
20
|
-
m.last_name "User"
|
21
|
-
m.sequence(:login) {|n| "test_#{n}" }
|
22
|
-
m.email {|a| "#{a.login}@example.com" }
|
23
|
-
m.password "password"
|
24
|
-
m.password_confirmation {|a| a.password }
|
25
|
-
end
|
26
|
-
|
27
|
-
Factory.define :section do |m|
|
28
|
-
m.name "A Section"
|
29
|
-
m.path "/a-section"
|
30
|
-
end
|
31
|
-
|
32
1
|
Factory.define :blog do |m|
|
33
2
|
m.sequence(:name) {|n| "TestBlog#{n}"}
|
34
3
|
m.moderate_comments true
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class BlogControllerTest < ActionController::TestCase
|
4
|
+
tests Cms::ContentController
|
5
|
+
|
6
|
+
def setup
|
7
|
+
seed_bcms_data
|
8
|
+
seed_blog_data
|
9
|
+
create_test_data
|
10
|
+
end
|
11
|
+
|
12
|
+
test "displays the list of blog posts" do
|
13
|
+
get :show, :path => ['myblog']
|
14
|
+
|
15
|
+
assert_response :success
|
16
|
+
assert_select ".blog_post", 5
|
17
|
+
|
18
|
+
assert_select "#blog_post_#{@first_post.id}" do
|
19
|
+
assert_select "h2 a", @first_post.name
|
20
|
+
assert_select "div.body", @first_post.body
|
21
|
+
assert_select "div.meta" do
|
22
|
+
assert_select "a", 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_select "#blog_post_#{@foo_post_1.id}" do
|
27
|
+
assert_select "h2 a", @foo_post_1.name
|
28
|
+
assert_select "div.body", @foo_post_1.body
|
29
|
+
assert_select "div.meta .tags a", "foo"
|
30
|
+
assert_select "div.meta .tags a", "stuff"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
test "list of blog posts by category" do
|
35
|
+
get :show, :path => ['myblog'], :category => 'General'
|
36
|
+
assert_response :success
|
37
|
+
assert_select ".blog_post", 3
|
38
|
+
end
|
39
|
+
|
40
|
+
test "list of blog posts by tag" do
|
41
|
+
get :show, :path => ['myblog'], :tag => 'foo'
|
42
|
+
assert_response :success
|
43
|
+
assert_select ".blog_post", 2
|
44
|
+
end
|
45
|
+
|
46
|
+
test "list_of_blog_posts_in_day" do
|
47
|
+
get :show, :path => ["myblog"], :year => 2008, :month => 7, :day => 5
|
48
|
+
assert_response :success
|
49
|
+
assert_select ".blog_post", 2
|
50
|
+
end
|
51
|
+
|
52
|
+
test "list_of_blog_posts_in_month" do
|
53
|
+
get :show, :path => ["myblog"], :year => 2008, :month => 7
|
54
|
+
assert_response :success
|
55
|
+
assert_select ".blog_post", 3
|
56
|
+
end
|
57
|
+
|
58
|
+
test "list_of_blog_posts_in_year" do
|
59
|
+
get :show, :path => ["myblog"], :year => 2008
|
60
|
+
assert_response :success
|
61
|
+
assert_select ".blog_post", 4
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class BlogPostControllerTest < ActionController::TestCase
|
4
|
+
tests Cms::ContentController
|
5
|
+
|
6
|
+
def setup
|
7
|
+
seed_bcms_data
|
8
|
+
seed_blog_data
|
9
|
+
create_test_data
|
10
|
+
end
|
11
|
+
|
12
|
+
test "show_post" do
|
13
|
+
get :show, :path => ['myblog', 'post'], :year => 2008, :month => 07, :day => 05, :slug => 'the-first-post'
|
14
|
+
assert_response :success
|
15
|
+
|
16
|
+
assert_select "title", @first_post.name
|
17
|
+
assert_select ".blog_post", 1
|
18
|
+
|
19
|
+
assert_select "#blog_post_#{@first_post.id}" do
|
20
|
+
assert_select "h2 a", @first_post.name
|
21
|
+
assert_select "div.body", @first_post.body
|
22
|
+
assert_select "div.meta a", "General"
|
23
|
+
assert_select "div.meta a", "0 Comments"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
test "non_existent_post_should_return_404" do
|
28
|
+
get :show, :path => ["myblog"], :year => 2005, :month => 6, :day => 14, :slug => "not-here"
|
29
|
+
assert_response :not_found
|
30
|
+
end
|
31
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
2
2
|
|
3
3
|
class Cms::BlogPostsControllerTest < ActionController::TestCase
|
4
|
+
|
4
5
|
def setup
|
5
|
-
|
6
|
+
setup_blog_stubs
|
6
7
|
ContentType.create!(:name => 'BlogPost', :group_name => 'Blog')
|
7
|
-
login_as(
|
8
|
+
login_as(create_user)
|
8
9
|
end
|
9
10
|
|
10
11
|
def test_access_denied_on_create_if_blog_not_user_editable
|
@@ -3,13 +3,13 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
3
3
|
class Cms::BlogsControllerTest < ActionController::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
6
|
+
setup_blog_stubs
|
7
7
|
ContentType.create!(:name => 'Blog', :group_name => 'Blog')
|
8
8
|
Factory(:blog)
|
9
9
|
end
|
10
10
|
|
11
11
|
test "should allow access to admin users" do
|
12
|
-
login_as(
|
12
|
+
login_as(create_user(:admin => true))
|
13
13
|
get :index
|
14
14
|
assert_response :success
|
15
15
|
assert assigns(:blocks)
|
@@ -17,7 +17,7 @@ class Cms::BlogsControllerTest < ActionController::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test "should not allow access to non-admin users" do
|
20
|
-
login_as(
|
20
|
+
login_as(create_user)
|
21
21
|
get :index
|
22
22
|
assert_response :success
|
23
23
|
assert_template("admin_only.html.erb")
|
data/test/test_helper.rb
CHANGED
@@ -1,81 +1,18 @@
|
|
1
1
|
ENV["RAILS_ENV"] = "test"
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
3
|
require 'test_help'
|
4
|
-
require 'factory_girl'
|
5
4
|
require 'mocha'
|
5
|
+
require 'factory_girl'
|
6
|
+
require 'bcms_support'
|
7
|
+
require 'bcms_support/factories'
|
8
|
+
require 'blog_test_helper'
|
9
|
+
require 'test_logging'
|
6
10
|
|
7
11
|
class ActiveSupport::TestCase
|
8
|
-
|
9
|
-
include
|
10
|
-
include
|
12
|
+
include BcmsSupport::Test
|
13
|
+
include BlogTestHelper
|
14
|
+
include TestLogging
|
11
15
|
|
12
16
|
self.use_transactional_fixtures = true
|
13
17
|
self.use_instantiated_fixtures = false
|
14
|
-
|
15
|
-
fixtures :all
|
16
|
-
|
17
|
-
def create_baseline_data
|
18
|
-
load_bcms_seed_data
|
19
|
-
|
20
|
-
@blog = Blog.create!(:name => "MyBlog")
|
21
|
-
@blog.publish!
|
22
|
-
Page.all.each(&:publish)
|
23
|
-
@category_type = Factory(:category_type)
|
24
|
-
|
25
|
-
# For some reason this is necessary otherwise the relevant page routes aren't loaded when
|
26
|
-
# the tests are run via "rake" (as opposed to running them directly). I don't know exactly
|
27
|
-
# why this is the case.
|
28
|
-
# ActionController::Routing::Routes.load!
|
29
|
-
|
30
|
-
@stuff = Category.create!(:name => "Stuff", :category_type => @category_type)
|
31
|
-
@general = Category.create!(:name => "General", :category_type => @category_type)
|
32
|
-
|
33
|
-
@first_post = Factory(:blog_post, :blog => @blog, :category => @general,
|
34
|
-
:published_at => Time.utc(2008, 7, 5, 6), :publish_on_save => true)
|
35
|
-
|
36
|
-
@foo_post_1 = Factory(:blog_post, :blog => @blog, :category => @stuff,
|
37
|
-
:published_at => Time.utc(2008, 7, 5, 12), :tag_list => "foo stuff", :publish_on_save => true)
|
38
|
-
|
39
|
-
@foo_post_2 = Factory(:blog_post, :blog => @blog, :category => @general,
|
40
|
-
:published_at => Time.utc(2008, 7, 21), :publish_on_save => true)
|
41
|
-
|
42
|
-
@bar_post_1 = Factory(:blog_post, :blog => @blog, :category => @stuff,
|
43
|
-
:published_at => Time.utc(2008, 9, 2), :tag_list => "foo stuff", :publish_on_save => true)
|
44
|
-
|
45
|
-
@bar_post_2 = Factory(:blog_post, :blog => @blog, :category => @general,
|
46
|
-
:published_at => Time.utc(2009, 3, 18), :publish_on_save => true)
|
47
|
-
end
|
48
|
-
|
49
|
-
def setup_stubs
|
50
|
-
Blog.any_instance.stubs(:reload_routes)
|
51
|
-
@section = Section.new
|
52
|
-
Section.stubs(:create! => @section)
|
53
|
-
@section.stubs(:groups => [], :save! => true)
|
54
|
-
Page.stubs(:create! => Page.new)
|
55
|
-
Page.any_instance.stubs(:create_connector)
|
56
|
-
end
|
57
|
-
|
58
|
-
def login_as(user)
|
59
|
-
@request.session[:user_id] = user ? user.id : nil
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
# TODO Find a better way to load this data
|
64
|
-
def load_bcms_seed_data
|
65
|
-
require File.join(Rails.root, 'db', 'migrate', '20081114172307_load_seed_data.rb')
|
66
|
-
LoadSeedData.up
|
67
|
-
end
|
68
|
-
|
69
|
-
#Cms::DataLoader defines methods create_group and create_user
|
70
|
-
def _create_group
|
71
|
-
@group = Factory(:group, :name => "Test", :group_type => Factory(:group_type, :name => "CMS User", :cms_access => true))
|
72
|
-
@group.permissions << Factory(:permission, :name => "edit_content")
|
73
|
-
@group.permissions << Factory(:permission, :name => "publish_content")
|
74
|
-
end
|
75
|
-
|
76
|
-
def _create_user(opts = {})
|
77
|
-
_create_group
|
78
|
-
@group.permissions << Factory(:permission, :name => "administrate") if opts[:admin]
|
79
|
-
@user = Factory(:user, :groups => [@group])
|
80
|
-
end
|
81
18
|
end
|
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
3
3
|
class BlogObserverTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
6
|
+
setup_blog_stubs
|
7
7
|
[Section, PageRoute, Page].each {|klass| klass.stubs(:find_by_name)}
|
8
8
|
BlogPostPortlet.stubs(:create!)
|
9
9
|
@blog = Factory(:blog, :name => 'TestBlog')
|
data/test/unit/blog_post_test.rb
CHANGED
data/test/unit/blog_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BrowserMedia
|
@@ -15,10 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-11 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bcms_support
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
22
35
|
description: The Blog Module for BrowserCMS
|
23
36
|
email: github@browsermedia.com
|
24
37
|
executables: []
|
@@ -53,8 +66,8 @@ files:
|
|
53
66
|
- app/views/cms/blogs/admin_only.html.erb
|
54
67
|
- app/views/cms/blogs/render.html.erb
|
55
68
|
- app/views/feeds/index.rss.builder
|
69
|
+
- app/views/layouts/templates/default.html.erb
|
56
70
|
- app/views/partials/_blog_post.html.erb
|
57
|
-
- app/views/partials/_blog_post.html.haml
|
58
71
|
- app/views/portlets/blog_post/_form.html.erb
|
59
72
|
- app/views/portlets/blog_post/render.html.erb
|
60
73
|
- app/views/portlets/blog_posts/_form.html.erb
|
@@ -72,12 +85,12 @@ files:
|
|
72
85
|
- rails/init.rb
|
73
86
|
- LICENSE.txt
|
74
87
|
- README.markdown
|
88
|
+
- test/blog_test_helper.rb
|
75
89
|
- test/factories.rb
|
76
|
-
- test/functional/
|
77
|
-
- test/functional/
|
90
|
+
- test/functional/blog_controller_test.rb
|
91
|
+
- test/functional/blog_post_controller_test.rb
|
78
92
|
- test/functional/cms/blog_posts_controller_test.rb
|
79
93
|
- test/functional/cms/blogs_controller_test.rb
|
80
|
-
- test/functional/feeds_controller_test.rb
|
81
94
|
- test/performance/browsing_test.rb
|
82
95
|
- test/test_helper.rb
|
83
96
|
- test/test_logging.rb
|
@@ -121,12 +134,12 @@ signing_key:
|
|
121
134
|
specification_version: 3
|
122
135
|
summary: The Blog Module for BrowserCMS
|
123
136
|
test_files:
|
137
|
+
- test/blog_test_helper.rb
|
124
138
|
- test/factories.rb
|
125
|
-
- test/functional/
|
126
|
-
- test/functional/
|
139
|
+
- test/functional/blog_controller_test.rb
|
140
|
+
- test/functional/blog_post_controller_test.rb
|
127
141
|
- test/functional/cms/blog_posts_controller_test.rb
|
128
142
|
- test/functional/cms/blogs_controller_test.rb
|
129
|
-
- test/functional/feeds_controller_test.rb
|
130
143
|
- test/performance/browsing_test.rb
|
131
144
|
- test/test_helper.rb
|
132
145
|
- test/test_logging.rb
|
@@ -1,91 +0,0 @@
|
|
1
|
-
%style
|
2
|
-
:sass
|
3
|
-
.blog_post.first
|
4
|
-
h2, h2 a
|
5
|
-
font: normal 30px/28px 'arial black', arial, sans-serif !important
|
6
|
-
border-bottom: 1px solid #ccc
|
7
|
-
|
8
|
-
.blog_post
|
9
|
-
border: 0px solid gray
|
10
|
-
margin-bottom: 20px
|
11
|
-
|
12
|
-
h2
|
13
|
-
margin-bottom: 0
|
14
|
-
h2, h2 a
|
15
|
-
font: normal 20px/23px 'arial black', arial, sans-serif !important
|
16
|
-
text-decoration: none !important
|
17
|
-
h2 a:hover
|
18
|
-
text-decoration: underline !important
|
19
|
-
|
20
|
-
.image
|
21
|
-
float: left
|
22
|
-
border: 1px solid #ccc
|
23
|
-
margin: 10px
|
24
|
-
margin-top: 0
|
25
|
-
|
26
|
-
.date
|
27
|
-
color: #666
|
28
|
-
.read_more
|
29
|
-
font-weight: bold
|
30
|
-
|
31
|
-
.comment + .comment
|
32
|
-
border-top: 1px dashed #ccc
|
33
|
-
|
34
|
-
.clear
|
35
|
-
clear: both
|
36
|
-
|
37
|
-
:ruby
|
38
|
-
# _counter is defined only if we pass :collection to the partial
|
39
|
-
if defined?(blog_post_counter)
|
40
|
-
showing_individual_post = false
|
41
|
-
else
|
42
|
-
showing_individual_post = true
|
43
|
-
blog_post_counter = 0
|
44
|
-
end
|
45
|
-
|
46
|
-
if blog_post_counter == 0
|
47
|
-
max_width = 250
|
48
|
-
css_class = 'first'
|
49
|
-
else
|
50
|
-
max_width = 75
|
51
|
-
css_class = ''
|
52
|
-
end
|
53
|
-
|
54
|
-
.blog_post.clear{:id => "blog_post_#{blog_post.id}", :class => css_class}
|
55
|
-
- if blog_post.attachment
|
56
|
-
-# .image= image_tag_with_max_size blog_post.attachment.file_path, blog_post.attachment.full_file_location, :width => max_width
|
57
|
-
.image= image_tag blog_post.attachment.file_path
|
58
|
-
|
59
|
-
%h2= link_to h(blog_post.name), href = _blog_post_path(blog_post)
|
60
|
-
|
61
|
-
.date= blog_post.published_at.to_s(:long)
|
62
|
-
|
63
|
-
.body
|
64
|
-
- if showing_individual_post or blog_post.summary.blank?
|
65
|
-
= blog_post.body
|
66
|
-
- else
|
67
|
-
= blog_post.summary
|
68
|
-
%p.read_more= link_to 'Read More »', href
|
69
|
-
|
70
|
-
- if showing_individual_post || blog_post_counter == 0
|
71
|
-
.meta
|
72
|
-
- unless blog_post.category_id.blank?
|
73
|
-
Posted in #{link_to h(blog_post.category_name), _blog_path(blog_post.blog, 'posts_in_category', :category => blog_post.category_name)}
|
74
|
-
%strong |
|
75
|
-
- if blog_post.tags.any?
|
76
|
-
Tags:
|
77
|
-
%span.tags
|
78
|
-
= blog_post.tags.map{|t| link_to(h(t.name), _blog_path(blog_post.blog, 'posts_with_tag', :tag => t.name)) }.join(", ")
|
79
|
-
%strong |
|
80
|
-
= link_to h(pluralize(blog_post.comments_count, "Comment")), "#{_blog_post_path(blog_post)}#comments"
|
81
|
-
%br.clear/
|
82
|
-
|
83
|
-
- comments = blog_post.comments.reject(&:new_record?)
|
84
|
-
- if showing_individual_post and comments.any?
|
85
|
-
%h2 Comments
|
86
|
-
- comments.each_with_index do |comment, i|
|
87
|
-
%div{:class => "comment #{'first' if i == 0}"}
|
88
|
-
= h comment.body
|
89
|
-
%p
|
90
|
-
\—#{comment.url.present? ? link_to(h(comment.author), comment.url) : h(comment.author)}
|
91
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class BlogPostTest < ActionController::TestCase
|
4
|
-
tests Cms::ContentController
|
5
|
-
|
6
|
-
def setup
|
7
|
-
create_baseline_data
|
8
|
-
end
|
9
|
-
|
10
|
-
=begin
|
11
|
-
def test_show_post
|
12
|
-
get :show, :path => ["myblog"],
|
13
|
-
:year => 2008,
|
14
|
-
:month => 07,
|
15
|
-
:day => 05
|
16
|
-
log @response.body
|
17
|
-
assert_response :success
|
18
|
-
assert_select "title", @first_post.name
|
19
|
-
assert_select ".blog_post", 1
|
20
|
-
|
21
|
-
assert_select "#blog_post_#{@first_post.id}" do
|
22
|
-
assert_select "h2 a", @first_post.name
|
23
|
-
assert_select "p.body", @first_post.body
|
24
|
-
assert_select "p.meta a", "General"
|
25
|
-
assert_select "p.meta a", "0 Comments"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
=end
|
29
|
-
|
30
|
-
def test_non_existent_slug_should_return_404
|
31
|
-
get :show, :path => ["blog", "post"],
|
32
|
-
:year => 2005, :month => 6, :day => 14,
|
33
|
-
:slug => "not-here"
|
34
|
-
assert_response :not_found
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
|
3
|
-
class BlogTest < ActionController::TestCase
|
4
|
-
tests Cms::ContentController
|
5
|
-
|
6
|
-
def setup
|
7
|
-
create_baseline_data
|
8
|
-
end
|
9
|
-
|
10
|
-
=begin
|
11
|
-
test "displays the list of blog posts" do
|
12
|
-
get :show, :path => ['myblog']
|
13
|
-
log @response.body
|
14
|
-
assert_response :success
|
15
|
-
assert_select ".blog_post", 5
|
16
|
-
|
17
|
-
assert_select "#blog_post_#{@first_post.id}" do
|
18
|
-
assert_select "h2 a", @first_post.name
|
19
|
-
assert_select "p.body", @first_post.body
|
20
|
-
assert_select "p.meta a", "General"
|
21
|
-
assert_select "p.meta a", "0 Comments"
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_select "#blog_post_#{@foo_post_1.id}" do
|
25
|
-
assert_select "h2 a", @foo_post_1.name
|
26
|
-
assert_select "p.body", @foo_post_1.body
|
27
|
-
assert_select "p.meta .tags a", "foo"
|
28
|
-
assert_select "p.meta .tags a", "stuff"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_list_of_tagged_blog_posts
|
33
|
-
get :show, :category => "General"
|
34
|
-
puts @response.body
|
35
|
-
assert_response :success
|
36
|
-
assert_select ".blog_post", 3
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_list_of_categorized_blog_posts
|
40
|
-
get :show, :tag => "foo"
|
41
|
-
assert_response :success
|
42
|
-
assert_select ".blog_post", 2
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_list_of_blog_posts_in_day
|
46
|
-
get :show, :path => ["blog", "posts_in_day"],
|
47
|
-
:year => 2008, :month => 7, :day => 5
|
48
|
-
assert_response :success
|
49
|
-
assert_select ".blog_post", 2
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_list_of_blog_posts_in_month
|
53
|
-
get :show, :path => ["blog", "posts_in_month"],
|
54
|
-
:year => 2008, :month => 7
|
55
|
-
assert_response :success
|
56
|
-
assert_select ".blog_post", 3
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_list_of_blog_posts_in_year
|
60
|
-
get :show, :path => ["blog", "posts_in_year"],
|
61
|
-
:year => 2008
|
62
|
-
assert_response :success
|
63
|
-
assert_select ".blog_post", 4
|
64
|
-
end
|
65
|
-
=end
|
66
|
-
|
67
|
-
end
|