tenacity 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/EXTEND.rdoc +9 -13
- data/Rakefile +6 -0
- data/history.txt +17 -0
- data/lib/tenacity.rb +13 -9
- data/lib/tenacity/associate_proxy.rb +56 -0
- data/lib/tenacity/associates_proxy.rb +5 -3
- data/lib/tenacity/association.rb +81 -9
- data/lib/tenacity/associations/belongs_to.rb +28 -16
- data/lib/tenacity/associations/has_many.rb +113 -53
- data/lib/tenacity/associations/has_one.rb +33 -14
- data/lib/tenacity/class_methods.rb +117 -9
- data/lib/tenacity/errors.rb +9 -0
- data/lib/tenacity/instance_methods.rb +40 -3
- data/lib/tenacity/orm_ext/activerecord.rb +114 -95
- data/lib/tenacity/orm_ext/couchrest.rb +132 -113
- data/lib/tenacity/orm_ext/datamapper.rb +138 -112
- data/lib/tenacity/orm_ext/helpers.rb +36 -0
- data/lib/tenacity/orm_ext/mongo_mapper.rb +102 -84
- data/lib/tenacity/orm_ext/mongoid.rb +106 -87
- data/lib/tenacity/orm_ext/sequel.rb +137 -110
- data/lib/tenacity/version.rb +1 -1
- data/tenacity.gemspec +2 -1
- data/test/association_features/belongs_to_test.rb +46 -1
- data/test/association_features/has_many_test.rb +187 -2
- data/test/association_features/has_one_test.rb +57 -2
- data/test/associations/belongs_to_test.rb +41 -7
- data/test/associations/has_many_test.rb +59 -10
- data/test/associations/has_one_test.rb +57 -2
- data/test/fixtures/active_record_car.rb +5 -4
- data/test/fixtures/active_record_climate_control_unit.rb +1 -0
- data/test/fixtures/active_record_engine.rb +1 -0
- data/test/fixtures/active_record_has_many_target.rb +7 -0
- data/test/fixtures/active_record_has_one_target.rb +7 -0
- data/test/fixtures/active_record_object.rb +19 -0
- data/test/fixtures/couch_rest_has_many_target.rb +7 -0
- data/test/fixtures/couch_rest_has_one_target.rb +7 -0
- data/test/fixtures/couch_rest_object.rb +14 -0
- data/test/fixtures/data_mapper_has_many_target.rb +23 -3
- data/test/fixtures/data_mapper_has_one_target.rb +23 -3
- data/test/fixtures/data_mapper_object.rb +14 -0
- data/test/fixtures/mongo_mapper_air_filter.rb +6 -0
- data/test/fixtures/mongo_mapper_alternator.rb +7 -0
- data/test/fixtures/mongo_mapper_autosave_false_has_many_target.rb +8 -0
- data/test/fixtures/mongo_mapper_autosave_false_has_one_target.rb +8 -0
- data/test/fixtures/mongo_mapper_autosave_true_has_many_target.rb +8 -0
- data/test/fixtures/mongo_mapper_autosave_true_has_one_target.rb +8 -0
- data/test/fixtures/mongo_mapper_circuit_board.rb +6 -0
- data/test/fixtures/mongo_mapper_dashboard.rb +5 -2
- data/test/fixtures/mongo_mapper_has_many_target.rb +7 -0
- data/test/fixtures/mongo_mapper_has_one_target.rb +7 -0
- data/test/fixtures/mongo_mapper_object.rb +14 -0
- data/test/fixtures/mongo_mapper_wheel.rb +2 -0
- data/test/fixtures/mongo_mapper_windows.rb +6 -0
- data/test/fixtures/mongoid_has_many_target.rb +7 -0
- data/test/fixtures/mongoid_has_one_target.rb +7 -0
- data/test/fixtures/mongoid_object.rb +14 -0
- data/test/fixtures/sequel_has_many_target.rb +7 -0
- data/test/fixtures/sequel_has_one_target.rb +7 -0
- data/test/fixtures/sequel_object.rb +14 -0
- data/test/helpers/active_record_test_helper.rb +87 -8
- data/test/helpers/couch_rest_test_helper.rb +7 -0
- data/test/helpers/data_mapper_test_helper.rb +41 -3
- data/test/helpers/sequel_test_helper.rb +65 -9
- data/test/orm_ext/activerecord_test.rb +1 -1
- data/test/orm_ext/datamapper_test.rb +33 -24
- data/test/orm_ext/mongo_mapper_test.rb +6 -6
- data/test/orm_ext/mongoid_test.rb +6 -6
- data/test/orm_ext/sequel_test.rb +1 -1
- data/test/test_helper.rb +18 -9
- metadata +119 -55
@@ -10,7 +10,7 @@ migration 1, :create_join_tables do
|
|
10
10
|
up do
|
11
11
|
create_table :active_record_has_many_targets_data_mapper_objects do
|
12
12
|
column :data_mapper_object_id, Integer
|
13
|
-
column :active_record_has_many_target_id,
|
13
|
+
column :active_record_has_many_target_id, Integer
|
14
14
|
end
|
15
15
|
|
16
16
|
create_table :data_mapper_objects_mongo_mapper_has_many_targets do
|
@@ -25,7 +25,7 @@ migration 1, :create_join_tables do
|
|
25
25
|
|
26
26
|
create_table :data_mapper_has_many_targets_data_mapper_objects do
|
27
27
|
column :data_mapper_object_id, Integer
|
28
|
-
column :data_mapper_has_many_target_id,
|
28
|
+
column :data_mapper_has_many_target_id, Integer
|
29
29
|
end
|
30
30
|
|
31
31
|
create_table :data_mapper_objects_mongoid_has_many_targets do
|
@@ -35,10 +35,48 @@ migration 1, :create_join_tables do
|
|
35
35
|
|
36
36
|
create_table :data_mapper_objects_sequel_has_many_targets do
|
37
37
|
column :data_mapper_object_id, Integer
|
38
|
-
column :sequel_has_many_target_id,
|
38
|
+
column :sequel_has_many_target_id, Integer
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table :active_record_has_many_target_testables_data_mapper_objects do
|
42
|
+
column :data_mapper_object_id, Integer
|
43
|
+
column :active_record_has_many_target_testable_id, Integer
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :data_mapper_objects_mongo_mapper_has_many_target_testables do
|
47
|
+
column :data_mapper_object_id, Integer
|
48
|
+
column :mongo_mapper_has_many_target_testable_id, String
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table :couch_rest_has_many_target_testables_data_mapper_objects do
|
52
|
+
column :data_mapper_object_id, Integer
|
53
|
+
column :couch_rest_has_many_target_testable_id, String
|
54
|
+
end
|
55
|
+
|
56
|
+
create_table :data_mapper_has_many_target_testables_data_mapper_objects do
|
57
|
+
column :data_mapper_object_id, Integer
|
58
|
+
column :data_mapper_has_many_target_testable_id, Integer
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table :data_mapper_objects_mongoid_has_many_target_testables do
|
62
|
+
column :data_mapper_object_id, Integer
|
63
|
+
column :mongoid_has_many_target_testable_id, String
|
64
|
+
end
|
65
|
+
|
66
|
+
create_table :data_mapper_objects_sequel_has_many_target_testables do
|
67
|
+
column :data_mapper_object_id, Integer
|
68
|
+
column :sequel_has_many_target_testable_id, Integer
|
39
69
|
end
|
40
70
|
end
|
41
71
|
end
|
42
72
|
|
43
73
|
migrate_up!
|
44
74
|
|
75
|
+
def migrate_data_mapper_tables
|
76
|
+
DataMapperHasManyTarget
|
77
|
+
DataMapperHasOneTarget
|
78
|
+
DataMapperObject
|
79
|
+
|
80
|
+
DataMapper.auto_migrate!
|
81
|
+
end
|
82
|
+
|
@@ -9,28 +9,54 @@ end
|
|
9
9
|
DB.create_table :sequel_has_one_targets do
|
10
10
|
primary_key :id
|
11
11
|
|
12
|
-
|
12
|
+
Integer :active_record_object_id
|
13
13
|
String :couch_rest_object_id
|
14
|
-
|
14
|
+
Integer :data_mapper_object_id
|
15
15
|
String :mongo_mapper_object_id
|
16
16
|
String :mongoid_object_id
|
17
|
-
|
17
|
+
Integer :sequel_object_id
|
18
|
+
|
19
|
+
String :active_record_has_one_target_testable_id
|
20
|
+
String :active_record_has_one_target_testable_type
|
21
|
+
String :couch_rest_has_one_target_testable_id
|
22
|
+
String :couch_rest_has_one_target_testable_type
|
23
|
+
String :data_mapper_has_one_target_testable_id
|
24
|
+
String :data_mapper_has_one_target_testable_type
|
25
|
+
String :mongo_mapper_has_one_target_testable_id
|
26
|
+
String :mongo_mapper_has_one_target_testable_type
|
27
|
+
String :mongoid_has_one_target_testable_id
|
28
|
+
String :mongoid_has_one_target_testable_type
|
29
|
+
String :sequel_has_one_target_testable_id
|
30
|
+
String :sequel_has_one_target_testable_type
|
18
31
|
end
|
19
32
|
|
20
33
|
DB.create_table :sequel_has_many_targets do
|
21
34
|
primary_key :id
|
22
35
|
|
23
|
-
|
36
|
+
Integer :active_record_object_id
|
24
37
|
String :couch_rest_object_id
|
25
|
-
|
38
|
+
Integer :data_mapper_object_id
|
26
39
|
String :mongo_mapper_object_id
|
27
40
|
String :mongoid_object_id
|
28
|
-
|
41
|
+
Integer :sequel_object_id
|
42
|
+
|
43
|
+
String :active_record_has_many_target_testable_id
|
44
|
+
String :active_record_has_many_target_testable_type
|
45
|
+
String :couch_rest_has_many_target_testable_id
|
46
|
+
String :couch_rest_has_many_target_testable_type
|
47
|
+
String :data_mapper_has_many_target_testable_id
|
48
|
+
String :data_mapper_has_many_target_testable_type
|
49
|
+
String :mongo_mapper_has_many_target_testable_id
|
50
|
+
String :mongo_mapper_has_many_target_testable_type
|
51
|
+
String :mongoid_has_many_target_testable_id
|
52
|
+
String :mongoid_has_many_target_testable_type
|
53
|
+
String :sequel_has_many_target_testable_id
|
54
|
+
String :sequel_has_many_target_testable_type
|
29
55
|
end
|
30
56
|
|
31
57
|
DB.create_table :active_record_has_many_targets_sequel_objects do
|
32
58
|
Integer :sequel_object_id
|
33
|
-
|
59
|
+
Integer :active_record_has_many_target_id
|
34
60
|
end
|
35
61
|
|
36
62
|
DB.create_table :mongo_mapper_has_many_targets_sequel_objects do
|
@@ -45,7 +71,7 @@ end
|
|
45
71
|
|
46
72
|
DB.create_table :data_mapper_has_many_targets_sequel_objects do
|
47
73
|
Integer :sequel_object_id
|
48
|
-
|
74
|
+
Integer :data_mapper_has_many_target_id
|
49
75
|
end
|
50
76
|
|
51
77
|
DB.create_table :mongoid_has_many_targets_sequel_objects do
|
@@ -55,6 +81,36 @@ end
|
|
55
81
|
|
56
82
|
DB.create_table :sequel_has_many_targets_sequel_objects do
|
57
83
|
Integer :sequel_object_id
|
58
|
-
|
84
|
+
Integer :sequel_has_many_target_id
|
85
|
+
end
|
86
|
+
|
87
|
+
DB.create_table :active_record_has_many_target_testables_sequel_objects do
|
88
|
+
Integer :sequel_object_id
|
89
|
+
Integer :active_record_has_many_target_testable_id
|
90
|
+
end
|
91
|
+
|
92
|
+
DB.create_table :mongo_mapper_has_many_target_testables_sequel_objects do
|
93
|
+
Integer :sequel_object_id
|
94
|
+
String :mongo_mapper_has_many_target_testable_id
|
95
|
+
end
|
96
|
+
|
97
|
+
DB.create_table :couch_rest_has_many_target_testables_sequel_objects do
|
98
|
+
Integer :sequel_object_id
|
99
|
+
String :couch_rest_has_many_target_testable_id
|
100
|
+
end
|
101
|
+
|
102
|
+
DB.create_table :data_mapper_has_many_target_testables_sequel_objects do
|
103
|
+
Integer :sequel_object_id
|
104
|
+
Integer :data_mapper_has_many_target_testable_id
|
105
|
+
end
|
106
|
+
|
107
|
+
DB.create_table :mongoid_has_many_target_testables_sequel_objects do
|
108
|
+
Integer :sequel_object_id
|
109
|
+
String :mongoid_has_many_target_testable_id
|
110
|
+
end
|
111
|
+
|
112
|
+
DB.create_table :sequel_has_many_target_testables_sequel_objects do
|
113
|
+
Integer :sequel_object_id
|
114
|
+
Integer :sequel_has_many_target_testable_id
|
59
115
|
end
|
60
116
|
|
@@ -52,7 +52,7 @@ class ActiveRecordTest < Test::Unit::TestCase
|
|
52
52
|
object = ActiveRecordHasOneTarget.create
|
53
53
|
object.mongo_mapper_object_id = 'abc123'
|
54
54
|
object.reload
|
55
|
-
|
55
|
+
assert_nil object.mongo_mapper_object_id
|
56
56
|
end
|
57
57
|
|
58
58
|
should "be able to clear the associates of a given object" do
|
@@ -50,31 +50,11 @@ class DataMapperTest < Test::Unit::TestCase
|
|
50
50
|
|
51
51
|
should "be able to reload an object from the database" do
|
52
52
|
object = DataMapperHasOneTarget.create
|
53
|
-
|
54
|
-
|
53
|
+
other_object = MongoMapperObject.create
|
54
|
+
object.mongo_mapper_object_id = other_object.id
|
55
|
+
assert_equal other_object.id.to_s, object.mongo_mapper_object_id
|
55
56
|
object.reload
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
should "be able to clear the associates of a given object" do
|
60
|
-
object = DataMapperObject.create
|
61
|
-
object._t_associate_many(association, ['abc123', 'def456', 'ghi789'])
|
62
|
-
object.save
|
63
|
-
object._t_clear_associates(association)
|
64
|
-
assert_set_equal [], object._t_get_associate_ids(association)
|
65
|
-
end
|
66
|
-
|
67
|
-
should "be able to associate many objects with the given object" do
|
68
|
-
object = DataMapperObject.create
|
69
|
-
object._t_associate_many(association, ['abc123', 'def456', 'ghi789'])
|
70
|
-
rows = DataMapperObject.repository.adapter.select("select mongo_mapper_has_many_target_id from data_mapper_objects_mongo_mapper_has_many_targets where data_mapper_object_id = #{object.id}")
|
71
|
-
assert_set_equal ['abc123', 'def456', 'ghi789'], rows
|
72
|
-
end
|
73
|
-
|
74
|
-
should "be able to get the ids of the objects associated with the given object" do
|
75
|
-
object = DataMapperObject.create
|
76
|
-
object._t_associate_many(association, ['abc123', 'def456', 'ghi789'])
|
77
|
-
assert_set_equal ['abc123', 'def456', 'ghi789'], object._t_get_associate_ids(association)
|
57
|
+
assert_nil object.mongo_mapper_object_id
|
78
58
|
end
|
79
59
|
|
80
60
|
should "return an empty array if there are no objects associated with the given object ids" do
|
@@ -101,6 +81,35 @@ class DataMapperTest < Test::Unit::TestCase
|
|
101
81
|
DataMapperObject._t_delete([object_1.id, object_2.id, object_3.id], false)
|
102
82
|
assert_equal old_count - 3, DataMapperObject.count
|
103
83
|
end
|
84
|
+
|
85
|
+
context "that works with t_has_many associations" do
|
86
|
+
setup do
|
87
|
+
@has_many_target_1 = MongoMapperHasManyTarget.create
|
88
|
+
@has_many_target_2 = MongoMapperHasManyTarget.create
|
89
|
+
@has_many_target_3 = MongoMapperHasManyTarget.create
|
90
|
+
end
|
91
|
+
|
92
|
+
should "be able to clear the associates of a given object" do
|
93
|
+
object = DataMapperObject.create
|
94
|
+
object._t_associate_many(association, [@has_many_target_1.id, @has_many_target_2.id, @has_many_target_3.id])
|
95
|
+
object.save
|
96
|
+
object._t_clear_associates(association)
|
97
|
+
assert_set_equal [], object._t_get_associate_ids(association)
|
98
|
+
end
|
99
|
+
|
100
|
+
should "be able to associate many objects with the given object" do
|
101
|
+
object = DataMapperObject.create
|
102
|
+
object._t_associate_many(association, [@has_many_target_1.id, @has_many_target_2.id, @has_many_target_3.id])
|
103
|
+
rows = DataMapperObject.repository.adapter.select("select mongo_mapper_has_many_target_id from data_mapper_objects_mongo_mapper_has_many_targets where data_mapper_object_id = #{object.id}")
|
104
|
+
assert_set_equal [@has_many_target_1.id.to_s, @has_many_target_2.id.to_s, @has_many_target_3.id.to_s], rows
|
105
|
+
end
|
106
|
+
|
107
|
+
should "be able to get the ids of the objects associated with the given object" do
|
108
|
+
object = DataMapperObject.create
|
109
|
+
object._t_associate_many(association, [@has_many_target_1.id, @has_many_target_2.id, @has_many_target_3.id])
|
110
|
+
assert_set_equal [@has_many_target_1.id.to_s, @has_many_target_2.id.to_s, @has_many_target_3.id.to_s], object._t_get_associate_ids(association)
|
111
|
+
end
|
112
|
+
end
|
104
113
|
end
|
105
114
|
|
106
115
|
private
|
@@ -28,7 +28,7 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
28
28
|
|
29
29
|
should "be able to find the first associate of an object" do
|
30
30
|
object = MongoMapperObject.create
|
31
|
-
target = MongoMapperHasOneTarget.create(:mongo_mapper_object_id => object.id
|
31
|
+
target = MongoMapperHasOneTarget.create(:mongo_mapper_object_id => object.id)
|
32
32
|
assert_equal target, MongoMapperHasOneTarget._t_find_first_by_associate(:mongo_mapper_object_id, object.id)
|
33
33
|
end
|
34
34
|
|
@@ -49,10 +49,10 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
49
49
|
|
50
50
|
should "be able to reload an object from the database" do
|
51
51
|
target = MongoMapperHasOneTarget.create
|
52
|
-
target.mongo_mapper_object_id = 101
|
52
|
+
target.mongo_mapper_object_id = '101'
|
53
53
|
assert_equal '101', target.mongo_mapper_object_id
|
54
54
|
target.reload
|
55
|
-
|
55
|
+
assert_nil target.mongo_mapper_object_id
|
56
56
|
end
|
57
57
|
|
58
58
|
should "be able to associate many objects with the given object" do
|
@@ -61,7 +61,7 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
61
61
|
target_3 = MongoMapperHasManyTarget.create
|
62
62
|
object = MongoMapperObject.create
|
63
63
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
64
|
-
assert_set_equal [target_1.id
|
64
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object.t_mongo_mapper_has_many_target_ids
|
65
65
|
end
|
66
66
|
|
67
67
|
should "be able to get the ids of the objects associated with the given object" do
|
@@ -71,7 +71,7 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
71
71
|
object = MongoMapperObject.create
|
72
72
|
|
73
73
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
74
|
-
assert_set_equal [target_1.id
|
74
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object._t_get_associate_ids(association)
|
75
75
|
end
|
76
76
|
|
77
77
|
should "return an empty array when trying to fetch associate ids for an object with no associates" do
|
@@ -86,7 +86,7 @@ class MongoMapperTest < Test::Unit::TestCase
|
|
86
86
|
object = MongoMapperObject.create
|
87
87
|
|
88
88
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
89
|
-
assert_set_equal [target_1.id
|
89
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object._t_get_associate_ids(association)
|
90
90
|
object._t_clear_associates(association)
|
91
91
|
assert_equal [], object._t_get_associate_ids(association)
|
92
92
|
end
|
@@ -29,7 +29,7 @@ require_mongoid do
|
|
29
29
|
|
30
30
|
should "be able to find the first associate of an object" do
|
31
31
|
object = MongoidObject.create
|
32
|
-
target = MongoidHasOneTarget.create(:mongoid_object_id => object.id
|
32
|
+
target = MongoidHasOneTarget.create(:mongoid_object_id => object.id)
|
33
33
|
assert_equal target, MongoidHasOneTarget._t_find_first_by_associate(:mongoid_object_id, object.id)
|
34
34
|
end
|
35
35
|
|
@@ -50,10 +50,10 @@ require_mongoid do
|
|
50
50
|
|
51
51
|
should "be able to reload an object from the database" do
|
52
52
|
target = MongoidHasOneTarget.create
|
53
|
-
target.mongoid_object_id = 101
|
53
|
+
target.mongoid_object_id = '101'
|
54
54
|
assert_equal '101', target.mongoid_object_id
|
55
55
|
target.reload
|
56
|
-
|
56
|
+
assert_nil target.mongoid_object_id
|
57
57
|
end
|
58
58
|
|
59
59
|
should "be able to associate many objects with the given object" do
|
@@ -62,7 +62,7 @@ require_mongoid do
|
|
62
62
|
target_3 = MongoidHasManyTarget.create
|
63
63
|
object = MongoidObject.create
|
64
64
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
65
|
-
assert_set_equal [target_1.id
|
65
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object.t_mongoid_has_many_target_ids
|
66
66
|
end
|
67
67
|
|
68
68
|
should "be able to get the ids of the objects associated with the given object" do
|
@@ -72,7 +72,7 @@ require_mongoid do
|
|
72
72
|
object = MongoidObject.create
|
73
73
|
|
74
74
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
75
|
-
assert_set_equal [target_1.id
|
75
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object._t_get_associate_ids(association)
|
76
76
|
end
|
77
77
|
|
78
78
|
should "return an empty array when trying to fetch associate ids for an object with no associates" do
|
@@ -87,7 +87,7 @@ require_mongoid do
|
|
87
87
|
object = MongoidObject.create
|
88
88
|
|
89
89
|
object._t_associate_many(association, [target_1.id, target_2.id, target_3.id])
|
90
|
-
assert_set_equal [target_1.id
|
90
|
+
assert_set_equal [target_1.id, target_2.id, target_3.id], object._t_get_associate_ids(association)
|
91
91
|
object._t_clear_associates(association)
|
92
92
|
assert_equal [], object._t_get_associate_ids(association)
|
93
93
|
end
|
data/test/orm_ext/sequel_test.rb
CHANGED
@@ -53,7 +53,7 @@ class SequelTest < Test::Unit::TestCase
|
|
53
53
|
object.mongo_mapper_object_id = 'abc123'
|
54
54
|
assert_equal 'abc123', object.mongo_mapper_object_id
|
55
55
|
object.reload
|
56
|
-
|
56
|
+
assert_nil object.mongo_mapper_object_id
|
57
57
|
end
|
58
58
|
|
59
59
|
should "be able to clear the associates of a given object" do
|
data/test/test_helper.rb
CHANGED
@@ -10,6 +10,11 @@ end
|
|
10
10
|
|
11
11
|
require 'test/unit'
|
12
12
|
require 'shoulda'
|
13
|
+
require 'mocha'
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
require 'tenacity'
|
13
18
|
|
14
19
|
require File.join(File.dirname(__FILE__), 'helpers', 'active_record_test_helper')
|
15
20
|
require File.join(File.dirname(__FILE__), 'helpers', 'couch_rest_test_helper')
|
@@ -18,13 +23,9 @@ require File.join(File.dirname(__FILE__), 'helpers', 'mongo_mapper_test_helper')
|
|
18
23
|
require File.join(File.dirname(__FILE__), 'helpers', 'mongoid_test_helper')
|
19
24
|
require File.join(File.dirname(__FILE__), 'helpers', 'sequel_test_helper')
|
20
25
|
|
21
|
-
|
22
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
23
|
-
require 'tenacity'
|
24
|
-
|
25
|
-
Dir[File.join(File.dirname(__FILE__), 'fixtures', '*.rb')].each { |file| require file }
|
26
|
+
Dir[File.join(File.dirname(__FILE__), 'fixtures', '*.rb')].each { |file| autoload(file[file.rindex('/') + 1..-4].camelcase, file) }
|
26
27
|
|
27
|
-
|
28
|
+
migrate_data_mapper_tables
|
28
29
|
|
29
30
|
def setup_fixtures
|
30
31
|
Dir.glob(File.join(File.dirname(__FILE__), 'fixtures', '*.rb')).each do |filename|
|
@@ -76,9 +77,13 @@ def setup_fixtures_for(source, target)
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def orm_extensions
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
if ENV['QUICK'] == 'true'
|
81
|
+
extensions = [:active_record, :mongo_mapper]
|
82
|
+
else
|
83
|
+
extensions = [:active_record, :couch_rest, :data_mapper, :mongo_mapper, :sequel]
|
84
|
+
require_mongoid { extensions << :mongoid }
|
85
|
+
extensions
|
86
|
+
end
|
82
87
|
end
|
83
88
|
|
84
89
|
def for_each_orm_extension_combination
|
@@ -124,3 +129,7 @@ def assert_set_equal(expecteds, actuals, message = nil)
|
|
124
129
|
assert_equal expecteds && Set.new(expecteds), actuals && Set.new(actuals), message
|
125
130
|
end
|
126
131
|
|
132
|
+
def serialize_id(object)
|
133
|
+
object.class._t_serialize(object.id)
|
134
|
+
end
|
135
|
+
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tenacity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 4
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- John Wood
|
@@ -14,234 +15,282 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-04-04 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
22
22
|
name: activesupport
|
23
|
+
prerelease: false
|
23
24
|
type: :runtime
|
24
|
-
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 5
|
28
31
|
segments:
|
29
32
|
- 2
|
30
33
|
- 3
|
31
34
|
version: "2.3"
|
32
|
-
|
35
|
+
version_requirements: *id001
|
33
36
|
- !ruby/object:Gem::Dependency
|
34
|
-
prerelease: false
|
35
37
|
name: bundler
|
38
|
+
prerelease: false
|
36
39
|
type: :development
|
37
|
-
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ~>
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
41
46
|
segments:
|
42
47
|
- 1
|
43
48
|
- 0
|
44
49
|
- 0
|
45
50
|
version: 1.0.0
|
46
|
-
|
51
|
+
version_requirements: *id002
|
47
52
|
- !ruby/object:Gem::Dependency
|
48
|
-
prerelease: false
|
49
53
|
name: rake
|
54
|
+
prerelease: false
|
50
55
|
type: :development
|
51
|
-
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
52
58
|
requirements:
|
53
59
|
- - ~>
|
54
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 49
|
55
62
|
segments:
|
56
63
|
- 0
|
57
64
|
- 8
|
58
65
|
- 7
|
59
66
|
version: 0.8.7
|
60
|
-
|
67
|
+
version_requirements: *id003
|
61
68
|
- !ruby/object:Gem::Dependency
|
62
|
-
prerelease: false
|
63
69
|
name: rcov
|
70
|
+
prerelease: false
|
64
71
|
type: :development
|
65
|
-
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ~>
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 41
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
- 9
|
72
81
|
- 9
|
73
82
|
version: 0.9.9
|
74
|
-
|
83
|
+
version_requirements: *id004
|
75
84
|
- !ruby/object:Gem::Dependency
|
76
|
-
prerelease: false
|
77
85
|
name: shoulda
|
86
|
+
prerelease: false
|
78
87
|
type: :development
|
79
|
-
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
80
90
|
requirements:
|
81
91
|
- - ~>
|
82
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 37
|
83
94
|
segments:
|
84
95
|
- 2
|
85
96
|
- 11
|
86
97
|
- 3
|
87
98
|
version: 2.11.3
|
88
|
-
|
99
|
+
version_requirements: *id005
|
89
100
|
- !ruby/object:Gem::Dependency
|
101
|
+
name: mocha
|
90
102
|
prerelease: false
|
103
|
+
type: :development
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 47
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
- 9
|
113
|
+
- 10
|
114
|
+
version: 0.9.10
|
115
|
+
version_requirements: *id006
|
116
|
+
- !ruby/object:Gem::Dependency
|
91
117
|
name: yard
|
118
|
+
prerelease: false
|
92
119
|
type: :development
|
93
|
-
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
94
122
|
requirements:
|
95
123
|
- - ~>
|
96
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 15
|
97
126
|
segments:
|
98
127
|
- 0
|
99
128
|
- 6
|
100
129
|
- 4
|
101
130
|
version: 0.6.4
|
102
|
-
|
131
|
+
version_requirements: *id007
|
103
132
|
- !ruby/object:Gem::Dependency
|
104
|
-
prerelease: false
|
105
133
|
name: sqlite3-ruby
|
134
|
+
prerelease: false
|
106
135
|
type: :development
|
107
|
-
|
136
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
108
138
|
requirements:
|
109
139
|
- - ~>
|
110
140
|
- !ruby/object:Gem::Version
|
141
|
+
hash: 25
|
111
142
|
segments:
|
112
143
|
- 1
|
113
144
|
- 3
|
114
145
|
- 1
|
115
146
|
version: 1.3.1
|
116
|
-
|
147
|
+
version_requirements: *id008
|
117
148
|
- !ruby/object:Gem::Dependency
|
118
|
-
prerelease: false
|
119
149
|
name: activerecord
|
150
|
+
prerelease: false
|
120
151
|
type: :development
|
121
|
-
|
152
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
122
154
|
requirements:
|
123
155
|
- - ~>
|
124
156
|
- !ruby/object:Gem::Version
|
157
|
+
hash: 7
|
125
158
|
segments:
|
126
159
|
- 3
|
127
160
|
- 0
|
128
161
|
- 0
|
129
162
|
version: 3.0.0
|
130
|
-
|
163
|
+
version_requirements: *id009
|
131
164
|
- !ruby/object:Gem::Dependency
|
132
|
-
prerelease: false
|
133
165
|
name: datamapper
|
166
|
+
prerelease: false
|
134
167
|
type: :development
|
135
|
-
|
168
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
136
170
|
requirements:
|
137
171
|
- - ~>
|
138
172
|
- !ruby/object:Gem::Version
|
173
|
+
hash: 19
|
139
174
|
segments:
|
140
175
|
- 1
|
141
176
|
- 0
|
142
177
|
- 2
|
143
178
|
version: 1.0.2
|
144
|
-
|
179
|
+
version_requirements: *id010
|
145
180
|
- !ruby/object:Gem::Dependency
|
146
|
-
prerelease: false
|
147
181
|
name: dm-sqlite-adapter
|
182
|
+
prerelease: false
|
148
183
|
type: :development
|
149
|
-
|
184
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
150
186
|
requirements:
|
151
187
|
- - ~>
|
152
188
|
- !ruby/object:Gem::Version
|
189
|
+
hash: 19
|
153
190
|
segments:
|
154
191
|
- 1
|
155
192
|
- 0
|
156
193
|
- 2
|
157
194
|
version: 1.0.2
|
158
|
-
|
195
|
+
version_requirements: *id011
|
159
196
|
- !ruby/object:Gem::Dependency
|
160
|
-
prerelease: false
|
161
197
|
name: sequel
|
198
|
+
prerelease: false
|
162
199
|
type: :development
|
163
|
-
|
200
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
164
202
|
requirements:
|
165
203
|
- - ~>
|
166
204
|
- !ruby/object:Gem::Version
|
205
|
+
hash: 75
|
167
206
|
segments:
|
168
207
|
- 3
|
169
208
|
- 19
|
170
209
|
- 0
|
171
210
|
version: 3.19.0
|
172
|
-
|
211
|
+
version_requirements: *id012
|
173
212
|
- !ruby/object:Gem::Dependency
|
174
|
-
prerelease: false
|
175
213
|
name: mongo_mapper
|
214
|
+
prerelease: false
|
176
215
|
type: :development
|
177
|
-
|
216
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
178
218
|
requirements:
|
179
219
|
- - ~>
|
180
220
|
- !ruby/object:Gem::Version
|
221
|
+
hash: 51
|
181
222
|
segments:
|
182
223
|
- 0
|
183
224
|
- 8
|
184
225
|
- 6
|
185
226
|
version: 0.8.6
|
186
|
-
|
227
|
+
version_requirements: *id013
|
187
228
|
- !ruby/object:Gem::Dependency
|
188
|
-
prerelease: false
|
189
229
|
name: bson_ext
|
230
|
+
prerelease: false
|
190
231
|
type: :development
|
191
|
-
|
232
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
192
234
|
requirements:
|
193
235
|
- - ~>
|
194
236
|
- !ruby/object:Gem::Version
|
237
|
+
hash: 23
|
195
238
|
segments:
|
196
239
|
- 1
|
197
|
-
-
|
198
|
-
-
|
199
|
-
version: 1.
|
200
|
-
|
240
|
+
- 2
|
241
|
+
- 4
|
242
|
+
version: 1.2.4
|
243
|
+
version_requirements: *id014
|
201
244
|
- !ruby/object:Gem::Dependency
|
202
|
-
prerelease: false
|
203
245
|
name: mongoid
|
246
|
+
prerelease: false
|
204
247
|
type: :development
|
205
|
-
|
248
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
206
250
|
requirements:
|
207
251
|
- - ~>
|
208
252
|
- !ruby/object:Gem::Version
|
253
|
+
hash: 31098209
|
209
254
|
segments:
|
210
255
|
- 2
|
211
256
|
- 0
|
212
257
|
- 0
|
213
258
|
- beta
|
214
259
|
version: 2.0.0.beta
|
215
|
-
|
260
|
+
version_requirements: *id015
|
216
261
|
- !ruby/object:Gem::Dependency
|
217
|
-
prerelease: false
|
218
262
|
name: couchrest
|
263
|
+
prerelease: false
|
219
264
|
type: :development
|
220
|
-
|
265
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
266
|
+
none: false
|
221
267
|
requirements:
|
222
268
|
- - ~>
|
223
269
|
- !ruby/object:Gem::Version
|
270
|
+
hash: 23
|
224
271
|
segments:
|
225
272
|
- 1
|
226
273
|
- 0
|
227
274
|
- 0
|
228
275
|
version: 1.0.0
|
229
|
-
|
276
|
+
version_requirements: *id016
|
230
277
|
- !ruby/object:Gem::Dependency
|
231
|
-
prerelease: false
|
232
278
|
name: couchrest_model
|
279
|
+
prerelease: false
|
233
280
|
type: :development
|
234
|
-
|
281
|
+
requirement: &id017 !ruby/object:Gem::Requirement
|
282
|
+
none: false
|
235
283
|
requirements:
|
236
284
|
- - ~>
|
237
285
|
- !ruby/object:Gem::Version
|
286
|
+
hash: 31098193
|
238
287
|
segments:
|
239
288
|
- 1
|
240
289
|
- 0
|
241
290
|
- 0
|
242
291
|
- beta
|
243
292
|
version: 1.0.0.beta
|
244
|
-
|
293
|
+
version_requirements: *id017
|
245
294
|
description: Tenacity provides a database client independent way of specifying simple relationships between models backed by different databases.
|
246
295
|
email:
|
247
296
|
- john@johnpwood.net
|
@@ -260,16 +309,19 @@ files:
|
|
260
309
|
- Rakefile
|
261
310
|
- history.txt
|
262
311
|
- lib/tenacity.rb
|
312
|
+
- lib/tenacity/associate_proxy.rb
|
263
313
|
- lib/tenacity/associates_proxy.rb
|
264
314
|
- lib/tenacity/association.rb
|
265
315
|
- lib/tenacity/associations/belongs_to.rb
|
266
316
|
- lib/tenacity/associations/has_many.rb
|
267
317
|
- lib/tenacity/associations/has_one.rb
|
268
318
|
- lib/tenacity/class_methods.rb
|
319
|
+
- lib/tenacity/errors.rb
|
269
320
|
- lib/tenacity/instance_methods.rb
|
270
321
|
- lib/tenacity/orm_ext/activerecord.rb
|
271
322
|
- lib/tenacity/orm_ext/couchrest.rb
|
272
323
|
- lib/tenacity/orm_ext/datamapper.rb
|
324
|
+
- lib/tenacity/orm_ext/helpers.rb
|
273
325
|
- lib/tenacity/orm_ext/mongo_mapper.rb
|
274
326
|
- lib/tenacity/orm_ext/mongoid.rb
|
275
327
|
- lib/tenacity/orm_ext/sequel.rb
|
@@ -297,13 +349,21 @@ files:
|
|
297
349
|
- test/fixtures/data_mapper_has_many_target.rb
|
298
350
|
- test/fixtures/data_mapper_has_one_target.rb
|
299
351
|
- test/fixtures/data_mapper_object.rb
|
352
|
+
- test/fixtures/mongo_mapper_air_filter.rb
|
353
|
+
- test/fixtures/mongo_mapper_alternator.rb
|
300
354
|
- test/fixtures/mongo_mapper_ash_tray.rb
|
355
|
+
- test/fixtures/mongo_mapper_autosave_false_has_many_target.rb
|
356
|
+
- test/fixtures/mongo_mapper_autosave_false_has_one_target.rb
|
357
|
+
- test/fixtures/mongo_mapper_autosave_true_has_many_target.rb
|
358
|
+
- test/fixtures/mongo_mapper_autosave_true_has_one_target.rb
|
359
|
+
- test/fixtures/mongo_mapper_circuit_board.rb
|
301
360
|
- test/fixtures/mongo_mapper_dashboard.rb
|
302
361
|
- test/fixtures/mongo_mapper_has_many_target.rb
|
303
362
|
- test/fixtures/mongo_mapper_has_one_target.rb
|
304
363
|
- test/fixtures/mongo_mapper_object.rb
|
305
364
|
- test/fixtures/mongo_mapper_vent.rb
|
306
365
|
- test/fixtures/mongo_mapper_wheel.rb
|
366
|
+
- test/fixtures/mongo_mapper_windows.rb
|
307
367
|
- test/fixtures/mongoid_has_many_target.rb
|
308
368
|
- test/fixtures/mongoid_has_one_target.rb
|
309
369
|
- test/fixtures/mongoid_object.rb
|
@@ -333,16 +393,20 @@ rdoc_options: []
|
|
333
393
|
require_paths:
|
334
394
|
- lib
|
335
395
|
required_ruby_version: !ruby/object:Gem::Requirement
|
396
|
+
none: false
|
336
397
|
requirements:
|
337
398
|
- - ">="
|
338
399
|
- !ruby/object:Gem::Version
|
400
|
+
hash: 3
|
339
401
|
segments:
|
340
402
|
- 0
|
341
403
|
version: "0"
|
342
404
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
405
|
+
none: false
|
343
406
|
requirements:
|
344
407
|
- - ">="
|
345
408
|
- !ruby/object:Gem::Version
|
409
|
+
hash: 23
|
346
410
|
segments:
|
347
411
|
- 1
|
348
412
|
- 3
|
@@ -351,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
351
415
|
requirements: []
|
352
416
|
|
353
417
|
rubyforge_project: tenacity
|
354
|
-
rubygems_version: 1.
|
418
|
+
rubygems_version: 1.6.0
|
355
419
|
signing_key:
|
356
420
|
specification_version: 3
|
357
421
|
summary: A database client independent way of specifying simple relationships between models backed by different databases.
|