joinfix 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +157 -85
- data/Rakefile +38 -0
- data/TEST_README +45 -44
- data/lib/joinfix/error.rb +220 -0
- data/lib/joinfix/fixture.rb +3 -4
- data/lib/joinfix/fixtures.rb +107 -145
- data/lib/joinfix/fixtures_class.rb +51 -97
- data/lib/joinfix.rb +118 -84
- data/rails/app/models/group.rb +3 -3
- data/rails/db/migrate/004_create_users.rb +1 -1
- data/rails/db/schema.rb +1 -1
- data/rails/log/development.log +409 -57
- data/rails/log/test.log +350 -23
- data/rails/test/fixtures/groups.yml +2 -1
- data/rails/test/fixtures/users.yml +27 -19
- data/rails/test/unit/user_test.rb +25 -4
- data/test/has_many_test.rb +16 -0
- data/test/joinfix_test.rb +6 -69
- data/test/joinfix_test_suite.rb +1 -1
- metadata +9 -5
- data/test/todo +0 -15
data/test/joinfix_test.rb
CHANGED
@@ -36,40 +36,6 @@ class JoinFixTest < Test::Unit::TestCase
|
|
36
36
|
def teardown
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
40
|
-
# compatability tests
|
41
|
-
#
|
42
|
-
|
43
|
-
def btest_fixtures_without_templates_are_unaffected
|
44
|
-
database_test(NoJoinFixMigration) do |connection|
|
45
|
-
assert_equal "1", no_join_fixes(:first).field
|
46
|
-
assert_equal "2", no_join_fixes(:second).field
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def btest_omap_fixtures_without_templates_are_unaffected
|
51
|
-
database_test(NoJoinFixMigration) do |connection|
|
52
|
-
assert_equal 1, omap_no_join_fixes(:first).id
|
53
|
-
assert_equal 2, omap_no_join_fixes(:second).id
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
#
|
58
|
-
# preserved keys test
|
59
|
-
#
|
60
|
-
|
61
|
-
def btest_id_keys_are_preserved
|
62
|
-
[:id, :preserved_id].each do |key|
|
63
|
-
assert JoinFix.preserves?(key)
|
64
|
-
assert JoinFix.preserves?(key.to_s)
|
65
|
-
end
|
66
|
-
|
67
|
-
[:not_preserved, :pid, "_id"].each do |key|
|
68
|
-
assert !JoinFix.preserves?(key)
|
69
|
-
assert !JoinFix.preserves?(key.to_s)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
39
|
#
|
74
40
|
# join tests
|
75
41
|
#
|
@@ -110,8 +76,7 @@ class JoinFixTest < Test::Unit::TestCase
|
|
110
76
|
|
111
77
|
def test_join_belongs_to_validates_inclusion_of_required_configurations
|
112
78
|
assert_raise(ArgumentError) { joinfix.join_belongs_to(nil, {}) }
|
113
|
-
assert_raise(ArgumentError) { joinfix.
|
114
|
-
assert_raise(ArgumentError) { joinfix.join_belongs_to(nil, :child_table => "child_table") }
|
79
|
+
assert_raise(ArgumentError) { joinfix.join_has_one(nil, :child_table => "child_table") }
|
115
80
|
end
|
116
81
|
|
117
82
|
# join_has_one tests
|
@@ -126,7 +91,6 @@ class JoinFixTest < Test::Unit::TestCase
|
|
126
91
|
|
127
92
|
def test_join_has_one_validates_inclusion_of_required_configurations
|
128
93
|
assert_raise(ArgumentError) { joinfix.join_has_one(nil, {}) }
|
129
|
-
assert_raise(ArgumentError) { joinfix.join_has_one(nil, :foreign_key => "foreign_key") }
|
130
94
|
assert_raise(ArgumentError) { joinfix.join_has_one(nil, :parent_table => "parent_table") }
|
131
95
|
end
|
132
96
|
|
@@ -143,25 +107,9 @@ class JoinFixTest < Test::Unit::TestCase
|
|
143
107
|
assert_equal({["foreign_key", "parent_table"] => "parent_entry", ["association_foreign_key", "child_table"] => "child_entry"}, join)
|
144
108
|
end
|
145
109
|
|
146
|
-
def btest_join_has_and_belongs_to_many_with_attributes
|
147
|
-
attributes = {:some_attribute => "attribute"}
|
148
|
-
|
149
|
-
join = parent.join_has_and_belongs_to_many(child,
|
150
|
-
:foreign_key => "foreign_key",
|
151
|
-
:parent_table => "parent_table",
|
152
|
-
:association_foreign_key => "association_foreign_key",
|
153
|
-
:child_table => "child_table",
|
154
|
-
:attributes => attributes)
|
155
|
-
|
156
|
-
assert_equal({:name => "parent_name"}, parent)
|
157
|
-
assert_equal({:name => "child_name"}, child)
|
158
|
-
assert_equal(attributes.merge( ["foreign_key", "parent_table"] => "parent_entry", ["association_foreign_key", "child_table"] => "child_entry" ), join)
|
159
|
-
end
|
160
|
-
|
161
110
|
def test_join_has_and_belongs_to_many_validates_inclusion_of_required_configurations
|
162
111
|
assert_raise(ArgumentError) { joinfix.join_has_and_belongs_to_many(nil, {}) }
|
163
|
-
assert_raise(ArgumentError) { joinfix.
|
164
|
-
assert_raise(ArgumentError) { joinfix.join_has_and_belongs_to_many(nil, :association_foreign_key => "parent_table") }
|
112
|
+
assert_raise(ArgumentError) { joinfix.join_has_one(nil, :parent_table => "parent_table") }
|
165
113
|
end
|
166
114
|
|
167
115
|
# join_has_many test
|
@@ -201,22 +149,11 @@ class JoinFixTest < Test::Unit::TestCase
|
|
201
149
|
assert_equal({["foreign_key", "parent_table"] => "parent_entry", ["association_foreign_key", "child_table"] => "child_entry"}, join)
|
202
150
|
end
|
203
151
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
join = parent.join_has_many(child,
|
208
|
-
:through => "some_join_table",
|
209
|
-
:foreign_key => "foreign_key",
|
210
|
-
:parent_table => "parent_table",
|
211
|
-
:association_foreign_key => "association_foreign_key",
|
212
|
-
:child_table => "child_table",
|
213
|
-
:attributes => attributes)
|
214
|
-
|
215
|
-
assert_equal({:name => "parent_name"}, parent)
|
216
|
-
assert_equal({:name => "child_name"}, child)
|
217
|
-
assert_equal(attributes.merge(["foreign_key", "parent_table"] => "parent_entry", ["association_foreign_key", "child_table"] => "child_entry"), join)
|
152
|
+
def test_join_has_many_validates_inclusion_of_required_configurations
|
153
|
+
assert_raise(ArgumentError) { joinfix.join_has_many(nil, {}) }
|
154
|
+
assert_raise(ArgumentError) { joinfix.join_has_one(nil, :parent_table => "parent_table") }
|
218
155
|
end
|
219
|
-
|
156
|
+
|
220
157
|
#
|
221
158
|
# test extract_if
|
222
159
|
#
|
data/test/joinfix_test_suite.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift File.join(File.dirname(__FILE__), '../lib')
|
|
2
2
|
|
3
3
|
puts %{
|
4
4
|
NOTE! The joinfix tests are not run through this test suite
|
5
|
-
because they
|
5
|
+
because they must connect to a database. See TEST_README
|
6
6
|
for details and instructions on running the joinfix tests.
|
7
7
|
}
|
8
8
|
#
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: joinfix
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-06-28 00:00:00 -06:00
|
8
8
|
summary: A reflection-based solution to the fixture join problem.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -51,8 +51,8 @@ files:
|
|
51
51
|
- test/joinfix_test_suite.rb
|
52
52
|
- test/missing_fixture_test.rb
|
53
53
|
- test/nested_test.rb
|
54
|
-
- test/todo
|
55
54
|
- lib/joinfix
|
55
|
+
- lib/joinfix/error.rb
|
56
56
|
- lib/joinfix/fixture.rb
|
57
57
|
- lib/joinfix/fixtures.rb
|
58
58
|
- lib/joinfix/fixtures_class.rb
|
@@ -157,13 +157,17 @@ files:
|
|
157
157
|
- rails/tmp
|
158
158
|
- rails/vendor
|
159
159
|
- rails/vendor/plugins
|
160
|
+
- Rakefile
|
160
161
|
- README
|
161
162
|
- MIT-LICENSE
|
162
163
|
- TEST_README
|
163
164
|
test_files:
|
164
165
|
- test/joinfix_test_suite.rb
|
165
|
-
rdoc_options:
|
166
|
-
|
166
|
+
rdoc_options:
|
167
|
+
- --title
|
168
|
+
- JoinFix
|
169
|
+
- --main
|
170
|
+
- README
|
167
171
|
extra_rdoc_files:
|
168
172
|
- README
|
169
173
|
- MIT-LICENSE
|
data/test/todo
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
test error conditions:
|
2
|
-
-- fixture not specified
|
3
|
-
-- model not specified
|
4
|
-
-- name collisions
|
5
|
-
-- id collisions
|
6
|
-
|
7
|
-
test also:
|
8
|
-
-- omaps
|
9
|
-
-- fixtures across different test
|
10
|
-
-- mapping a fixture to a class
|
11
|
-
-- default field values
|
12
|
-
|
13
|
-
devel:
|
14
|
-
-- clean up error handling -- make appropriate subclasses of error
|
15
|
-
-- annoying that the re-raise loses the original stack trace
|