dm-core 1.0.2 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/Gemfile +28 -94
  2. data/LICENSE +1 -1
  3. data/README.rdoc +44 -11
  4. data/Rakefile +1 -7
  5. data/VERSION +1 -1
  6. data/dm-core.gemspec +398 -299
  7. data/lib/dm-core.rb +23 -13
  8. data/lib/dm-core/adapters/abstract_adapter.rb +1 -1
  9. data/lib/dm-core/associations/many_to_many.rb +1 -3
  10. data/lib/dm-core/associations/many_to_one.rb +54 -36
  11. data/lib/dm-core/associations/one_to_many.rb +1 -2
  12. data/lib/dm-core/associations/relationship.rb +11 -2
  13. data/lib/dm-core/collection.rb +3 -7
  14. data/lib/dm-core/core_ext/symbol.rb +1 -1
  15. data/lib/dm-core/identity_map.rb +0 -5
  16. data/lib/dm-core/model.rb +11 -21
  17. data/lib/dm-core/model/property.rb +43 -58
  18. data/lib/dm-core/model/relationship.rb +49 -44
  19. data/lib/dm-core/property.rb +106 -130
  20. data/lib/dm-core/property/date_time.rb +1 -3
  21. data/lib/dm-core/property/decimal.rb +11 -7
  22. data/lib/dm-core/property/integer.rb +2 -2
  23. data/lib/dm-core/property/lookup.rb +3 -16
  24. data/lib/dm-core/property/numeric.rb +3 -3
  25. data/lib/dm-core/property/object.rb +2 -11
  26. data/lib/dm-core/property/string.rb +1 -1
  27. data/lib/dm-core/property_set.rb +34 -54
  28. data/lib/dm-core/query.rb +85 -56
  29. data/lib/dm-core/query/conditions/comparison.rb +3 -6
  30. data/lib/dm-core/query/direction.rb +0 -4
  31. data/lib/dm-core/query/path.rb +22 -6
  32. data/lib/dm-core/relationship_set.rb +74 -0
  33. data/lib/dm-core/resource.rb +21 -32
  34. data/lib/dm-core/resource/state.rb +3 -4
  35. data/lib/dm-core/spec/lib/spec_helper.rb +1 -4
  36. data/lib/dm-core/spec/setup.rb +12 -5
  37. data/lib/dm-core/spec/shared/public/property_spec.rb +35 -21
  38. data/lib/dm-core/spec/shared/resource_spec.rb +1 -1
  39. data/lib/dm-core/spec/shared/semipublic/property_spec.rb +9 -9
  40. data/lib/dm-core/spec/shared/semipublic/query/conditions/abstract_comparison_spec.rb +261 -0
  41. data/lib/dm-core/support/deprecate.rb +1 -1
  42. data/lib/dm-core/support/descendant_set.rb +12 -5
  43. data/lib/dm-core/support/ordered_set.rb +382 -0
  44. data/lib/dm-core/support/subject_set.rb +252 -0
  45. data/lib/dm-core/version.rb +1 -1
  46. data/spec/public/associations/many_to_many/read_multiple_join_spec.rb +1 -2
  47. data/spec/public/associations/many_to_many_spec.rb +11 -9
  48. data/spec/public/associations/many_to_one_spec.rb +1 -1
  49. data/spec/public/associations/many_to_one_with_boolean_cpk_spec.rb +1 -1
  50. data/spec/public/associations/many_to_one_with_custom_fk_spec.rb +2 -2
  51. data/spec/public/associations/one_to_many_spec.rb +6 -5
  52. data/spec/public/associations/one_to_one_spec.rb +1 -1
  53. data/spec/public/associations/one_to_one_with_boolean_cpk_spec.rb +1 -1
  54. data/spec/public/collection_spec.rb +7 -6
  55. data/spec/public/finalize_spec.rb +1 -1
  56. data/spec/public/model/hook_spec.rb +4 -3
  57. data/spec/public/model/property_spec.rb +9 -3
  58. data/spec/public/model/relationship_spec.rb +2 -4
  59. data/spec/public/model_spec.rb +1 -1
  60. data/spec/public/property/binary_spec.rb +1 -1
  61. data/spec/public/property/boolean_spec.rb +1 -1
  62. data/spec/public/property/class_spec.rb +1 -1
  63. data/spec/public/property/date_spec.rb +1 -1
  64. data/spec/public/property/date_time_spec.rb +1 -1
  65. data/spec/public/property/decimal_spec.rb +7 -6
  66. data/spec/public/property/discriminator_spec.rb +1 -1
  67. data/spec/public/property/float_spec.rb +1 -1
  68. data/spec/public/property/integer_spec.rb +1 -1
  69. data/spec/public/property/object_spec.rb +2 -2
  70. data/spec/public/property/serial_spec.rb +1 -1
  71. data/spec/public/property/string_spec.rb +1 -1
  72. data/spec/public/property/text_spec.rb +6 -3
  73. data/spec/public/property/time_spec.rb +1 -1
  74. data/spec/public/property_spec.rb +13 -11
  75. data/spec/public/resource_spec.rb +43 -1
  76. data/spec/public/sel_spec.rb +1 -1
  77. data/spec/public/setup_spec.rb +1 -1
  78. data/spec/public/shared/collection_shared_spec.rb +6 -1
  79. data/spec/semipublic/adapters/abstract_adapter_spec.rb +1 -1
  80. data/spec/semipublic/adapters/in_memory_adapter_spec.rb +1 -1
  81. data/spec/semipublic/associations/many_to_many_spec.rb +1 -1
  82. data/spec/semipublic/associations/many_to_one_spec.rb +1 -1
  83. data/spec/semipublic/associations/one_to_many_spec.rb +1 -1
  84. data/spec/semipublic/associations/one_to_one_spec.rb +1 -1
  85. data/spec/semipublic/associations/relationship_spec.rb +1 -1
  86. data/spec/semipublic/associations_spec.rb +1 -1
  87. data/spec/semipublic/collection_spec.rb +1 -1
  88. data/spec/semipublic/model_spec.rb +1 -1
  89. data/spec/semipublic/property/binary_spec.rb +1 -1
  90. data/spec/semipublic/property/boolean_spec.rb +1 -1
  91. data/spec/semipublic/property/class_spec.rb +1 -1
  92. data/spec/semipublic/property/date_spec.rb +1 -1
  93. data/spec/semipublic/property/date_time_spec.rb +1 -1
  94. data/spec/semipublic/property/decimal_spec.rb +6 -5
  95. data/spec/semipublic/property/discriminator_spec.rb +1 -1
  96. data/spec/semipublic/property/float_spec.rb +1 -1
  97. data/spec/semipublic/property/integer_spec.rb +1 -1
  98. data/spec/semipublic/property/lookup_spec.rb +8 -5
  99. data/spec/semipublic/property/serial_spec.rb +1 -1
  100. data/spec/semipublic/property/string_spec.rb +1 -1
  101. data/spec/semipublic/property/text_spec.rb +1 -1
  102. data/spec/semipublic/property/time_spec.rb +1 -1
  103. data/spec/semipublic/property_spec.rb +32 -7
  104. data/spec/semipublic/query/conditions/comparison_spec.rb +1 -264
  105. data/spec/semipublic/query/conditions/operation_spec.rb +1 -2
  106. data/spec/semipublic/query/path_spec.rb +27 -1
  107. data/spec/semipublic/query_spec.rb +87 -36
  108. data/spec/semipublic/resource/state/clean_spec.rb +1 -2
  109. data/spec/semipublic/resource/state/deleted_spec.rb +1 -2
  110. data/spec/semipublic/resource/state/dirty_spec.rb +1 -2
  111. data/spec/semipublic/resource/state/immutable_spec.rb +1 -2
  112. data/spec/semipublic/resource/state/transient_spec.rb +7 -2
  113. data/spec/semipublic/resource/state_spec.rb +1 -1
  114. data/spec/semipublic/resource_spec.rb +1 -1
  115. data/spec/unit/array_spec.rb +1 -0
  116. data/spec/unit/data_mapper/ordered_set/append_spec.rb +26 -0
  117. data/spec/unit/data_mapper/ordered_set/clear_spec.rb +24 -0
  118. data/spec/unit/data_mapper/ordered_set/delete_spec.rb +28 -0
  119. data/spec/unit/data_mapper/ordered_set/each_spec.rb +19 -0
  120. data/spec/unit/data_mapper/ordered_set/empty_spec.rb +20 -0
  121. data/spec/unit/data_mapper/ordered_set/entries_spec.rb +22 -0
  122. data/spec/unit/data_mapper/ordered_set/eql_spec.rb +51 -0
  123. data/spec/unit/data_mapper/ordered_set/equal_value_spec.rb +84 -0
  124. data/spec/unit/data_mapper/ordered_set/hash_spec.rb +12 -0
  125. data/spec/unit/data_mapper/ordered_set/include_spec.rb +23 -0
  126. data/spec/unit/data_mapper/ordered_set/index_spec.rb +28 -0
  127. data/spec/unit/data_mapper/ordered_set/initialize_spec.rb +32 -0
  128. data/spec/unit/data_mapper/ordered_set/merge_spec.rb +36 -0
  129. data/spec/unit/data_mapper/ordered_set/shared/append_spec.rb +24 -0
  130. data/spec/unit/data_mapper/ordered_set/shared/clear_spec.rb +9 -0
  131. data/spec/unit/data_mapper/ordered_set/shared/delete_spec.rb +25 -0
  132. data/spec/unit/data_mapper/ordered_set/shared/each_spec.rb +17 -0
  133. data/spec/unit/data_mapper/ordered_set/shared/empty_spec.rb +9 -0
  134. data/spec/unit/data_mapper/ordered_set/shared/entries_spec.rb +9 -0
  135. data/spec/unit/data_mapper/ordered_set/shared/include_spec.rb +9 -0
  136. data/spec/unit/data_mapper/ordered_set/shared/index_spec.rb +13 -0
  137. data/spec/unit/data_mapper/ordered_set/shared/initialize_spec.rb +28 -0
  138. data/spec/unit/data_mapper/ordered_set/shared/merge_spec.rb +28 -0
  139. data/spec/unit/data_mapper/ordered_set/shared/size_spec.rb +13 -0
  140. data/spec/unit/data_mapper/ordered_set/shared/to_ary_spec.rb +11 -0
  141. data/spec/unit/data_mapper/ordered_set/size_spec.rb +27 -0
  142. data/spec/unit/data_mapper/ordered_set/to_ary_spec.rb +23 -0
  143. data/spec/unit/data_mapper/subject_set/append_spec.rb +47 -0
  144. data/spec/unit/data_mapper/subject_set/clear_spec.rb +34 -0
  145. data/spec/unit/data_mapper/subject_set/delete_spec.rb +40 -0
  146. data/spec/unit/data_mapper/subject_set/each_spec.rb +30 -0
  147. data/spec/unit/data_mapper/subject_set/empty_spec.rb +31 -0
  148. data/spec/unit/data_mapper/subject_set/entries_spec.rb +31 -0
  149. data/spec/unit/data_mapper/subject_set/get_spec.rb +34 -0
  150. data/spec/unit/data_mapper/subject_set/include_spec.rb +32 -0
  151. data/spec/unit/data_mapper/subject_set/named_spec.rb +33 -0
  152. data/spec/unit/data_mapper/subject_set/shared/append_spec.rb +18 -0
  153. data/spec/unit/data_mapper/subject_set/shared/clear_spec.rb +9 -0
  154. data/spec/unit/data_mapper/subject_set/shared/delete_spec.rb +9 -0
  155. data/spec/unit/data_mapper/subject_set/shared/each_spec.rb +9 -0
  156. data/spec/unit/data_mapper/subject_set/shared/empty_spec.rb +9 -0
  157. data/spec/unit/data_mapper/subject_set/shared/entries_spec.rb +9 -0
  158. data/spec/unit/data_mapper/subject_set/shared/get_spec.rb +9 -0
  159. data/spec/unit/data_mapper/subject_set/shared/include_spec.rb +9 -0
  160. data/spec/unit/data_mapper/subject_set/shared/named_spec.rb +9 -0
  161. data/spec/unit/data_mapper/subject_set/shared/size_spec.rb +13 -0
  162. data/spec/unit/data_mapper/subject_set/shared/to_ary_spec.rb +9 -0
  163. data/spec/unit/data_mapper/subject_set/shared/values_at_spec.rb +44 -0
  164. data/spec/unit/data_mapper/subject_set/size_spec.rb +42 -0
  165. data/spec/unit/data_mapper/subject_set/to_ary_spec.rb +34 -0
  166. data/spec/unit/data_mapper/subject_set/values_at_spec.rb +57 -0
  167. data/spec/unit/hash_spec.rb +2 -1
  168. data/spec/unit/hook_spec.rb +1 -0
  169. data/spec/unit/lazy_array_spec.rb +2 -1
  170. data/spec/unit/module_spec.rb +2 -1
  171. data/spec/unit/object_spec.rb +1 -0
  172. data/spec/unit/try_dup_spec.rb +1 -0
  173. data/tasks/spec.rake +0 -3
  174. metadata +149 -52
  175. data/.gitignore +0 -37
  176. data/lib/dm-core/type.rb +0 -216
  177. data/lib/dm-core/types/boolean.rb +0 -9
  178. data/lib/dm-core/types/decimal.rb +0 -9
  179. data/lib/dm-core/types/discriminator.rb +0 -50
  180. data/lib/dm-core/types/object.rb +0 -25
  181. data/lib/dm-core/types/serial.rb +0 -11
  182. data/lib/dm-core/types/text.rb +0 -11
  183. data/tasks/local_gemfile.rake +0 -16
  184. data/tasks/metrics.rake +0 -37
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  share_examples_for 'it creates a one accessor' do
4
4
  describe 'accessor' do
@@ -614,9 +614,7 @@ describe DataMapper::Associations do
614
614
  end
615
615
 
616
616
  it 'should also change the foreign key' do
617
- pending 'a change to the foreign key should also change the related object' do
618
- @engine.car.should eql(@car2)
619
- end
617
+ @engine.car.should eql(@car2)
620
618
  end
621
619
 
622
620
  it 'should add the engine to the car' do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  # TODO: move these specs into shared specs for #copy
4
4
  describe DataMapper::Model do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Binary do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Boolean do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Class do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Date do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::DateTime do
4
4
  before :all do
@@ -1,12 +1,13 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Decimal do
4
4
  before :all do
5
- @name = :rate
6
- @type = DataMapper::Property::Decimal
7
- @primitive = BigDecimal
8
- @value = BigDecimal('1.0')
9
- @other_value = BigDecimal('2.0')
5
+ @name = :rate
6
+ @type = DataMapper::Property::Decimal
7
+ @options = { :precision => 5, :scale => 2 }
8
+ @primitive = BigDecimal
9
+ @value = BigDecimal('1.0')
10
+ @other_value = BigDecimal('2.0')
10
11
  @invalid_value = true
11
12
  end
12
13
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Discriminator do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Float do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Integer do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property, 'Object type' do
4
4
  before :all do
@@ -31,7 +31,7 @@ describe DataMapper::Property, 'Object type' do
31
31
  it { should equal(@value) }
32
32
  end
33
33
 
34
- it { should respond_to(:value) }
34
+ it { should respond_to(:dump) }
35
35
 
36
36
  describe '#dump' do
37
37
  describe 'with a value' do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Serial do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::String do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Text do
4
4
  before :all do
@@ -15,7 +15,8 @@ describe DataMapper::Property::Text do
15
15
  describe 'migration with an index' do
16
16
  supported_by :all do
17
17
  before do
18
- @model = DataMapper::Model.new do
18
+ Object.send(:remove_const, :Foo) if Object.const_defined?(:Foo)
19
+ @model = DataMapper::Model.new('Foo') do
19
20
  storage_names[:default] = 'anonymous'
20
21
 
21
22
  property :id, DataMapper::Property::Serial
@@ -34,7 +35,9 @@ describe DataMapper::Property::Text do
34
35
  describe 'migration with a unique index' do
35
36
  supported_by :all do
36
37
  before do
37
- @model = DataMapper::Model.new do
38
+
39
+ Object.send(:remove_const, :Foo) if Object.const_defined?(:Foo)
40
+ @model = DataMapper::Model.new('Foo') do
38
41
  storage_names[:default] = 'anonymous'
39
42
 
40
43
  property :id, DataMapper::Property::Serial
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Time do
4
4
  before :all do
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+ require 'spec_helper'
3
3
 
4
4
  # instance methods
5
5
  describe DataMapper::Property do
@@ -22,6 +22,8 @@ describe DataMapper::Property do
22
22
  property :md5hash, String, :key => true, :length => 32
23
23
  property :title, String, :required => true, :unique => true
24
24
  property :description, Text, :length => 1..1024, :lazy => [ :detail ]
25
+ property :width, Integer, :lazy => [:dimensions]
26
+ property :height, Integer, :lazy => [:dimensions]
25
27
  property :format, String, :default => 'jpeg'
26
28
  property :taken_at, Time, :default => proc { Time.now }
27
29
  end
@@ -39,12 +41,6 @@ describe DataMapper::Property do
39
41
  it 'sets field value using field naming convention on first reference'
40
42
  end
41
43
 
42
- describe '#custom?' do
43
- it 'is true for custom type fields (not provided by dm-core)'
44
-
45
- it 'is false for core type fields (provided by dm-core)'
46
- end
47
-
48
44
  describe '#default_for' do
49
45
  it 'returns default value for non-callables' do
50
46
  Image.properties[:format].default_for(Image.new).should == 'jpeg'
@@ -103,10 +99,6 @@ describe DataMapper::Property do
103
99
  describe 'when tracking strategy is explicitly given' do
104
100
  it 'uses tracking strategy from options'
105
101
  end
106
-
107
- describe 'when custom type has tracking stragegy' do
108
- it 'uses tracking strategy from type'
109
- end
110
102
  end
111
103
 
112
104
  describe '#inspect' do
@@ -150,6 +142,16 @@ describe DataMapper::Property do
150
142
  end
151
143
  end
152
144
 
145
+ describe "#lazy_load_properties" do
146
+ it "returns all lazy properties in the same context" do
147
+ Image.properties[:width].__send__(:lazy_load_properties).should == Image.properties.values_at(:width, :height)
148
+ end
149
+
150
+ it "returns all properties by default" do
151
+ Track.properties[:artist].__send__(:lazy_load_properties).should == Track.properties
152
+ end
153
+ end
154
+
153
155
  describe '#length' do
154
156
  it 'returns upper bound for Range values' do
155
157
  Image.properties[:description].length.should eql(1024)
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Resource do
4
4
  before :all do
@@ -180,5 +180,47 @@ describe DataMapper::Resource do
180
180
  end
181
181
  end
182
182
  end
183
+
184
+ [ :update, :update! ].each do |method|
185
+ describe 'with attributes where one is a foreign key' do
186
+ before :all do
187
+ rescue_if @skip do
188
+ @dkubb = @user.referrer = @user_model.create(:name => 'dkubb', :age => 33)
189
+ @user.save
190
+ @user = @user_model.get(*@user.key)
191
+ @user.referrer.should == @dkubb
192
+
193
+ @solnic = @user_model.create(:name => 'solnic', :age => 28)
194
+
195
+ @attributes = {}
196
+
197
+ relationship = @user_model.relationships[:referrer]
198
+ relationship.child_key.to_a.each_with_index do |k, i|
199
+ @attributes[k.name] = relationship.parent_key.to_a[i].get(@solnic)
200
+ end
201
+
202
+ @return = @user.__send__(method, @attributes)
203
+ end
204
+ end
205
+
206
+ it 'should return true' do
207
+ @return.should be(true)
208
+ end
209
+
210
+ it 'should update attributes of Resource' do
211
+ @attributes.each { |key, value| @user.__send__(key).should == value }
212
+ end
213
+
214
+ it 'should persist the changes' do
215
+ resource = @user_model.get(*@user.key)
216
+ @attributes.each { |key, value| resource.__send__(key).should == value }
217
+ end
218
+
219
+ it 'should return correct parent' do
220
+ resource = @user_model.get(*@user.key)
221
+ resource.referrer.should == @solnic
222
+ end
223
+ end
224
+ end
183
225
  end
184
226
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'SEL', 'with STI subclasses' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper do
4
4
  describe '.setup' do
@@ -566,7 +566,8 @@ share_examples_for 'A public Collection' do
566
566
  describe '#new' do
567
567
  describe 'when scoped to a property' do
568
568
  before :all do
569
- @return = @resource = @articles.new
569
+ @source = @articles.new(:attachment => "A File")
570
+ @return = @resource = @articles.new(:original => @source)
570
571
  end
571
572
 
572
573
  it 'should return a Resource' do
@@ -584,6 +585,10 @@ share_examples_for 'A public Collection' do
584
585
  it 'should use the query conditions to set default values' do
585
586
  @resource.title.should == 'Sample Article'
586
587
  end
588
+
589
+ it 'should use the query conditions to set default values when accessed through a m:1 relationship' do
590
+ @resource.original.attachment.should == 'A File'
591
+ end
587
592
  end
588
593
 
589
594
  describe 'when scoped to the key' do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'AbstractAdapter' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
  require DataMapper.root / 'lib' / 'dm-core' / 'spec' / 'shared' / 'adapter_spec'
3
3
 
4
4
  describe 'Adapter' do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'Many to Many Associations' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'Many to One Associations' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'One to Many Associations' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'One to One Associations' do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Associations::Relationship do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Associations do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  # run the specs once with a loaded collection and once not
4
4
  [ false, true ].each do |loaded|
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Model do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Binary do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Boolean do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Class do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Date do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::DateTime do
4
4
  before :all do
@@ -1,11 +1,12 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Decimal do
4
4
  before :all do
5
- @name = :rate
6
- @type = DataMapper::Property::Decimal
7
- @value = BigDecimal('1.0')
8
- @other_value = BigDecimal('2.0')
5
+ @name = :rate
6
+ @type = DataMapper::Property::Decimal
7
+ @options = { :precision => 5, :scale => 2 }
8
+ @value = BigDecimal('1.0')
9
+ @other_value = BigDecimal('2.0')
9
10
  @invalid_value = true
10
11
  end
11
12
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Discriminator do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Float do
4
4
  before :all do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe DataMapper::Property::Integer do
4
4
  before :all do