Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove execute permissions from affected files

  • Loading branch information...
commit 7f7ad072b65e984372b9f459ca49c6347a9f5b79 1 parent 5386b3f
Martin Gamsjaeger authored

Showing 32 changed files with 908 additions and 908 deletions. Show diff stats Hide diff stats

  1. 0  LICENSE
  2. 0  README.textile
  3. 0  Rakefile
  4. 0  TODO
  5. 0  spec/accepts_nested_attributes_for_spec.rb
  6. 0  spec/assign_nested_attributes_for_spec.rb
  7. +67 67 spec/comb/1-1_disjoint_spec.rb
  8. 0  spec/comb/1-1_overlapping_spec.rb
  9. +65 65 spec/comb/1-1_subset_spec.rb
  10. +67 67 spec/comb/1-1_superset_spec.rb
  11. +71 71 spec/comb/1-m_disjoint_spec.rb
  12. 0  spec/comb/1-m_overlapping_spec.rb
  13. +65 65 spec/comb/1-m_subset_spec.rb
  14. +71 71 spec/comb/1-m_superset_spec.rb
  15. +71 71 spec/comb/m-1_disjoint_spec.rb
  16. 0  spec/comb/m-1_overlapping_spec.rb
  17. +65 65 spec/comb/m-1_subset_spec.rb
  18. +71 71 spec/comb/m-1_superset_spec.rb
  19. +141 141 spec/comb/n-m_composite_spec.rb
  20. +154 154 spec/comb/n-m_surrogate_spec.rb
  21. 0  spec/many_to_many_composite_spec.rb
  22. 0  spec/many_to_one_composite_spec.rb
  23. 0  spec/one_to_many_composite_spec.rb
  24. 0  spec/one_to_one_composite_spec.rb
  25. 0  spec/shared/many_to_many_composite_spec.rb
  26. 0  spec/shared/many_to_one_composite_spec.rb
  27. 0  spec/shared/one_to_many_composite_spec.rb
  28. 0  spec/shared/one_to_one_composite_spec.rb
  29. 0  spec/spec.opts
  30. 0  spec/spec_helper.rb
  31. 0  spec/update_dirty_spec.rb
  32. 0  spec/update_multiple_spec.rb
0  LICENSE 100755 → 100644
File mode changed
0  README.textile 100755 → 100644
File mode changed
0  Rakefile 100755 → 100644
File mode changed
0  TODO 100755 → 100644
File mode changed
0  spec/accepts_nested_attributes_for_spec.rb 100755 → 100644
File mode changed
0  spec/assign_nested_attributes_for_spec.rb 100755 → 100644
File mode changed
134 spec/comb/1-1_disjoint_spec.rb 100755 → 100644
... ... @@ -1,67 +1,67 @@
1   -require 'spec_helper'
2   -
3   -describe "1:1 (PK disjoint FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has 1, :membership, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :min => 0, :unique => :person
21   - property :audit_id, Integer, :key => true, :min => 0
22   - property :id, Integer, :key => true, :min => 0
23   - property :person_id, Integer, :min => 0, :unique => :person
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35   - end
36   -
37   - describe "Person.accepts_nested_attributes_for(:membership)" do
38   - before(:all) do
39   - Person.accepts_nested_attributes_for :membership
40   - end
41   -
42   - it "should allow to update an existing membership via Person#membership_attributes" do
43   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
44   - Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
45   - person1.reload
46   -
47   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
48   - Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
49   - person2.reload
50   -
51   - Person.all.size.should == 2
52   - Membership.all.size.should == 2
53   -
54   - person1.membership_attributes = { :id => 100, :audit_id => 1000, :role => 'tester' }
55   - person1.save.should be_true
56   -
57   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
58   - [1, 10, 'Martin'],
59   - [2, 20, 'John'],
60   - ]
61   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
62   - [1, 10, 100, 1000, 'tester'],
63   - [2, 20, 200, 2000, 'contributor'],
64   - ]
65   - end
66   - end
67   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:1 (PK disjoint FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has 1, :membership, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :min => 0, :unique => :person
  21 + property :audit_id, Integer, :key => true, :min => 0
  22 + property :id, Integer, :key => true, :min => 0
  23 + property :person_id, Integer, :min => 0, :unique => :person
  24 + property :role, String, :required => true
  25 +
  26 + belongs_to :person
  27 + end
  28 +
  29 + DataMapper.auto_migrate!
  30 + end
  31 +
  32 + before(:each) do
  33 + Membership.all.destroy!
  34 + Person.all.destroy!
  35 + end
  36 +
  37 + describe "Person.accepts_nested_attributes_for(:membership)" do
  38 + before(:all) do
  39 + Person.accepts_nested_attributes_for :membership
  40 + end
  41 +
  42 + it "should allow to update an existing membership via Person#membership_attributes" do
  43 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  44 + Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
  45 + person1.reload
  46 +
  47 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  48 + Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
  49 + person2.reload
  50 +
  51 + Person.all.size.should == 2
  52 + Membership.all.size.should == 2
  53 +
  54 + person1.membership_attributes = { :id => 100, :audit_id => 1000, :role => 'tester' }
  55 + person1.save.should be_true
  56 +
  57 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  58 + [1, 10, 'Martin'],
  59 + [2, 20, 'John'],
  60 + ]
  61 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
  62 + [1, 10, 100, 1000, 'tester'],
  63 + [2, 20, 200, 2000, 'contributor'],
  64 + ]
  65 + end
  66 + end
  67 +end
0  spec/comb/1-1_overlapping_spec.rb 100755 → 100644
File mode changed
130 spec/comb/1-1_subset_spec.rb 100755 → 100644
... ... @@ -1,65 +1,65 @@
1   -require 'spec_helper'
2   -
3   -describe "1:1 (PK subset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has 1, :membership, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :key => false, :min => 0, :unique => :person
21   - property :person_id, Integer, :key => true, :min => 0, :unique => :person
22   - property :role, String, :required => true
23   -
24   - belongs_to :person
25   - end
26   -
27   - DataMapper.auto_migrate!
28   - end
29   -
30   - before(:each) do
31   - Membership.all.destroy!
32   - Person.all.destroy!
33   - end
34   -
35   - describe "Person.accepts_nested_attributes_for(:membership)" do
36   - before(:all) do
37   - Person.accepts_nested_attributes_for :membership
38   - end
39   -
40   - it "should allow to update an existing membership via Person#membership_attributes" do
41   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
42   - Membership.create(:person => person1, :role => 'maintainer')
43   - person1.reload
44   -
45   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
46   - Membership.create(:person => person2, :role => 'contributor')
47   - person2.reload
48   -
49   - Person.all.size.should == 2
50   - Membership.all.size.should == 2
51   -
52   - person1.membership_attributes = { :role => 'tester' }
53   - person1.save.should be_true
54   -
55   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
56   - [1, 10, 'Martin'],
57   - [2, 20, 'John'],
58   - ]
59   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
60   - [1, 10, 'tester'],
61   - [2, 20, 'contributor'],
62   - ]
63   - end
64   - end
65   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:1 (PK subset FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has 1, :membership, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :key => false, :min => 0, :unique => :person
  21 + property :person_id, Integer, :key => true, :min => 0, :unique => :person
  22 + property :role, String, :required => true
  23 +
  24 + belongs_to :person
  25 + end
  26 +
  27 + DataMapper.auto_migrate!
  28 + end
  29 +
  30 + before(:each) do
  31 + Membership.all.destroy!
  32 + Person.all.destroy!
  33 + end
  34 +
  35 + describe "Person.accepts_nested_attributes_for(:membership)" do
  36 + before(:all) do
  37 + Person.accepts_nested_attributes_for :membership
  38 + end
  39 +
  40 + it "should allow to update an existing membership via Person#membership_attributes" do
  41 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  42 + Membership.create(:person => person1, :role => 'maintainer')
  43 + person1.reload
  44 +
  45 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  46 + Membership.create(:person => person2, :role => 'contributor')
  47 + person2.reload
  48 +
  49 + Person.all.size.should == 2
  50 + Membership.all.size.should == 2
  51 +
  52 + person1.membership_attributes = { :role => 'tester' }
  53 + person1.save.should be_true
  54 +
  55 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  56 + [1, 10, 'Martin'],
  57 + [2, 20, 'John'],
  58 + ]
  59 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
  60 + [1, 10, 'tester'],
  61 + [2, 20, 'contributor'],
  62 + ]
  63 + end
  64 + end
  65 +end
134 spec/comb/1-1_superset_spec.rb 100755 → 100644
... ... @@ -1,67 +1,67 @@
1   -require 'spec_helper'
2   -
3   -describe "1:M (PK superset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has 1, :membership, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :project_audit_id, Integer, :key => true, :min => 0
21   - property :person_audit_id, Integer, :key => true, :min => 0, :unique => :person
22   - property :person_id, Integer, :key => true, :min => 0, :unique => :person
23   - property :project_id, Integer, :key => true, :min => 0
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35   - end
36   -
37   - describe "Person.accepts_nested_attributes_for(:membership)" do
38   - before(:all) do
39   - Person.accepts_nested_attributes_for :membership
40   - end
41   -
42   - it "should allow to update an existing membership via Person#membership_attributes" do
43   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
44   - Membership.create(:project_id => 100, :project_audit_id => 1000, :person => person1, :role => 'maintainer')
45   - person1.reload
46   -
47   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
48   - Membership.create(:project_id => 200, :project_audit_id => 2000, :person => person2, :role => 'contributor')
49   - person2.reload
50   -
51   - Person.all.size.should == 2
52   - Membership.all.size.should == 2
53   -
54   - person1.membership_attributes = { :project_id => 100, :project_audit_id => 1000, :role => 'tester' }
55   - person1.save.should be_true
56   -
57   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
58   - [1, 10, 'Martin'],
59   - [2, 20, 'John'],
60   - ]
61   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.project_id, m.project_audit_id, m.role] }.should == [
62   - [1, 10, 100, 1000, 'tester'],
63   - [2, 20, 200, 2000, 'contributor'],
64   - ]
65   - end
66   - end
67   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:M (PK superset FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has 1, :membership, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :project_audit_id, Integer, :key => true, :min => 0
  21 + property :person_audit_id, Integer, :key => true, :min => 0, :unique => :person
  22 + property :person_id, Integer, :key => true, :min => 0, :unique => :person
  23 + property :project_id, Integer, :key => true, :min => 0
  24 + property :role, String, :required => true
  25 +
  26 + belongs_to :person
  27 + end
  28 +
  29 + DataMapper.auto_migrate!
  30 + end
  31 +
  32 + before(:each) do
  33 + Membership.all.destroy!
  34 + Person.all.destroy!
  35 + end
  36 +
  37 + describe "Person.accepts_nested_attributes_for(:membership)" do
  38 + before(:all) do
  39 + Person.accepts_nested_attributes_for :membership
  40 + end
  41 +
  42 + it "should allow to update an existing membership via Person#membership_attributes" do
  43 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  44 + Membership.create(:project_id => 100, :project_audit_id => 1000, :person => person1, :role => 'maintainer')
  45 + person1.reload
  46 +
  47 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  48 + Membership.create(:project_id => 200, :project_audit_id => 2000, :person => person2, :role => 'contributor')
  49 + person2.reload
  50 +
  51 + Person.all.size.should == 2
  52 + Membership.all.size.should == 2
  53 +
  54 + person1.membership_attributes = { :project_id => 100, :project_audit_id => 1000, :role => 'tester' }
  55 + person1.save.should be_true
  56 +
  57 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  58 + [1, 10, 'Martin'],
  59 + [2, 20, 'John'],
  60 + ]
  61 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.project_id, m.project_audit_id, m.role] }.should == [
  62 + [1, 10, 100, 1000, 'tester'],
  63 + [2, 20, 200, 2000, 'contributor'],
  64 + ]
  65 + end
  66 + end
  67 +end
142 spec/comb/1-m_disjoint_spec.rb 100755 → 100644
... ... @@ -1,71 +1,71 @@
1   -require 'spec_helper'
2   -
3   -describe "1:M (PK disjoint FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :min => 0
21   - property :audit_id, Integer, :key => true, :min => 0
22   - property :id, Integer, :key => true, :min => 0
23   - property :person_id, Integer, :min => 0
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35   - end
36   -
37   - describe "Person.accepts_nested_attributes_for(:memberships)" do
38   - before(:all) do
39   - Person.accepts_nested_attributes_for :memberships
40   - end
41   -
42   - it "should allow to update an existing membership via Person#memberships_attributes" do
43   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
44   - Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
45   - Membership.create(:id => 101, :audit_id => 1001, :person => person1, :role => 'user')
46   - person1.reload
47   -
48   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
49   - Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
50   - Membership.create(:id => 201, :audit_id => 2001, :person => person2, :role => 'release-manager')
51   - person2.reload
52   -
53   - Person.all.size.should == 2
54   - Membership.all.size.should == 4
55   -
56   - person1.memberships_attributes = [{ :id => 100, :audit_id => 1000, :role => 'tester' }]
57   - person1.save.should be_true
58   -
59   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
60   - [1, 10, 'Martin'],
61   - [2, 20, 'John'],
62   - ]
63   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
64   - [1, 10, 100, 1000, 'tester'],
65   - [1, 10, 101, 1001, 'user'],
66   - [2, 20, 200, 2000, 'contributor'],
67   - [2, 20, 201, 2001, 'release-manager'],
68   - ]
69   - end
70   - end
71   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:M (PK disjoint FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has n, :memberships, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :min => 0
  21 + property :audit_id, Integer, :key => true, :min => 0
  22 + property :id, Integer, :key => true, :min => 0
  23 + property :person_id, Integer, :min => 0
  24 + property :role, String, :required => true
  25 +
  26 + belongs_to :person
  27 + end
  28 +
  29 + DataMapper.auto_migrate!
  30 + end
  31 +
  32 + before(:each) do
  33 + Membership.all.destroy!
  34 + Person.all.destroy!
  35 + end
  36 +
  37 + describe "Person.accepts_nested_attributes_for(:memberships)" do
  38 + before(:all) do
  39 + Person.accepts_nested_attributes_for :memberships
  40 + end
  41 +
  42 + it "should allow to update an existing membership via Person#memberships_attributes" do
  43 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  44 + Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
  45 + Membership.create(:id => 101, :audit_id => 1001, :person => person1, :role => 'user')
  46 + person1.reload
  47 +
  48 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  49 + Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
  50 + Membership.create(:id => 201, :audit_id => 2001, :person => person2, :role => 'release-manager')
  51 + person2.reload
  52 +
  53 + Person.all.size.should == 2
  54 + Membership.all.size.should == 4
  55 +
  56 + person1.memberships_attributes = [{ :id => 100, :audit_id => 1000, :role => 'tester' }]
  57 + person1.save.should be_true
  58 +
  59 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  60 + [1, 10, 'Martin'],
  61 + [2, 20, 'John'],
  62 + ]
  63 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
  64 + [1, 10, 100, 1000, 'tester'],
  65 + [1, 10, 101, 1001, 'user'],
  66 + [2, 20, 200, 2000, 'contributor'],
  67 + [2, 20, 201, 2001, 'release-manager'],
  68 + ]
  69 + end
  70 + end
  71 +end
0  spec/comb/1-m_overlapping_spec.rb 100755 → 100644
File mode changed
130 spec/comb/1-m_subset_spec.rb 100755 → 100644
... ... @@ -1,65 +1,65 @@
1   -require 'spec_helper'
2   -
3   -describe "1:M (PK subset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :key => false, :min => 0
21   - property :person_id, Integer, :key => true, :min => 0
22   - property :role, String, :required => true
23   -
24   - belongs_to :person
25   - end
26   -
27   - DataMapper.auto_migrate!
28   - end
29   -
30   - before(:each) do
31   - Membership.all.destroy!
32   - Person.all.destroy!
33   - end
34   -
35   - describe "Person.accepts_nested_attributes_for(:memberships)" do
36   - before(:all) do
37   - Person.accepts_nested_attributes_for :memberships
38   - end
39   -
40   - it "should allow to update an existing membership via Person#memberships_attributes" do
41   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
42   - Membership.create(:person => person1, :role => 'maintainer')
43   - person1.reload
44   -
45   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
46   - Membership.create(:person => person2, :role => 'contributor')
47   - person2.reload
48   -
49   - Person.all.size.should == 2
50   - Membership.all.size.should == 2
51   -
52   - person1.memberships_attributes = [{ :role => 'tester' }]
53   - person1.save.should be_true
54   -
55   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
56   - [1, 10, 'Martin'],
57   - [2, 20, 'John'],
58   - ]
59   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
60   - [1, 10, 'tester'],
61   - [2, 20, 'contributor'],
62   - ]
63   - end
64   - end
65   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:M (PK subset FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has n, :memberships, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :key => false, :min => 0
  21 + property :person_id, Integer, :key => true, :min => 0
  22 + property :role, String, :required => true
  23 +
  24 + belongs_to :person
  25 + end
  26 +
  27 + DataMapper.auto_migrate!
  28 + end
  29 +
  30 + before(:each) do
  31 + Membership.all.destroy!
  32 + Person.all.destroy!
  33 + end
  34 +
  35 + describe "Person.accepts_nested_attributes_for(:memberships)" do
  36 + before(:all) do
  37 + Person.accepts_nested_attributes_for :memberships
  38 + end
  39 +
  40 + it "should allow to update an existing membership via Person#memberships_attributes" do
  41 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  42 + Membership.create(:person => person1, :role => 'maintainer')
  43 + person1.reload
  44 +
  45 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  46 + Membership.create(:person => person2, :role => 'contributor')
  47 + person2.reload
  48 +
  49 + Person.all.size.should == 2
  50 + Membership.all.size.should == 2
  51 +
  52 + person1.memberships_attributes = [{ :role => 'tester' }]
  53 + person1.save.should be_true
  54 +
  55 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  56 + [1, 10, 'Martin'],
  57 + [2, 20, 'John'],
  58 + ]
  59 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
  60 + [1, 10, 'tester'],
  61 + [2, 20, 'contributor'],
  62 + ]
  63 + end
  64 + end
  65 +end
142 spec/comb/1-m_superset_spec.rb 100755 → 100644
... ... @@ -1,71 +1,71 @@
1   -require 'spec_helper'
2   -
3   -describe "1:M (PK superset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :project_audit_id, Integer, :key => true, :min => 0
21   - property :person_audit_id, Integer, :key => true, :min => 0
22   - property :person_id, Integer, :key => true, :min => 0
23   - property :project_id, Integer, :key => true, :min => 0
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35   - end
36   -
37   - describe "Person.accepts_nested_attributes_for(:memberships)" do
38   - before(:all) do
39   - Person.accepts_nested_attributes_for :memberships
40   - end
41   -
42   - it "should allow to update an existing membership via Person#memberships_attributes" do
43   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
44   - Membership.create(:project_id => 100, :project_audit_id => 1000, :person => person1, :role => 'maintainer')
45   - Membership.create(:project_id => 101, :project_audit_id => 1001, :person => person1, :role => 'user')
46   - person1.reload
47   -
48   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
49   - Membership.create(:project_id => 200, :project_audit_id => 2000, :person => person2, :role => 'contributor')
50   - Membership.create(:project_id => 201, :project_audit_id => 2001, :person => person2, :role => 'release-manager')
51   - person2.reload
52   -
53   - Person.all.size.should == 2
54   - Membership.all.size.should == 4
55   -
56   - person1.memberships_attributes = [{ :project_id => 100, :project_audit_id => 1000, :role => 'tester' }]
57   - person1.save.should be_true
58   -
59   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
60   - [1, 10, 'Martin'],
61   - [2, 20, 'John'],
62   - ]
63   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.project_id, m.project_audit_id, m.role] }.should == [
64   - [1, 10, 100, 1000, 'tester'],
65   - [1, 10, 101, 1001, 'user'],
66   - [2, 20, 200, 2000, 'contributor'],
67   - [2, 20, 201, 2001, 'release-manager'],
68   - ]
69   - end
70   - end
71   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "1:M (PK superset FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has n, :memberships, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :project_audit_id, Integer, :key => true, :min => 0
  21 + property :person_audit_id, Integer, :key => true, :min => 0
  22 + property :person_id, Integer, :key => true, :min => 0
  23 + property :project_id, Integer, :key => true, :min => 0
  24 + property :role, String, :required => true
  25 +
  26 + belongs_to :person
  27 + end
  28 +
  29 + DataMapper.auto_migrate!
  30 + end
  31 +
  32 + before(:each) do
  33 + Membership.all.destroy!
  34 + Person.all.destroy!
  35 + end
  36 +
  37 + describe "Person.accepts_nested_attributes_for(:memberships)" do
  38 + before(:all) do
  39 + Person.accepts_nested_attributes_for :memberships
  40 + end
  41 +
  42 + it "should allow to update an existing membership via Person#memberships_attributes" do
  43 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  44 + Membership.create(:project_id => 100, :project_audit_id => 1000, :person => person1, :role => 'maintainer')
  45 + Membership.create(:project_id => 101, :project_audit_id => 1001, :person => person1, :role => 'user')
  46 + person1.reload
  47 +
  48 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  49 + Membership.create(:project_id => 200, :project_audit_id => 2000, :person => person2, :role => 'contributor')
  50 + Membership.create(:project_id => 201, :project_audit_id => 2001, :person => person2, :role => 'release-manager')
  51 + person2.reload
  52 +
  53 + Person.all.size.should == 2
  54 + Membership.all.size.should == 4
  55 +
  56 + person1.memberships_attributes = [{ :project_id => 100, :project_audit_id => 1000, :role => 'tester' }]
  57 + person1.save.should be_true
  58 +
  59 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  60 + [1, 10, 'Martin'],
  61 + [2, 20, 'John'],
  62 + ]
  63 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.project_id, m.project_audit_id, m.role] }.should == [
  64 + [1, 10, 100, 1000, 'tester'],
  65 + [1, 10, 101, 1001, 'user'],
  66 + [2, 20, 200, 2000, 'contributor'],
  67 + [2, 20, 201, 2001, 'release-manager'],
  68 + ]
  69 + end
  70 + end
  71 +end
142 spec/comb/m-1_disjoint_spec.rb 100755 → 100644
... ... @@ -1,71 +1,71 @@
1   -require 'spec_helper'
2   -
3   -describe "M:1 (PK disjoint FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :min => 0
21   - property :audit_id, Integer, :key => true, :min => 0
22   - property :id, Integer, :key => true, :min => 0
23   - property :person_id, Integer, :min => 0
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35   - end
36   -
37   - describe "Membership.accepts_nested_attributes_for(:person)" do
38   - before(:all) do
39   - Membership.accepts_nested_attributes_for :person
40   - end
41   -
42   - it "should allow to update an existing person via Membership#person_attributes" do
43   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
44   - membership = Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
45   - Membership.create(:id => 101, :audit_id => 1001, :person => person1, :role => 'user')
46   - person1.reload
47   -
48   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
49   - Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
50   - Membership.create(:id => 201, :audit_id => 2001, :person => person2, :role => 'release-manager')
51   - person2.reload
52   -
53   - Person.all.size.should == 2
54   - Membership.all.size.should == 4
55   -
56   - membership.person_attributes = { :name => 'Martin Gamsjaeger' }
57   - membership.save.should be_true
58   -
59   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
60   - [1, 10, 'Martin Gamsjaeger'],
61   - [2, 20, 'John'],
62   - ]
63   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
64   - [1, 10, 100, 1000, 'maintainer'],
65   - [1, 10, 101, 1001, 'user'],
66   - [2, 20, 200, 2000, 'contributor'],
67   - [2, 20, 201, 2001, 'release-manager'],
68   - ]
69   - end
70   - end
71   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "M:1 (PK disjoint FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has n, :memberships, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :min => 0
  21 + property :audit_id, Integer, :key => true, :min => 0
  22 + property :id, Integer, :key => true, :min => 0
  23 + property :person_id, Integer, :min => 0
  24 + property :role, String, :required => true
  25 +
  26 + belongs_to :person
  27 + end
  28 +
  29 + DataMapper.auto_migrate!
  30 + end
  31 +
  32 + before(:each) do
  33 + Membership.all.destroy!
  34 + Person.all.destroy!
  35 + end
  36 +
  37 + describe "Membership.accepts_nested_attributes_for(:person)" do
  38 + before(:all) do
  39 + Membership.accepts_nested_attributes_for :person
  40 + end
  41 +
  42 + it "should allow to update an existing person via Membership#person_attributes" do
  43 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  44 + membership = Membership.create(:id => 100, :audit_id => 1000, :person => person1, :role => 'maintainer')
  45 + Membership.create(:id => 101, :audit_id => 1001, :person => person1, :role => 'user')
  46 + person1.reload
  47 +
  48 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  49 + Membership.create(:id => 200, :audit_id => 2000, :person => person2, :role => 'contributor')
  50 + Membership.create(:id => 201, :audit_id => 2001, :person => person2, :role => 'release-manager')
  51 + person2.reload
  52 +
  53 + Person.all.size.should == 2
  54 + Membership.all.size.should == 4
  55 +
  56 + membership.person_attributes = { :name => 'Martin Gamsjaeger' }
  57 + membership.save.should be_true
  58 +
  59 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  60 + [1, 10, 'Martin Gamsjaeger'],
  61 + [2, 20, 'John'],
  62 + ]
  63 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.id, m.audit_id, m.role] }.should == [
  64 + [1, 10, 100, 1000, 'maintainer'],
  65 + [1, 10, 101, 1001, 'user'],
  66 + [2, 20, 200, 2000, 'contributor'],
  67 + [2, 20, 201, 2001, 'release-manager'],
  68 + ]
  69 + end
  70 + end
  71 +end
0  spec/comb/m-1_overlapping_spec.rb 100755 → 100644
File mode changed
130 spec/comb/m-1_subset_spec.rb 100755 → 100644
... ... @@ -1,65 +1,65 @@
1   -require 'spec_helper'
2   -
3   -describe "M:1 (PK subset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :person_audit_id, Integer, :key => false, :min => 0
21   - property :person_id, Integer, :key => true, :min => 0
22   - property :role, String, :required => true
23   -
24   - belongs_to :person
25   - end
26   -
27   - DataMapper.auto_migrate!
28   - end
29   -
30   - before(:each) do
31   - Membership.all.destroy!
32   - Person.all.destroy!
33   - end
34   -
35   - describe "Membership.accepts_nested_attributes_for(:person)" do
36   - before(:all) do
37   - Membership.accepts_nested_attributes_for :person
38   - end
39   -
40   - it "should allow to update an existing person via Membership#person_attributes" do
41   - person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
42   - membership = Membership.create(:person => person1, :role => 'maintainer')
43   - person1.reload
44   -
45   - person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
46   - Membership.create(:person => person2, :role => 'contributor')
47   - person2.reload
48   -
49   - Person.all.size.should == 2
50   - Membership.all.size.should == 2
51   -
52   - membership.person_attributes = { :name => 'Martin Gamsjaeger' }
53   - membership.save.should be_true
54   -
55   - Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
56   - [1, 10, 'Martin Gamsjaeger'],
57   - [2, 20, 'John'],
58   - ]
59   - Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
60   - [1, 10, 'maintainer'],
61   - [2, 20, 'contributor'],
62   - ]
63   - end
64   - end
65   -end
  1 +require 'spec_helper'
  2 +
  3 +describe "M:1 (PK subset FK)" do
  4 + before(:all) do
  5 + class ::Person
  6 + include DataMapper::Resource
  7 + extend ConstraintSupport
  8 +
  9 + property :id, Serial, :key => true
  10 + property :audit_id, Integer, :key => true, :min => 0
  11 + property :name, String, :required => true
  12 +
  13 + has n, :memberships, constraint(:destroy)
  14 + end
  15 +
  16 + class ::Membership
  17 + include DataMapper::Resource
  18 +
  19 + # keep properties unordered
  20 + property :person_audit_id, Integer, :key => false, :min => 0
  21 + property :person_id, Integer, :key => true, :min => 0
  22 + property :role, String, :required => true
  23 +
  24 + belongs_to :person
  25 + end
  26 +
  27 + DataMapper.auto_migrate!
  28 + end
  29 +
  30 + before(:each) do
  31 + Membership.all.destroy!
  32 + Person.all.destroy!
  33 + end
  34 +
  35 + describe "Membership.accepts_nested_attributes_for(:person)" do
  36 + before(:all) do
  37 + Membership.accepts_nested_attributes_for :person
  38 + end
  39 +
  40 + it "should allow to update an existing person via Membership#person_attributes" do
  41 + person1 = Person.create(:id => 1, :audit_id => 10, :name => 'Martin')
  42 + membership = Membership.create(:person => person1, :role => 'maintainer')
  43 + person1.reload
  44 +
  45 + person2 = Person.create(:id => 2, :audit_id => 20, :name => 'John')
  46 + Membership.create(:person => person2, :role => 'contributor')
  47 + person2.reload
  48 +
  49 + Person.all.size.should == 2
  50 + Membership.all.size.should == 2
  51 +
  52 + membership.person_attributes = { :name => 'Martin Gamsjaeger' }
  53 + membership.save.should be_true
  54 +
  55 + Person.all.map { |p| [p.id, p.audit_id, p.name] }.should == [
  56 + [1, 10, 'Martin Gamsjaeger'],
  57 + [2, 20, 'John'],
  58 + ]
  59 + Membership.all.map { |m| [m.person_id, m.person_audit_id, m.role] }.should == [
  60 + [1, 10, 'maintainer'],
  61 + [2, 20, 'contributor'],
  62 + ]
  63 + end
  64 + end
  65 +end
142 spec/comb/m-1_superset_spec.rb 100755 → 100644
... ... @@ -1,71 +1,71 @@
1   -require 'spec_helper'
2   -
3   -describe "M:1 (PK superset FK)" do
4   - before(:all) do
5   - class ::Person
6   - include DataMapper::Resource
7   - extend ConstraintSupport
8   -
9   - property :id, Serial, :key => true
10   - property :audit_id, Integer, :key => true, :min => 0
11   - property :name, String, :required => true
12   -
13   - has n, :memberships, constraint(:destroy)
14   - end
15   -
16   - class ::Membership
17   - include DataMapper::Resource
18   -
19   - # keep properties unordered
20   - property :project_audit_id, Integer, :key => true, :min => 0
21   - property :person_audit_id, Integer, :key => true, :min => 0
22   - property :person_id, Integer, :key => true, :min => 0
23   - property :project_id, Integer, :key => true, :min => 0
24   - property :role, String, :required => true
25   -
26   - belongs_to :person
27   - end
28   -
29   - DataMapper.auto_migrate!
30   - end
31   -
32   - before(:each) do
33   - Membership.all.destroy!
34   - Person.all.destroy!
35