socialization 0.4.0 → 0.5.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -1
- data/CHANGELOG.md +41 -0
- data/README.md +246 -0
- data/demo/{demo_app/.gitignore → .gitignore} +0 -0
- data/demo/{demo_app/Gemfile → Gemfile} +1 -1
- data/demo/{demo_app/README.rdoc → README.rdoc} +0 -0
- data/demo/{demo_app/Rakefile → Rakefile} +0 -0
- data/demo/{demo_app/app → app}/assets/images/rails.png +0 -0
- data/demo/{demo_app/app → app}/assets/javascripts/application.js +0 -0
- data/demo/{demo_app/app → app}/assets/stylesheets/application.css +0 -0
- data/demo/{demo_app/app → app}/controllers/application_controller.rb +0 -0
- data/demo/{demo_app/app → app}/helpers/application_helper.rb +0 -0
- data/demo/{demo_app/app → app}/mailers/.gitkeep +0 -0
- data/demo/{demo_app/app → app}/models/.gitkeep +0 -0
- data/demo/{demo_app/app → app}/models/celebrity.rb +0 -0
- data/demo/{demo_app/app → app}/models/comment.rb +0 -0
- data/demo/app/models/follow.rb +2 -0
- data/demo/app/models/like.rb +2 -0
- data/demo/app/models/mention.rb +2 -0
- data/demo/{demo_app/app → app}/models/movie.rb +0 -0
- data/demo/{demo_app/app → app}/models/user.rb +0 -0
- data/demo/{demo_app/app → app}/views/layouts/application.html.erb +0 -0
- data/demo/{demo_app/config.ru → config.ru} +0 -0
- data/demo/{demo_app/config → config}/application.rb +0 -0
- data/demo/{demo_app/config → config}/boot.rb +0 -0
- data/demo/{demo_app/config → config}/database.yml +0 -0
- data/demo/{demo_app/config → config}/environment.rb +0 -0
- data/demo/{demo_app/config → config}/environments/development.rb +0 -0
- data/demo/{demo_app/config → config}/environments/production.rb +0 -0
- data/demo/{demo_app/config → config}/environments/test.rb +0 -0
- data/demo/{demo_app/config → config}/initializers/backtrace_silencers.rb +0 -0
- data/demo/{demo_app/config → config}/initializers/inflections.rb +0 -0
- data/demo/{demo_app/config → config}/initializers/mime_types.rb +0 -0
- data/demo/{demo_app/config → config}/initializers/secret_token.rb +0 -0
- data/demo/{demo_app/config → config}/initializers/session_store.rb +1 -1
- data/demo/{demo_app/config → config}/initializers/wrap_parameters.rb +1 -1
- data/demo/{demo_app/config → config}/locales/en.yml +0 -0
- data/demo/{demo_app/config → config}/routes.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120115051222_create_users.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120115051234_create_movies.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120115051255_create_celebrities.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120115054646_create_follows.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120115054647_create_likes.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120221200644_create_mentions.rb +0 -0
- data/demo/{demo_app/db → db}/migrate/20120221202703_create_comments.rb +0 -0
- data/demo/{demo_app/db → db}/schema.rb +0 -1
- data/demo/{demo_app/db → db}/seeds.rb +0 -0
- data/demo/{demo_app/lib → lib}/assets/.gitkeep +0 -0
- data/demo/{demo_app/lib → lib}/tasks/.gitkeep +0 -0
- data/demo/{demo_app/public → public}/404.html +0 -0
- data/demo/{demo_app/public → public}/422.html +0 -0
- data/demo/{demo_app/public → public}/500.html +0 -0
- data/demo/{demo_app/public → public}/favicon.ico +0 -0
- data/demo/{demo_app/public → public}/index.html +0 -0
- data/demo/{demo_app/public → public}/robots.txt +0 -0
- data/demo/{demo_app/script → script}/rails +0 -0
- data/demo/{demo_app/test → test}/fixtures/.gitkeep +0 -0
- data/demo/{demo_app/test → test}/fixtures/celebrities.yml +0 -0
- data/demo/{demo_app/test → test}/fixtures/movies.yml +0 -0
- data/demo/{demo_app/test → test}/fixtures/users.yml +0 -0
- data/demo/{demo_app/test → test}/functional/.gitkeep +0 -0
- data/demo/{demo_app/test → test}/integration/.gitkeep +0 -0
- data/demo/{demo_app/test → test}/performance/browsing_test.rb +0 -0
- data/demo/{demo_app/test → test}/test_helper.rb +0 -0
- data/demo/{demo_app/test → test}/unit/.gitkeep +0 -0
- data/demo/{demo_app/test → test}/unit/celebrity_test.rb +0 -0
- data/demo/{demo_app/test → test}/unit/movie_test.rb +0 -0
- data/demo/{demo_app/test → test}/unit/user_test.rb +0 -0
- data/demo/{demo_app/vendor → vendor}/assets/javascripts/.gitkeep +0 -0
- data/demo/{demo_app/vendor → vendor}/assets/stylesheets/.gitkeep +0 -0
- data/demo/{demo_app/vendor → vendor}/plugins/.gitkeep +0 -0
- data/lib/generators/socialization/socialization_generator.rb +20 -9
- data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_follows.rb +0 -0
- data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_likes.rb +0 -0
- data/{generators/socialization/templates → lib/generators/socialization/templates/active_record}/migration_mentions.rb +0 -0
- data/lib/generators/socialization/templates/active_record/model_follow.rb +2 -0
- data/lib/generators/socialization/templates/active_record/model_like.rb +2 -0
- data/lib/generators/socialization/templates/active_record/model_mention.rb +2 -0
- data/lib/socialization.rb +3 -5
- data/lib/socialization/actors/follower.rb +74 -0
- data/lib/socialization/actors/liker.rb +74 -0
- data/lib/socialization/actors/mentioner.rb +74 -0
- data/lib/socialization/acts_as_helpers.rb +43 -0
- data/lib/socialization/config.rb +45 -0
- data/lib/socialization/helpers/string.rb +17 -0
- data/lib/socialization/stores/active_record/follow_store.rb +143 -0
- data/lib/socialization/stores/active_record/like_store.rb +143 -0
- data/lib/socialization/stores/active_record/mention_store.rb +143 -0
- data/lib/socialization/stores/redis/base.rb +8 -0
- data/lib/socialization/stores/redis/config.rb +11 -0
- data/lib/socialization/stores/redis/follow_store.rb +126 -0
- data/lib/socialization/stores/redis/like_store.rb +126 -0
- data/lib/socialization/stores/redis/mention_store.rb +126 -0
- data/lib/socialization/version.rb +1 -1
- data/lib/socialization/victims/followable.rb +38 -0
- data/lib/socialization/victims/likeable.rb +38 -0
- data/lib/socialization/victims/mentionable.rb +38 -0
- data/socialization.gemspec +3 -3
- data/test/actors/follower_test.rb +74 -0
- data/test/actors/liker_test.rb +74 -0
- data/test/actors/mentioner_test.rb +74 -0
- data/test/stores/active_record/follow_store_test.rb +121 -0
- data/test/stores/active_record/like_store_test.rb +121 -0
- data/test/stores/active_record/mention_store_test.rb +121 -0
- data/test/stores/redis/config_test.rb +30 -0
- data/test/stores/redis/follow_store_test.rb +153 -0
- data/test/stores/redis/like_store_test.rb +153 -0
- data/test/stores/redis/mention_store_test.rb +153 -0
- data/test/string_test.rb +13 -0
- data/test/test_helper.rb +70 -12
- data/test/victims/followable_test.rb +34 -0
- data/test/victims/likeable_test.rb +34 -0
- data/test/victims/mentionable_test.rb +34 -0
- data/test/world_test.rb +80 -69
- metadata +261 -176
- data/README.rdoc +0 -186
- data/demo/demo_app/app/models/follow.rb +0 -3
- data/demo/demo_app/app/models/like.rb +0 -3
- data/demo/demo_app/app/models/mention.rb +0 -3
- data/demo/demo_app/doc/README_FOR_APP +0 -2
- data/gemfiles/activerecord30.gemfile +0 -6
- data/gemfiles/activerecord30.gemfile.lock +0 -23
- data/gemfiles/activerecord31.gemfile +0 -6
- data/gemfiles/activerecord31.gemfile.lock +0 -25
- data/gemfiles/activerecord32.gemfile +0 -6
- data/gemfiles/activerecord32.gemfile.lock +0 -25
- data/generators/socialization/USAGE +0 -1
- data/generators/socialization/socialization_generator.rb +0 -15
- data/generators/socialization/templates/model_follow.rb +0 -3
- data/generators/socialization/templates/model_like.rb +0 -3
- data/generators/socialization/templates/model_mention.rb +0 -3
- data/lib/socialization/follow_store.rb +0 -14
- data/lib/socialization/followable.rb +0 -34
- data/lib/socialization/follower.rb +0 -50
- data/lib/socialization/hello.rb +0 -53
- data/lib/socialization/like_store.rb +0 -14
- data/lib/socialization/likeable.rb +0 -34
- data/lib/socialization/liker.rb +0 -54
- data/lib/socialization/mention_store.rb +0 -14
- data/lib/socialization/mentionable.rb +0 -36
- data/lib/socialization/mentioner.rb +0 -54
- data/test/follow_test.rb +0 -125
- data/test/like_test.rb +0 -125
- data/test/mention_test.rb +0 -116
data/test/mention_test.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__))+'/test_helper'
|
2
|
-
|
3
|
-
class MentionTest < Test::Unit::TestCase
|
4
|
-
context "a Mentioner" do
|
5
|
-
setup do
|
6
|
-
seed
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be mentioner" do
|
10
|
-
assert_equal true, @mentioner1.is_mentioner?
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be able to mention a Mentionable" do
|
14
|
-
assert @mentioner1.mention!(@mentionable1)
|
15
|
-
assert_equal true, @mentioner1.mentions?(@mentionable1)
|
16
|
-
assert_equal false, @mentioner2.mentions?(@mentionable1)
|
17
|
-
end
|
18
|
-
|
19
|
-
should "be able to unmention a Mentionable" do
|
20
|
-
Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
|
21
|
-
assert @mentioner1.unmention!(@mentionable1)
|
22
|
-
assert_equal false, @mentioner1.mentions?(@mentionable1)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "not be able to mention the same thing twice" do
|
26
|
-
assert @mentioner1.mention!(@mentionable1)
|
27
|
-
|
28
|
-
assert_raise ActiveRecord::RecordInvalid do
|
29
|
-
@mentioner1.mention!(@mentionable1)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
should "not be able to unmention something that is not mentionned" do
|
34
|
-
assert_raise ActiveRecord::RecordNotFound do
|
35
|
-
@mentioner1.unmention!(@mentionable1)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
should "be able to mention itself" do
|
40
|
-
@mentioner_and_mentionable.mention!(@mentioner_and_mentionable)
|
41
|
-
end
|
42
|
-
|
43
|
-
should "expose a list of its mentionees" do
|
44
|
-
Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
|
45
|
-
assert @mentioner1.mentionees(ImAMentioner).is_a?(ActiveRecord::Relation)
|
46
|
-
assert_equal [@mentionable1], @mentioner1.mentionees(ImAMentionable).all
|
47
|
-
|
48
|
-
assert_equal @mentioner1.mentionees(ImAMentionable), @mentioner1.mentionees(:im_a_mentionables)
|
49
|
-
assert_equal @mentioner1.mentionees(ImAMentionable), @mentioner1.mentionees("im_a_mentionable")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "a Mentionable" do
|
54
|
-
setup do
|
55
|
-
seed
|
56
|
-
end
|
57
|
-
|
58
|
-
should "be mentionable" do
|
59
|
-
assert_equal true, @mentionable1.is_mentionable?
|
60
|
-
end
|
61
|
-
|
62
|
-
should "be able to determine who mentions it" do
|
63
|
-
Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
|
64
|
-
assert_equal true, @mentionable1.mentioned_by?(@mentioner1)
|
65
|
-
assert_equal false, @mentionable1.mentioned_by?(@mentioner2)
|
66
|
-
end
|
67
|
-
|
68
|
-
should "expose a list of its mentioners" do
|
69
|
-
Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
|
70
|
-
assert @mentionable1.mentioners(ImAMentioner).is_a?(ActiveRecord::Relation)
|
71
|
-
assert_equal [@mentioner1], @mentionable1.mentioners(ImAMentioner).all
|
72
|
-
|
73
|
-
assert_equal @mentionable1.mentioners(ImAMentioner), @mentionable1.mentioners(:im_a_mentioners)
|
74
|
-
assert_equal @mentionable1.mentioners(ImAMentioner), @mentionable1.mentioners("im_a_mentioner")
|
75
|
-
end
|
76
|
-
|
77
|
-
should "expose mentionings" do
|
78
|
-
Mention.create :mentioner => @mentioner1, :mentionable => @mentionable1
|
79
|
-
mentionings = @mentionable1.mentionings
|
80
|
-
assert_equal 1, mentionings.size
|
81
|
-
assert mentionings.first.is_a?(Mention)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "Deleting a mentioner" do
|
86
|
-
setup do
|
87
|
-
seed
|
88
|
-
@mentioner1.mention!(@mentionable1)
|
89
|
-
end
|
90
|
-
|
91
|
-
should "delete its Mention records" do
|
92
|
-
@mentioner1.destroy
|
93
|
-
assert_equal false, @mentionable1.mentioned_by?(@mentioner1)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "Deleting a Mentionable" do
|
98
|
-
setup do
|
99
|
-
seed
|
100
|
-
@mentioner1.mention!(@mentionable1)
|
101
|
-
end
|
102
|
-
|
103
|
-
should "delete its Mention records" do
|
104
|
-
@mentionable1.destroy
|
105
|
-
assert_equal false, @mentioner1.mentions?(@mentionable1)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def seed
|
110
|
-
@mentioner1 = ImAMentioner.create
|
111
|
-
@mentioner2 = ImAMentioner.create
|
112
|
-
@mentionable1 = ImAMentionable.create
|
113
|
-
@mentionable2 = ImAMentionable.create
|
114
|
-
@mentioner_and_mentionable = ImAMentionerAndMentionable.create
|
115
|
-
end
|
116
|
-
end
|