rails-erd 0.4.5 → 1.0.0

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.
@@ -4,17 +4,17 @@ class EntityTest < ActiveSupport::TestCase
4
4
  def create_entity(model)
5
5
  Domain::Entity.new(Domain.new, model.name, model)
6
6
  end
7
-
7
+
8
8
  def create_generalized_entity(name)
9
9
  Domain::Entity.new(Domain.new, name)
10
10
  end
11
-
11
+
12
12
  # Entity ===================================================================
13
13
  test "model should return active record model" do
14
14
  create_models "Foo"
15
15
  assert_equal Foo, create_entity(Foo).model
16
16
  end
17
-
17
+
18
18
  test "name should return model name" do
19
19
  create_models "Foo"
20
20
  assert_equal "Foo", create_entity(Foo).name
@@ -25,7 +25,7 @@ class EntityTest < ActiveSupport::TestCase
25
25
  foo, bar = create_entity(Foo), create_entity(Bar)
26
26
  assert_equal [bar, foo], [foo, bar].sort
27
27
  end
28
-
28
+
29
29
  test "to_s should equal name" do
30
30
  create_models "Foo"
31
31
  assert_equal "Foo", create_entity(Foo).to_s
@@ -49,7 +49,7 @@ class EntityTest < ActiveSupport::TestCase
49
49
  foo = domain.entity_by_name("Foo")
50
50
  assert_equal domain.relationships.select { |r| r.destination == foo }, foo.relationships
51
51
  end
52
-
52
+
53
53
  test "relationships should return relationships that connect to this model" do
54
54
  create_model "Foo", :bar => :references
55
55
  create_model "Bar", :baz => :references do
@@ -67,24 +67,24 @@ class EntityTest < ActiveSupport::TestCase
67
67
  # create_model "Foo"
68
68
  # assert_nil create_entity(Foo).parent
69
69
  # end
70
- #
70
+ #
71
71
  # test "parent should return nil for specialized entities with distinct tables" do
72
72
  # create_model "Foo", :type => :string
73
73
  # Object.const_set :SpecialFoo, Class.new(Foo)
74
74
  # SpecialFoo.class_eval do
75
- # set_table_name "special_foo"
75
+ # self.table_name = "special_foo"
76
76
  # end
77
77
  # create_table "special_foo", {}, true
78
78
  # assert_nil create_entity(SpecialFoo).parent
79
79
  # end
80
- #
80
+ #
81
81
  # test "parent should return parent entity for specialized entities" do
82
82
  # create_model "Foo", :type => :string
83
83
  # Object.const_set :SpecialFoo, Class.new(Foo)
84
84
  # domain = Domain.generate
85
85
  # assert_equal domain.entity_by_name("Foo"), Domain::Entity.from_models(domain, [SpecialFoo]).first.parent
86
86
  # end
87
- #
87
+ #
88
88
  # test "parent should return parent entity for specializations of specialized entities" do
89
89
  # create_model "Foo", :type => :string
90
90
  # Object.const_set :SpecialFoo, Class.new(Foo)
@@ -119,7 +119,7 @@ class EntityTest < ActiveSupport::TestCase
119
119
  create_model "Bar"
120
120
  assert_equal [false, false], Domain.generate.entities.map(&:disconnected?)
121
121
  end
122
-
122
+
123
123
  test "specialized should return false for regular entities" do
124
124
  create_model "Foo"
125
125
  assert_equal false, create_entity(Foo).specialized?
@@ -129,7 +129,7 @@ class EntityTest < ActiveSupport::TestCase
129
129
  create_model "Foo", :type => :string
130
130
  Object.const_set :SpecialFoo, Class.new(Foo)
131
131
  SpecialFoo.class_eval do
132
- set_table_name "special_foo"
132
+ self.table_name = "special_foo"
133
133
  end
134
134
  create_table "special_foo", {}, true
135
135
  assert_equal false, create_entity(SpecialFoo).specialized?
@@ -153,17 +153,17 @@ class EntityTest < ActiveSupport::TestCase
153
153
  Object.const_set :SpecialFoo, Class.new(Foo)
154
154
  assert_equal true, create_entity(SpecialFoo).abstract?
155
155
  end
156
-
156
+
157
157
  test "generalized should return false for regular entity" do
158
158
  create_model "Concrete"
159
159
  assert_equal false, create_entity(Concrete).generalized?
160
160
  end
161
-
161
+
162
162
  test "abstract should return false for regular entity" do
163
163
  create_model "Concrete"
164
164
  assert_equal false, create_entity(Concrete).abstract?
165
165
  end
166
-
166
+
167
167
  # Attribute processing =====================================================
168
168
  test "attributes should return list of attributes" do
169
169
  create_model "Bar", :some_column => :integer, :another_column => :string
@@ -179,23 +179,23 @@ class EntityTest < ActiveSupport::TestCase
179
179
  test "model should return nil for generalized entity" do
180
180
  assert_nil create_generalized_entity("MyAbstractModel").model
181
181
  end
182
-
182
+
183
183
  test "name should return given name for generalized entity" do
184
184
  assert_equal "MyAbstractModel", create_generalized_entity("MyAbstractModel").name
185
185
  end
186
-
186
+
187
187
  test "attributes should return empty array for generalized entity" do
188
188
  assert_equal [], create_generalized_entity("MyAbstractModel").attributes
189
189
  end
190
-
190
+
191
191
  test "generalized should return true for generalized entity" do
192
192
  assert_equal true, create_generalized_entity("MyAbstractModel").generalized?
193
193
  end
194
-
194
+
195
195
  test "specialized should return false for generalized entity" do
196
196
  assert_equal false, create_generalized_entity("MyAbstractModel").specialized?
197
197
  end
198
-
198
+
199
199
  test "abstract should return true for generalized entity" do
200
200
  assert_equal true, create_generalized_entity("MyAbstractModel").abstract?
201
201
  end
@@ -8,7 +8,7 @@ class GraphvizTest < ActiveSupport::TestCase
8
8
  end
9
9
 
10
10
  def teardown
11
- FileUtils.rm Dir["ERD.*"] rescue nil
11
+ FileUtils.rm Dir["erd.*"] rescue nil
12
12
  RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
13
13
  end
14
14
 
@@ -54,9 +54,9 @@ class GraphvizTest < ActiveSupport::TestCase
54
54
  test "file name should depend on file type" do
55
55
  create_simple_domain
56
56
  begin
57
- assert_equal "ERD.svg", Diagram::Graphviz.create(:filetype => :svg)
57
+ assert_equal "erd.svg", Diagram::Graphviz.create(:filetype => :svg)
58
58
  ensure
59
- FileUtils.rm "ERD.svg" rescue nil
59
+ FileUtils.rm "erd.svg" rescue nil
60
60
  end
61
61
  end
62
62
 
@@ -77,19 +77,19 @@ class GraphvizTest < ActiveSupport::TestCase
77
77
  end
78
78
  create_model "Bar", :column => :string
79
79
  Diagram::Graphviz.create
80
- assert File.exists?("ERD.png")
80
+ assert File.exists?("erd.png")
81
81
  end
82
82
 
83
83
  test "create should create output for domain without attributes" do
84
84
  create_simple_domain
85
85
  Diagram::Graphviz.create
86
- assert File.exists?("ERD.png")
86
+ assert File.exists?("erd.png")
87
87
  end
88
88
 
89
89
  test "create should write to file with dot extension if type is dot" do
90
90
  create_simple_domain
91
91
  Diagram::Graphviz.create :filetype => :dot
92
- assert File.exists?("ERD.dot")
92
+ assert File.exists?("erd.dot")
93
93
  end
94
94
 
95
95
  test "create should write to file with dot extension without requiring graphviz" do
@@ -115,18 +115,18 @@ class GraphvizTest < ActiveSupport::TestCase
115
115
  end
116
116
  create_model "Bar", :column => :string
117
117
  Diagram::Graphviz.create(:orientation => :vertical)
118
- assert File.exists?("ERD.png")
118
+ assert File.exists?("erd.png")
119
119
  end
120
120
 
121
121
  test "create should create output for domain if orientation is vertical" do
122
122
  create_simple_domain
123
123
  Diagram::Graphviz.create(:orientation => :vertical)
124
- assert File.exists?("ERD.png")
124
+ assert File.exists?("erd.png")
125
125
  end
126
126
 
127
127
  test "create should not create output if there are no connected models" do
128
128
  Diagram::Graphviz.create rescue nil
129
- assert !File.exists?("ERD.png")
129
+ assert !File.exists?("erd.png")
130
130
  end
131
131
 
132
132
  test "create should abort and complain if there are no connected models" do
@@ -341,7 +341,7 @@ class GraphvizTest < ActiveSupport::TestCase
341
341
  assert_equal [["normal", "normal"]], find_dot_edge_styles(diagram(:notation => :simple))
342
342
  end
343
343
 
344
- # Advanced notation style ===================================================
344
+ # Advanced notation style ==================================================
345
345
  test "generate should use open dots for one to one cardinalities with bachman notation" do
346
346
  create_one_to_one_assoc_domain
347
347
  assert_equal [["odot", "odot"]], find_dot_edge_styles(diagram(:notation => :bachman))
@@ -383,4 +383,47 @@ class GraphvizTest < ActiveSupport::TestCase
383
383
  end
384
384
  assert_equal [["dotnormal", "dotnormal"]], find_dot_edge_styles(diagram(:notation => :bachman))
385
385
  end
386
+
387
+ # Crows-foot notation style ================================================
388
+ test "generate should use 0/1 crowsfeet for one to one cardinalities with crowsfoot notation" do
389
+ create_one_to_one_assoc_domain
390
+ assert_equal [["teeodot", "teeodot"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
391
+ end
392
+
393
+ test "generate should use 1/1 crowsfeet for mandatory one to one cardinalities with crowsfoot notation" do
394
+ create_one_to_one_assoc_domain
395
+ One.class_eval do
396
+ validates_presence_of :other
397
+ end
398
+ assert_equal [["teeodot","teetee"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
399
+ end
400
+
401
+ test "generate should use 0/* crowsfeet with 0/1 crowsfeet for one to many cardinalities with crowsfoot notation" do
402
+ create_one_to_many_assoc_domain
403
+ assert_equal [["teeodot", "crowodot"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
404
+ end
405
+
406
+ test "generate should use 0/* crowsfeet with 1/1 crowsfett for mandatory one to many cardinalities with crowsfoot notation" do
407
+ create_one_to_many_assoc_domain
408
+ One.class_eval do
409
+ validates_presence_of :many
410
+ end
411
+ assert_equal [["teeodot", "crowtee"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
412
+ end
413
+
414
+ test "generate should use 0/* and 0/* crowsfeet for many to many cardinalities with crowsfoot notation" do
415
+ create_many_to_many_assoc_domain
416
+ assert_equal [["crowodot", "crowodot"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
417
+ end
418
+
419
+ test "generate should use 1/* and 1/* tail and head for mandatory many to many cardinalities with crowsfoot notation" do
420
+ create_many_to_many_assoc_domain
421
+ Many.class_eval do
422
+ validates_presence_of :more
423
+ end
424
+ More.class_eval do
425
+ validates_presence_of :many
426
+ end
427
+ assert_equal [["crowtee", "crowtee"]], find_dot_edge_styles(diagram(:notation => :crowsfoot))
428
+ end
386
429
  end
@@ -13,7 +13,7 @@ class RakeTaskTest < ActiveSupport::TestCase
13
13
  end
14
14
 
15
15
  def teardown
16
- FileUtils.rm "ERD.dot" rescue nil
16
+ FileUtils.rm "erd.dot" rescue nil
17
17
  RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
18
18
  end
19
19
 
@@ -35,12 +35,12 @@ class RakeTaskTest < ActiveSupport::TestCase
35
35
  test "generate task should create output based on domain model" do
36
36
  create_simple_domain
37
37
  Rake::Task["erd:generate"].execute
38
- assert File.exists?("ERD.dot")
38
+ assert File.exists?("erd.dot")
39
39
  end
40
40
 
41
41
  test "generate task should not create output if there are no connected models" do
42
42
  Rake::Task["erd:generate"].execute rescue nil
43
- assert !File.exists?("ERD.dot")
43
+ assert !File.exists?("erd.dot")
44
44
  end
45
45
 
46
46
  test "generate task should eager load application environment" do
@@ -92,11 +92,11 @@ class RakeTaskTest < ActiveSupport::TestCase
92
92
  rescue => e
93
93
  message = e.message
94
94
  end
95
- assert_equal <<-MSG.strip, message
95
+ assert_match /#{Regexp.escape(<<-MSG.strip).gsub("xxx", ".*?")}/, message
96
96
  Loading models failed!
97
97
  Error occurred while loading application: FooBar (RuntimeError)
98
- test/unit/rake_task_test.rb:#{l1}:in `block (3 levels) in <class:RakeTaskTest>'
99
- test/unit/rake_task_test.rb:#{l2}:in `block in <class:RakeTaskTest>'
98
+ test/unit/rake_task_test.rb:#{l1}:in `xxx'
99
+ test/unit/rake_task_test.rb:#{l2}:in `xxx'
100
100
  MSG
101
101
  end
102
102
 
@@ -110,13 +110,13 @@ Error occurred while loading application: FooBar (RuntimeError)
110
110
  Rake::Task.define_task :environment
111
111
  message = nil
112
112
  begin
113
- old_stdout, $stdout = $stdout, StringIO.new
113
+ old_stderr, $stderr = $stderr, StringIO.new
114
114
  Rake.application.options.trace = true
115
115
  Rake::Task["erd:generate"].invoke
116
116
  rescue => e
117
117
  message = e.message
118
118
  ensure
119
- $stdout = old_stdout
119
+ $stderr = old_stderr
120
120
  end
121
121
  assert_equal "FooBar", message
122
122
  end
@@ -2,11 +2,11 @@ require File.expand_path("../test_helper", File.dirname(__FILE__))
2
2
 
3
3
  class RelationshipTest < ActiveSupport::TestCase
4
4
  N = Domain::Relationship::N
5
-
5
+
6
6
  def domain_cardinalities
7
7
  Domain.generate.relationships.map(&:cardinality)
8
8
  end
9
-
9
+
10
10
  # Relationship =============================================================
11
11
  test "inspect should show source and destination" do
12
12
  create_model "Foo", :bar => :references do
@@ -15,7 +15,7 @@ class RelationshipTest < ActiveSupport::TestCase
15
15
  create_model "Bar"
16
16
  assert_match %r{#<RailsERD::Domain::Relationship:.* @source=Bar @destination=Foo>}, Domain.generate.relationships.first.inspect
17
17
  end
18
-
18
+
19
19
  test "source should return relationship source" do
20
20
  create_model "Foo", :bar => :references do
21
21
  belongs_to :bar
@@ -24,7 +24,7 @@ class RelationshipTest < ActiveSupport::TestCase
24
24
  domain = Domain.generate
25
25
  assert_equal [domain.entity_by_name("Bar")], domain.relationships.map(&:source)
26
26
  end
27
-
27
+
28
28
  test "destination should return relationship destination" do
29
29
  create_model "Foo", :bar => :references do
30
30
  belongs_to :bar
@@ -33,7 +33,7 @@ class RelationshipTest < ActiveSupport::TestCase
33
33
  domain = Domain.generate
34
34
  assert_equal [domain.entity_by_name("Foo")], domain.relationships.map(&:destination)
35
35
  end
36
-
36
+
37
37
  test "destination should return relationship destination if specified with absolute module path" do
38
38
  create_model "Foo", :bar => :references
39
39
  create_model "Bar" do
@@ -42,7 +42,7 @@ class RelationshipTest < ActiveSupport::TestCase
42
42
  domain = Domain.generate
43
43
  assert_equal [domain.entity_by_name("Foo")], domain.relationships.map(&:destination)
44
44
  end
45
-
45
+
46
46
  # Relationship properties ==================================================
47
47
  test "mutual should return false for one way relationship" do
48
48
  create_model "Foo", :bar => :references do
@@ -51,7 +51,7 @@ class RelationshipTest < ActiveSupport::TestCase
51
51
  create_model "Bar"
52
52
  assert_equal [false], Domain.generate.relationships.map(&:mutual?)
53
53
  end
54
-
54
+
55
55
  test "mutual should return true for mutual relationship" do
56
56
  create_model "Foo", :bar => :references do
57
57
  belongs_to :bar
@@ -61,12 +61,12 @@ class RelationshipTest < ActiveSupport::TestCase
61
61
  end
62
62
  assert_equal [true], Domain.generate.relationships.map(&:mutual?)
63
63
  end
64
-
64
+
65
65
  test "mutual should return true for mutual many to many relationship" do
66
66
  create_many_to_many_assoc_domain
67
67
  assert_equal [true], Domain.generate.relationships.map(&:mutual?)
68
68
  end
69
-
69
+
70
70
  test "recursive should return false for ordinary relationship" do
71
71
  create_model "Foo", :bar => :references do
72
72
  belongs_to :bar
@@ -76,14 +76,14 @@ class RelationshipTest < ActiveSupport::TestCase
76
76
  end
77
77
  assert_equal [false], Domain.generate.relationships.map(&:recursive?)
78
78
  end
79
-
79
+
80
80
  test "recursive should return true for self referencing relationship" do
81
81
  create_model "Foo", :foo => :references do
82
82
  belongs_to :foo
83
83
  end
84
84
  assert_equal [true], Domain.generate.relationships.map(&:recursive?)
85
85
  end
86
-
86
+
87
87
  test "indirect should return false for ordinary relationship" do
88
88
  create_model "Foo", :bar => :references do
89
89
  belongs_to :bar
@@ -93,7 +93,7 @@ class RelationshipTest < ActiveSupport::TestCase
93
93
  end
94
94
  assert_equal [false], Domain.generate.relationships.map(&:indirect?)
95
95
  end
96
-
96
+
97
97
  test "indirect should return false for non mutual ordinary relationship" do
98
98
  create_model "Foo", :bar => :references do
99
99
  belongs_to :bar
@@ -101,7 +101,7 @@ class RelationshipTest < ActiveSupport::TestCase
101
101
  create_model "Bar"
102
102
  assert_equal [false], Domain.generate.relationships.map(&:indirect?)
103
103
  end
104
-
104
+
105
105
  test "indirect should return true if relationship is a through association" do
106
106
  create_model "Foo", :baz => :references, :bar => :references do
107
107
  belongs_to :baz
@@ -117,7 +117,7 @@ class RelationshipTest < ActiveSupport::TestCase
117
117
  assert_equal true, Domain.generate.relationships.find { |rel|
118
118
  rel.source.model == Bar and rel.destination.model == Baz }.indirect?
119
119
  end
120
-
120
+
121
121
  test "strength should return one for relationship with one association" do
122
122
  create_model "Foo", :bar => :references
123
123
  create_model "Bar" do
@@ -160,7 +160,7 @@ class RelationshipTest < ActiveSupport::TestCase
160
160
  end
161
161
  assert_equal [1], Domain.generate.relationships.map(&:strength)
162
162
  end
163
-
163
+
164
164
  # Cardinalities ============================================================
165
165
  test "cardinality should be zero-one to zero-one for optional one to one associations" do
166
166
  create_one_to_one_assoc_domain
@@ -245,7 +245,7 @@ class RelationshipTest < ActiveSupport::TestCase
245
245
  end
246
246
  assert_equal [Domain::Relationship::Cardinality.new(0..1, 5..17)], domain_cardinalities
247
247
  end
248
-
248
+
249
249
  test "cardinality should be zero-many to zero-many for optional many to many associations" do
250
250
  create_many_to_many_assoc_domain
251
251
  assert_equal [Domain::Relationship::Cardinality.new(0..N, 0..N)], domain_cardinalities
@@ -261,7 +261,7 @@ class RelationshipTest < ActiveSupport::TestCase
261
261
  end
262
262
  assert_equal [Domain::Relationship::Cardinality.new(1..N, 1..N)], domain_cardinalities
263
263
  end
264
-
264
+
265
265
  test "cardinality should be n-m to n-m for limited many to many associations with single validations" do
266
266
  create_many_to_many_assoc_domain
267
267
  Many.class_eval do
@@ -289,7 +289,7 @@ class RelationshipTest < ActiveSupport::TestCase
289
289
  end
290
290
  assert_equal [Domain::Relationship::Cardinality.new(9..17, 3..20)], domain_cardinalities
291
291
  end
292
-
292
+
293
293
  # Cardinality for non-mutual relationships =================================
294
294
  test "cardinality should be zero-one to zero-many for non mutual relationship with belongs_to association" do
295
295
  create_model "One"
@@ -306,7 +306,7 @@ class RelationshipTest < ActiveSupport::TestCase
306
306
  create_model "Many", :one => :references
307
307
  assert_equal [Domain::Relationship::Cardinality.new(0..1, 0..N)], domain_cardinalities
308
308
  end
309
-
309
+
310
310
  test "cardinality should be zero-one to zero-one for non mutual relationship with has_one association" do
311
311
  create_model "One" do
312
312
  has_one :other
@@ -314,7 +314,7 @@ class RelationshipTest < ActiveSupport::TestCase
314
314
  create_model "Other", :one => :references
315
315
  assert_equal [Domain::Relationship::Cardinality.new(0..1, 0..1)], domain_cardinalities
316
316
  end
317
-
317
+
318
318
  test "cardinality should be zero-many to zero-many for non mutual relationship with has_and_belongs_to_many association" do
319
319
  create_table "many_more", :many_id => :integer, :more_id => :integer
320
320
  create_model "Many"
@@ -323,7 +323,7 @@ class RelationshipTest < ActiveSupport::TestCase
323
323
  end
324
324
  assert_equal [Domain::Relationship::Cardinality.new(0..N, 0..N)], domain_cardinalities
325
325
  end
326
-
326
+
327
327
  # Cardinality for multiple associations ====================================
328
328
  test "cardinality should be zero-one to zero-many for conflicting one to many associations" do
329
329
  create_model "CreditCard", :person => :references do
@@ -331,7 +331,7 @@ class RelationshipTest < ActiveSupport::TestCase
331
331
  end
332
332
  create_model "Person" do
333
333
  has_many :credit_cards
334
-
334
+
335
335
  # A person may have a preferred card, but they are still able to have
336
336
  # many cards. The association has an infinite maximum cardinality.
337
337
  has_one :preferred_credit_card, :class_name => "CreditCard"
@@ -353,14 +353,14 @@ class RelationshipTest < ActiveSupport::TestCase
353
353
  end
354
354
  assert_equal [Domain::Relationship::Cardinality.new(0..1, 1..N)], domain_cardinalities
355
355
  end
356
-
356
+
357
357
  test "cardinality should be n-m to n-m for conflicting validations in one to many associations" do
358
358
  create_model "Spell", :wizard => :references do
359
359
  end
360
360
  create_model "Wizard" do
361
361
  has_many :ice_spells, :class_name => "Spell"
362
362
  has_many :fire_spells, :class_name => "Spell"
363
-
363
+
364
364
  # Well, this can make sense, based on the conditions for the associations.
365
365
  # We don't go that far yet. We ignore the lower values and opt for the
366
366
  # higher values. It'll be okay. Really... You'll never need this.
@@ -369,7 +369,7 @@ class RelationshipTest < ActiveSupport::TestCase
369
369
  end
370
370
  assert_equal [Domain::Relationship::Cardinality.new(0..1, 50..100)], domain_cardinalities
371
371
  end
372
-
372
+
373
373
  test "cardinality should be one to one-many for mandatory one to many associations on polymorphic interfaces" do
374
374
  create_model "Cannon", :defensible => :references do
375
375
  belongs_to :defensible, :polymorphic => true
@@ -385,7 +385,7 @@ class RelationshipTest < ActiveSupport::TestCase
385
385
  end
386
386
  assert_equal [Domain::Relationship::Cardinality.new(1, 1..N)], domain_cardinalities
387
387
  end
388
-
388
+
389
389
  # Cardinality classes ======================================================
390
390
  test "cardinality should be one to one for has_one associations" do
391
391
  create_one_to_one_assoc_domain
@@ -403,7 +403,7 @@ class RelationshipTest < ActiveSupport::TestCase
403
403
  assert_equal [true], domain.relationships.map(&:to_one?)
404
404
  assert_equal [false], domain.relationships.map(&:to_many?)
405
405
  end
406
-
406
+
407
407
  test "cardinality should be one to many for has_many associations" do
408
408
  create_one_to_many_assoc_domain
409
409
  domain = Domain.generate
@@ -418,7 +418,7 @@ class RelationshipTest < ActiveSupport::TestCase
418
418
  assert_equal [false], domain.relationships.map(&:to_one?)
419
419
  assert_equal [true], domain.relationships.map(&:to_many?)
420
420
  end
421
-
421
+
422
422
  test "cardinality should be many to many for has_and_belongs_to_many associations" do
423
423
  create_many_to_many_assoc_domain
424
424
  domain = Domain.generate
@@ -434,7 +434,7 @@ class RelationshipTest < ActiveSupport::TestCase
434
434
  assert_equal [false], domain.relationships.map(&:to_one?)
435
435
  assert_equal [true], domain.relationships.map(&:to_many?)
436
436
  end
437
-
437
+
438
438
  test "cardinality should be one to many for multiple associations with maximum cardinality of has_many" do
439
439
  create_model "Foo", :bar => :references
440
440
  create_model "Bar" do
@@ -444,7 +444,7 @@ class RelationshipTest < ActiveSupport::TestCase
444
444
  domain = Domain.generate
445
445
  assert_equal [:one_to_many], domain.relationships.map(&:cardinality).map(&:name)
446
446
  end
447
-
447
+
448
448
  test "cardinality should be one to many if forward association is missing" do
449
449
  create_model "Foo", :bar => :references do
450
450
  belongs_to :bar
@@ -453,7 +453,7 @@ class RelationshipTest < ActiveSupport::TestCase
453
453
  domain = Domain.generate
454
454
  assert_equal [:one_to_many], domain.relationships.map(&:cardinality).map(&:name)
455
455
  end
456
-
456
+
457
457
  test "cardinality should be one to many for has_many associations from generalized entity" do
458
458
  create_model "Stronghold" do
459
459
  has_many :cannons, :as => :defensible