We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Fork of courtenay/can_flag
Description: flag content as inappropriate
Clone URL: git://github.com/bumi/can_flag.git
link user to flaggings
courtenay (author)
Mon Mar 17 02:09:24 -0700 2008
commit  972e59c1f738c6b28c5e4ecb21e9cb18655cc47e
tree    29b3ac2ec7c9c0f714881c03efca6952c15faecc
parent  7adc469956202bd4b98d411befd89e7628157b37
...
31
32
33
34
 
35
36
37
38
39
 
 
40
41
42
...
31
32
33
 
34
35
36
37
38
 
39
40
41
42
43
0
@@ -31,12 +31,13 @@ module Caboose
0
           has_many :flags, :foreign_key => "user_id", :order => "id desc"
0
           
0
           # User was responsible for creating this filth
0
- has_many :flagged, :foreign_key => "user_id"
0
+ has_many :flaggings, :foreign_key => "flaggable_user_id", :class_name => "Flag"
0
           
0
           # Associate the flag back here
0
           # Flag.belongs_to :user
0
           # Flag.belongs_to :owner, :foreign_key => flaggable_user_id
0
- ::Flag.class_eval "belongs_to :#{name.underscore}, :foreign_key => :user_id; belongs_to :owner, :foreign_key => :flaggable_user_id, :class_name => '#{name}'"
0
+ ::Flag.class_eval "belongs_to :#{name.underscore}, :foreign_key => :user_id;
0
+ belongs_to :owner, :foreign_key => :flaggable_user_id, :class_name => '#{name}'"
0
         end
0
       end
0
       
...
1
2
 
 
3
4
5
 
6
7
8
9
10
11
 
 
 
 
 
12
13
14
15
 
 
16
17
18
19
20
21
 
 
 
 
 
 
22
23
24
25
...
1
2
3
4
5
 
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
 
20
21
22
23
 
 
 
 
24
25
26
27
28
29
30
31
32
33
0
@@ -1,24 +1,32 @@
0
 require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
0
 
0
+class User<ActiveRecord::Base; end
0
+
0
 class UserAssociationTest < Test::Unit::TestCase
0
-
0
- def test_craetes_user_association_in_flag
0
+ def test_creates_user_association_in_flag
0
     assert_nil Flag.reflect_on_association(:user)
0
     User.class_eval do
0
       can_flag
0
     end
0
     assert_not_nil Flag.reflect_on_association(:user)
0
   end
0
+end
0
+
0
+class User2<ActiveRecord::Base; set_table_name :users; end
0
+
0
+class UserFlagAssociationTest < Test::Unit::TestCase
0
   
0
   def test_creates_flaggable_associations_in_user
0
- assert_nil User.reflect_on_association(:flaggable)
0
- User.class_eval do
0
+ assert_nil User2.reflect_on_association(:flaggable)
0
+ User2.class_eval do
0
       can_flag
0
     end
0
- assert_not_nil User.reflect_on_association(:flagged)
0
- assert_equal :has_many, User.reflect_on_association(:flagged).macro
0
- assert_not_nil User.reflect_on_association(:flags)
0
- assert_equal :has_many, User.reflect_on_association(:flags).macro
0
+ assert_not_nil User2.reflect_on_association(:flaggings)
0
+ assert_equal :has_many, User2.reflect_on_association(:flaggings).macro
0
+ assert_nothing_raised { User2.new.flaggings }
0
+ assert_not_nil User2.reflect_on_association(:flags)
0
+ assert_equal :has_many, User2.reflect_on_association(:flags).macro
0
+ assert_nothing_raised { User2.new.flags }
0
   end
0
   
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.