muck-contents 0.2.11 → 0.2.12
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/VERSION +1 -1
- data/lib/active_record/acts/muck_content.rb +7 -7
- data/muck-contents.gemspec +5 -4
- data/test/rails_root/app/models/comment.rb +18 -0
- data/test/rails_root/app/models/content.rb +24 -1
- data/test/rails_root/app/models/content_permission.rb +12 -1
- data/test/rails_root/app/models/content_translation.rb +15 -1
- data/test/rails_root/app/models/upload.rb +6 -13
- data/test/rails_root/app/models/user.rb +32 -1
- data/test/rails_root/config/database.yml +12 -14
- data/test/rails_root/test/unit/content_permission_test.rb +12 -1
- data/test/rails_root/test/unit/content_test.rb +66 -8
- data/test/rails_root/test/unit/content_translation_test.rb +57 -20
- data/test/rails_root/test/unit/user_test.rb +32 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.12
|
@@ -32,13 +32,13 @@ module ActiveRecord
|
|
32
32
|
has_many :content_permissions, :dependent => :destroy
|
33
33
|
has_many :content_translations, :dependent => :destroy
|
34
34
|
|
35
|
-
named_scope :by_newest, :order => "created_at DESC"
|
36
|
-
named_scope :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } }
|
37
|
-
named_scope :by_alpha, :order => "title ASC"
|
38
|
-
named_scope :public, :conditions => "is_public = true"
|
39
|
-
named_scope :by_parent, lambda { |parent_id| { :conditions => ['parent_id = ?', parent_id || 0] } }
|
40
|
-
named_scope :by_creator, lambda { |creator_id| { :conditions => ['creator_id = ?', creator_id || 0] } }
|
41
|
-
named_scope :no_contentable, :conditions => 'contentable_id IS NULL'
|
35
|
+
named_scope :by_newest, :order => "contents.created_at DESC"
|
36
|
+
named_scope :recent, lambda { { :conditions => ['contents.created_at > ?', 1.week.ago] } }
|
37
|
+
named_scope :by_alpha, :order => "contents.title ASC"
|
38
|
+
named_scope :public, :conditions => "contents.is_public = true"
|
39
|
+
named_scope :by_parent, lambda { |parent_id| { :conditions => ['contents.parent_id = ?', parent_id || 0] } }
|
40
|
+
named_scope :by_creator, lambda { |creator_id| { :conditions => ['contents.creator_id = ?', creator_id || 0] } }
|
41
|
+
named_scope :no_contentable, :conditions => 'contents.contentable_id IS NULL'
|
42
42
|
# include the '/' in case the user forgets. Note 'get_content_scope' will add the '/' so
|
43
43
|
# if we don't include it here the content won't be found as the scope won't match up.
|
44
44
|
named_scope :by_scope, lambda { |scope| { :conditions => ["slugs.scope = ?", File.join('/', scope)], :include => [:slugs] } }
|
data/muck-contents.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-contents}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-12-16}
|
13
13
|
s.email = %q{justin@tatemae.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.rdoc"
|
@@ -3136,3 +3136,4 @@ Gem::Specification.new do |s|
|
|
3136
3136
|
s.add_dependency(%q<fleakr>, [">= 0"])
|
3137
3137
|
end
|
3138
3138
|
end
|
3139
|
+
|
@@ -1,3 +1,21 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: comments
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# commentable_id :integer default(0)
|
7
|
+
# commentable_type :string(15) default("")
|
8
|
+
# body :text
|
9
|
+
# user_id :integer
|
10
|
+
# parent_id :integer
|
11
|
+
# lft :integer
|
12
|
+
# rgt :integer
|
13
|
+
# is_denied :integer default(0), not null
|
14
|
+
# is_reviewed :boolean
|
15
|
+
# created_at :datetime
|
16
|
+
# updated_at :datetime
|
17
|
+
#
|
18
|
+
|
1
19
|
class Comment < ActiveRecord::Base
|
2
20
|
|
3
21
|
acts_as_muck_comment
|
@@ -1,7 +1,30 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: contents
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# creator_id :integer
|
7
|
+
# title :string(255)
|
8
|
+
# body :text
|
9
|
+
# locale :string(255)
|
10
|
+
# body_raw :text
|
11
|
+
# contentable_id :integer
|
12
|
+
# contentable_type :string(255)
|
13
|
+
# parent_id :integer
|
14
|
+
# lft :integer
|
15
|
+
# rgt :integer
|
16
|
+
# is_public :boolean
|
17
|
+
# state :string(255)
|
18
|
+
# created_at :datetime
|
19
|
+
# updated_at :datetime
|
20
|
+
# layout :string(255)
|
21
|
+
# comment_count :integer default(0)
|
22
|
+
#
|
23
|
+
|
1
24
|
class Content < ActiveRecord::Base
|
2
25
|
acts_as_muck_content(
|
3
26
|
:git_repository => GlobalConfig.content_git_repository,
|
4
27
|
:enable_auto_translations => GlobalConfig.enable_auto_translations,
|
5
28
|
:enable_solr => GlobalConfig.content_enable_solr
|
6
29
|
)
|
7
|
-
end
|
30
|
+
end
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: content_permissions
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# content_id :integer
|
7
|
+
# user_id :integer
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
1
12
|
class ContentPermission < ActiveRecord::Base
|
2
13
|
acts_as_muck_content_permission
|
3
|
-
end
|
14
|
+
end
|
@@ -1,3 +1,17 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: content_translations
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# content_id :integer
|
7
|
+
# title :string(255)
|
8
|
+
# body :text
|
9
|
+
# locale :string(255)
|
10
|
+
# user_edited :boolean
|
11
|
+
# created_at :datetime
|
12
|
+
# updated_at :datetime
|
13
|
+
#
|
14
|
+
|
1
15
|
class ContentTranslation < ActiveRecord::Base
|
2
16
|
acts_as_muck_content_translation
|
3
|
-
end
|
17
|
+
end
|
@@ -2,34 +2,27 @@
|
|
2
2
|
#
|
3
3
|
# Table name: uploads
|
4
4
|
#
|
5
|
-
# id :integer
|
6
|
-
# creator_id :integer
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# creator_id :integer
|
7
7
|
# name :string(255)
|
8
8
|
# caption :string(1000)
|
9
9
|
# description :text
|
10
|
-
# is_public :boolean
|
11
|
-
# uploadable_id :integer
|
10
|
+
# is_public :boolean default(TRUE)
|
11
|
+
# uploadable_id :integer
|
12
12
|
# uploadable_type :string(255)
|
13
13
|
# width :string(255)
|
14
14
|
# height :string(255)
|
15
15
|
# local_file_name :string(255)
|
16
16
|
# local_content_type :string(255)
|
17
|
-
# local_file_size :integer
|
17
|
+
# local_file_size :integer
|
18
18
|
# local_updated_at :datetime
|
19
19
|
# remote_file_name :string(255)
|
20
20
|
# remote_content_type :string(255)
|
21
|
-
# remote_file_size :integer
|
21
|
+
# remote_file_size :integer
|
22
22
|
# remote_updated_at :datetime
|
23
23
|
# created_at :datetime
|
24
24
|
# updated_at :datetime
|
25
25
|
#
|
26
|
-
# Indexes
|
27
|
-
#
|
28
|
-
# index_uploads_on_creator_id (creator_id)
|
29
|
-
# index_uploads_on_uploadable_id (uploadable_id)
|
30
|
-
# index_uploads_on_uploadable_type (uploadable_type)
|
31
|
-
# index_uploads_on_local_content_type (local_content_type)
|
32
|
-
#
|
33
26
|
|
34
27
|
class Upload < ActiveRecord::Base
|
35
28
|
|
@@ -1,3 +1,34 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: users
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# login :string(255)
|
7
|
+
# email :string(255)
|
8
|
+
# first_name :string(255)
|
9
|
+
# last_name :string(255)
|
10
|
+
# crypted_password :string(255)
|
11
|
+
# password_salt :string(255)
|
12
|
+
# persistence_token :string(255) not null
|
13
|
+
# single_access_token :string(255) not null
|
14
|
+
# perishable_token :string(255) not null
|
15
|
+
# login_count :integer default(0), not null
|
16
|
+
# failed_login_count :integer default(0), not null
|
17
|
+
# last_request_at :datetime
|
18
|
+
# current_login_at :datetime
|
19
|
+
# last_login_at :datetime
|
20
|
+
# current_login_ip :string(255)
|
21
|
+
# last_login_ip :string(255)
|
22
|
+
# terms_of_service :boolean not null
|
23
|
+
# time_zone :string(255) default("UTC")
|
24
|
+
# disabled_at :datetime
|
25
|
+
# created_at :datetime
|
26
|
+
# activated_at :datetime
|
27
|
+
# updated_at :datetime
|
28
|
+
# identity_url :string(255)
|
29
|
+
# url_key :string(255)
|
30
|
+
#
|
31
|
+
|
1
32
|
class User < ActiveRecord::Base
|
2
33
|
acts_as_authentic do |c|
|
3
34
|
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
|
@@ -14,4 +45,4 @@ class User < ActiveRecord::Base
|
|
14
45
|
true
|
15
46
|
end
|
16
47
|
|
17
|
-
end
|
48
|
+
end
|
@@ -1,19 +1,17 @@
|
|
1
1
|
development:
|
2
|
-
adapter:
|
3
|
-
database:
|
4
|
-
|
2
|
+
adapter: mysql
|
3
|
+
database: muck_contents
|
4
|
+
username: root
|
5
|
+
password:
|
6
|
+
host: localhost
|
7
|
+
encoding: utf8
|
5
8
|
|
6
9
|
test: &TEST
|
7
|
-
adapter:
|
8
|
-
database:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
database: db/production.sqlite3
|
14
|
-
timeout: 5000
|
15
|
-
|
16
|
-
cucumber:
|
17
|
-
<<: *TEST
|
10
|
+
adapter: mysql
|
11
|
+
database: muck_contents_test
|
12
|
+
username: root
|
13
|
+
password:
|
14
|
+
host: localhost
|
15
|
+
encoding: utf8
|
18
16
|
cucumber:
|
19
17
|
<<: *TEST
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: content_permissions
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# content_id :integer
|
7
|
+
# user_id :integer
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
1
12
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
13
|
|
3
14
|
# Used to test muck_content_permission
|
@@ -29,4 +40,4 @@ class ContentPermissionTest < ActiveSupport::TestCase
|
|
29
40
|
|
30
41
|
end
|
31
42
|
|
32
|
-
end
|
43
|
+
end
|
@@ -1,3 +1,26 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: contents
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# creator_id :integer
|
7
|
+
# title :string(255)
|
8
|
+
# body :text
|
9
|
+
# locale :string(255)
|
10
|
+
# body_raw :text
|
11
|
+
# contentable_id :integer
|
12
|
+
# contentable_type :string(255)
|
13
|
+
# parent_id :integer
|
14
|
+
# lft :integer
|
15
|
+
# rgt :integer
|
16
|
+
# is_public :boolean
|
17
|
+
# state :string(255)
|
18
|
+
# created_at :datetime
|
19
|
+
# updated_at :datetime
|
20
|
+
# layout :string(255)
|
21
|
+
# comment_count :integer default(0)
|
22
|
+
#
|
23
|
+
|
1
24
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
25
|
|
3
26
|
# Used to test muck_content
|
@@ -29,15 +52,50 @@ class ContentTest < ActiveSupport::TestCase
|
|
29
52
|
should_validate_presence_of :body_raw
|
30
53
|
should_validate_presence_of :locale
|
31
54
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
55
|
+
should_scope_by_newest
|
56
|
+
should_scope_recent
|
57
|
+
should_scope_public
|
58
|
+
should_scope_by_alpha_title
|
59
|
+
should_scope_by_creator
|
60
|
+
|
38
61
|
should_sanitize :title
|
39
62
|
should_sanitize :body
|
40
|
-
|
63
|
+
|
64
|
+
context "named scopes" do
|
65
|
+
context "no_contentable" do
|
66
|
+
# named_scope :no_contentable, :conditions => 'contentable_id IS NULL'
|
67
|
+
setup do
|
68
|
+
@user = Factory(:user)
|
69
|
+
@content_not = Factory(:content, :contentable => nil)
|
70
|
+
@content = Factory(:content, :contentable => @user)
|
71
|
+
end
|
72
|
+
should "not find content with contentable association" do
|
73
|
+
assert !Content.no_contentable.include?(@content)
|
74
|
+
end
|
75
|
+
should "find content without contentable association" do
|
76
|
+
assert Content.no_contentable.include?(@content_not)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
context "by_scope" do
|
80
|
+
# named_scope :by_scope, lambda { |scope| { :conditions => ["slugs.scope = ?", File.join('/', scope)], :include => [:slugs] } }
|
81
|
+
# TODO add test
|
82
|
+
end
|
83
|
+
context "by_parent" do
|
84
|
+
# named_scope :by_parent, lambda { |parent_id| { :conditions => ['parent_id = ?', parent_id || 0] } }
|
85
|
+
setup do
|
86
|
+
Content.delete_all
|
87
|
+
@parent_content = Factory(:content)
|
88
|
+
@item = Factory(:content, :parent => @parent_content)
|
89
|
+
@item1 = Factory(:content)
|
90
|
+
end
|
91
|
+
should "find items by the source they are associated with" do
|
92
|
+
items = Content.by_parent(@parent_content)
|
93
|
+
assert items.include?(@item), "created_by didn't find item whose parent is user"
|
94
|
+
assert !items.include?(@item1), "created_by found item that should not have user as a parent"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
41
99
|
context "translations" do
|
42
100
|
should "have localized title" do
|
43
101
|
assert_equal 'hola', @content.locale_title('es')
|
@@ -288,4 +346,4 @@ class ContentTest < ActiveSupport::TestCase
|
|
288
346
|
end
|
289
347
|
end
|
290
348
|
|
291
|
-
end
|
349
|
+
end
|
@@ -1,3 +1,17 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: content_translations
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# content_id :integer
|
7
|
+
# title :string(255)
|
8
|
+
# body :text
|
9
|
+
# locale :string(255)
|
10
|
+
# user_edited :boolean
|
11
|
+
# created_at :datetime
|
12
|
+
# updated_at :datetime
|
13
|
+
#
|
14
|
+
|
1
15
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
16
|
|
3
17
|
# Used to test muck_content_translation
|
@@ -6,36 +20,59 @@ class ContentTranslationTest < ActiveSupport::TestCase
|
|
6
20
|
context "A content translation instance" do
|
7
21
|
setup do
|
8
22
|
@content_translation = Factory(:content_translation)
|
9
|
-
end
|
10
|
-
|
23
|
+
end
|
11
24
|
subject { @content_translation }
|
12
|
-
|
13
25
|
should_belong_to :content
|
14
|
-
|
15
|
-
should_have_named_scope :recent
|
16
|
-
should_have_named_scope :by_alpha
|
17
|
-
should_have_named_scope :by_locale
|
26
|
+
should_scope_recent
|
18
27
|
end
|
19
28
|
|
20
|
-
context "
|
29
|
+
context "named scope" do
|
30
|
+
|
21
31
|
setup do
|
32
|
+
@content = Factory(:content)
|
22
33
|
ContentTranslation.destroy_all
|
23
|
-
@
|
24
|
-
@
|
34
|
+
@first = Factory(:content_translation, :created_at => 1.day.ago, :content => @content, :title => 'a')
|
35
|
+
@second = Factory(:content_translation, :created_at => 1.week.ago, :content => @content, :title => 'b')
|
25
36
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
37
|
+
|
38
|
+
# We have to build a custom 'by_newest' and 'by_alpha' test here since creating a content object
|
39
|
+
# will create a large number of content translations.
|
40
|
+
context "by_newest scope" do
|
41
|
+
should "sort by created_at" do
|
42
|
+
assert_equal @first, ContentTranslation.by_newest[0]
|
43
|
+
assert_equal @second, ContentTranslation.by_newest[1]
|
44
|
+
end
|
29
45
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
46
|
+
|
47
|
+
context "by_alpha" do
|
48
|
+
should "sort by title" do
|
49
|
+
assert_equal @first, ContentTranslation.by_alpha[0]
|
50
|
+
assert_equal @second, ContentTranslation.by_alpha[1]
|
51
|
+
end
|
33
52
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
53
|
+
|
54
|
+
context "find by locale" do
|
55
|
+
#named_scope :by_locale, lambda { |locale| { :conditions => ['content_translations.locale = ?', locale] } }
|
56
|
+
setup do
|
57
|
+
ContentTranslation.destroy_all
|
58
|
+
@content_one = Factory(:content)
|
59
|
+
@content_two = Factory(:content)
|
60
|
+
end
|
61
|
+
should "find two English translations" do
|
62
|
+
translations = ContentTranslation.by_locale('en')
|
63
|
+
assert_equal 2, translations.length
|
64
|
+
end
|
65
|
+
should "find two Spanish translations" do
|
66
|
+
translations = ContentTranslation.by_locale('es')
|
67
|
+
assert_equal 2, translations.length
|
68
|
+
end
|
69
|
+
should "delete translations" do
|
70
|
+
assert_difference "ContentTranslation.count", -(@content_two.content_translations.count) do
|
71
|
+
@content_two.destroy
|
72
|
+
end
|
37
73
|
end
|
38
74
|
end
|
75
|
+
|
39
76
|
end
|
40
77
|
|
41
|
-
end
|
78
|
+
end
|
@@ -1,3 +1,34 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: users
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# login :string(255)
|
7
|
+
# email :string(255)
|
8
|
+
# first_name :string(255)
|
9
|
+
# last_name :string(255)
|
10
|
+
# crypted_password :string(255)
|
11
|
+
# password_salt :string(255)
|
12
|
+
# persistence_token :string(255) not null
|
13
|
+
# single_access_token :string(255) not null
|
14
|
+
# perishable_token :string(255) not null
|
15
|
+
# login_count :integer default(0), not null
|
16
|
+
# failed_login_count :integer default(0), not null
|
17
|
+
# last_request_at :datetime
|
18
|
+
# current_login_at :datetime
|
19
|
+
# last_login_at :datetime
|
20
|
+
# current_login_ip :string(255)
|
21
|
+
# last_login_ip :string(255)
|
22
|
+
# terms_of_service :boolean not null
|
23
|
+
# time_zone :string(255) default("UTC")
|
24
|
+
# disabled_at :datetime
|
25
|
+
# created_at :datetime
|
26
|
+
# activated_at :datetime
|
27
|
+
# updated_at :datetime
|
28
|
+
# identity_url :string(255)
|
29
|
+
# url_key :string(255)
|
30
|
+
#
|
31
|
+
|
1
32
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
33
|
|
3
34
|
# Used to test muck_friend_user
|
@@ -9,4 +40,4 @@ class UserTest < ActiveSupport::TestCase
|
|
9
40
|
|
10
41
|
|
11
42
|
|
12
|
-
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-contents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-16 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|