jmonteiro-mongo_mapper 0.1.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.
Files changed (91) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +38 -0
  4. data/Rakefile +55 -0
  5. data/VERSION +1 -0
  6. data/bin/mmconsole +60 -0
  7. data/jmonteiro-mongo_mapper.gemspec +195 -0
  8. data/lib/mongo_mapper.rb +128 -0
  9. data/lib/mongo_mapper/descendant_appends.rb +44 -0
  10. data/lib/mongo_mapper/document.rb +402 -0
  11. data/lib/mongo_mapper/dynamic_finder.rb +74 -0
  12. data/lib/mongo_mapper/embedded_document.rb +61 -0
  13. data/lib/mongo_mapper/finder_options.rb +127 -0
  14. data/lib/mongo_mapper/plugins.rb +19 -0
  15. data/lib/mongo_mapper/plugins/associations.rb +104 -0
  16. data/lib/mongo_mapper/plugins/associations/base.rb +121 -0
  17. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +28 -0
  18. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +23 -0
  19. data/lib/mongo_mapper/plugins/associations/collection.rb +21 -0
  20. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +49 -0
  21. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +139 -0
  22. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +28 -0
  23. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +117 -0
  24. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +31 -0
  25. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +23 -0
  26. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +13 -0
  27. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +66 -0
  28. data/lib/mongo_mapper/plugins/associations/proxy.rb +118 -0
  29. data/lib/mongo_mapper/plugins/callbacks.rb +65 -0
  30. data/lib/mongo_mapper/plugins/clone.rb +13 -0
  31. data/lib/mongo_mapper/plugins/descendants.rb +16 -0
  32. data/lib/mongo_mapper/plugins/dirty.rb +119 -0
  33. data/lib/mongo_mapper/plugins/equality.rb +11 -0
  34. data/lib/mongo_mapper/plugins/identity_map.rb +66 -0
  35. data/lib/mongo_mapper/plugins/inspect.rb +14 -0
  36. data/lib/mongo_mapper/plugins/keys.rb +295 -0
  37. data/lib/mongo_mapper/plugins/logger.rb +17 -0
  38. data/lib/mongo_mapper/plugins/pagination.rb +85 -0
  39. data/lib/mongo_mapper/plugins/protected.rb +31 -0
  40. data/lib/mongo_mapper/plugins/rails.rb +80 -0
  41. data/lib/mongo_mapper/plugins/serialization.rb +109 -0
  42. data/lib/mongo_mapper/plugins/validations.rb +48 -0
  43. data/lib/mongo_mapper/support.rb +213 -0
  44. data/performance/read_write.rb +52 -0
  45. data/specs.watchr +51 -0
  46. data/test/NOTE_ON_TESTING +1 -0
  47. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +63 -0
  48. data/test/functional/associations/test_belongs_to_proxy.rb +93 -0
  49. data/test/functional/associations/test_in_array_proxy.rb +309 -0
  50. data/test/functional/associations/test_many_documents_as_proxy.rb +246 -0
  51. data/test/functional/associations/test_many_documents_proxy.rb +437 -0
  52. data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +175 -0
  53. data/test/functional/associations/test_many_embedded_proxy.rb +216 -0
  54. data/test/functional/associations/test_many_polymorphic_proxy.rb +340 -0
  55. data/test/functional/associations/test_one_proxy.rb +149 -0
  56. data/test/functional/test_associations.rb +44 -0
  57. data/test/functional/test_binary.rb +27 -0
  58. data/test/functional/test_callbacks.rb +81 -0
  59. data/test/functional/test_dirty.rb +156 -0
  60. data/test/functional/test_document.rb +1171 -0
  61. data/test/functional/test_embedded_document.rb +125 -0
  62. data/test/functional/test_identity_map.rb +233 -0
  63. data/test/functional/test_logger.rb +20 -0
  64. data/test/functional/test_modifiers.rb +252 -0
  65. data/test/functional/test_pagination.rb +93 -0
  66. data/test/functional/test_protected.rb +41 -0
  67. data/test/functional/test_string_id_compatibility.rb +67 -0
  68. data/test/functional/test_validations.rb +329 -0
  69. data/test/models.rb +232 -0
  70. data/test/support/custom_matchers.rb +55 -0
  71. data/test/support/timing.rb +16 -0
  72. data/test/test_helper.rb +60 -0
  73. data/test/unit/associations/test_base.rb +207 -0
  74. data/test/unit/associations/test_proxy.rb +103 -0
  75. data/test/unit/serializers/test_json_serializer.rb +189 -0
  76. data/test/unit/test_descendant_appends.rb +71 -0
  77. data/test/unit/test_document.rb +203 -0
  78. data/test/unit/test_dynamic_finder.rb +125 -0
  79. data/test/unit/test_embedded_document.rb +628 -0
  80. data/test/unit/test_finder_options.rb +325 -0
  81. data/test/unit/test_keys.rb +169 -0
  82. data/test/unit/test_mongo_mapper.rb +65 -0
  83. data/test/unit/test_pagination.rb +127 -0
  84. data/test/unit/test_plugins.rb +42 -0
  85. data/test/unit/test_rails.rb +139 -0
  86. data/test/unit/test_rails_compatibility.rb +42 -0
  87. data/test/unit/test_serialization.rb +51 -0
  88. data/test/unit/test_support.rb +350 -0
  89. data/test/unit/test_time_zones.rb +39 -0
  90. data/test/unit/test_validations.rb +492 -0
  91. metadata +260 -0
@@ -0,0 +1,232 @@
1
+ # custom type
2
+ class WindowSize
3
+ attr_reader :width, :height
4
+
5
+ def self.to_mongo(value)
6
+ value.to_a
7
+ end
8
+
9
+ def self.from_mongo(value)
10
+ value.is_a?(self) ? value : WindowSize.new(value)
11
+ end
12
+
13
+ def initialize(*args)
14
+ @width, @height = args.flatten
15
+ end
16
+
17
+ def to_a
18
+ [width, height]
19
+ end
20
+
21
+ def ==(other)
22
+ other.is_a?(self.class) && other.width == width && other.height == height
23
+ end
24
+ end
25
+
26
+ module AccountsExtensions
27
+ def inactive
28
+ all(:last_logged_in => nil)
29
+ end
30
+ end
31
+
32
+ class Post
33
+ include MongoMapper::Document
34
+
35
+ key :title, String
36
+ key :body, String
37
+
38
+ many :comments, :as => :commentable, :class_name => 'PostComment'
39
+
40
+ timestamps!
41
+ end
42
+
43
+ class PostComment
44
+ include MongoMapper::Document
45
+
46
+ key :username, String, :default => 'Anonymous'
47
+ key :body, String
48
+
49
+ key :commentable_id, ObjectId
50
+ key :commentable_type, String
51
+ belongs_to :commentable, :polymorphic => true
52
+
53
+ timestamps!
54
+ end
55
+
56
+ class Address
57
+ include MongoMapper::EmbeddedDocument
58
+
59
+ key :address, String
60
+ key :city, String
61
+ key :state, String
62
+ key :zip, Integer
63
+ end
64
+
65
+ class Message
66
+ include MongoMapper::Document
67
+
68
+ key :body, String
69
+ key :position, Integer
70
+ key :_type, String
71
+ key :room_id, ObjectId
72
+
73
+ belongs_to :room
74
+ end
75
+
76
+ class Enter < Message; end
77
+ class Exit < Message; end
78
+ class Chat < Message; end
79
+
80
+ class Room
81
+ include MongoMapper::Document
82
+
83
+ key :name, String
84
+ many :messages, :polymorphic => true, :order => 'position' do
85
+ def older
86
+ all(:position => {'$gt' => 5})
87
+ end
88
+ end
89
+ many :latest_messages, :class_name => 'Message', :order => 'position desc', :limit => 2
90
+
91
+ many :accounts, :polymorphic => true, :extend => AccountsExtensions
92
+ end
93
+
94
+ class Account
95
+ include MongoMapper::Document
96
+
97
+ key :_type, String
98
+ key :room_id, ObjectId
99
+ key :last_logged_in, Time
100
+
101
+ belongs_to :room
102
+ end
103
+ class AccountUser < Account; end
104
+ class Bot < Account; end
105
+
106
+ class Answer
107
+ include MongoMapper::Document
108
+
109
+ key :body, String
110
+ end
111
+
112
+ module CollaboratorsExtensions
113
+ def top
114
+ first
115
+ end
116
+ end
117
+
118
+ class Project
119
+ include MongoMapper::Document
120
+
121
+ key :name, String
122
+
123
+ many :collaborators, :extend => CollaboratorsExtensions
124
+ many :statuses, :order => 'position' do
125
+ def open
126
+ all(:name => %w(New Assigned))
127
+ end
128
+ end
129
+
130
+ many :addresses do
131
+ def find_all_by_state(state)
132
+ # can't use select here for some reason
133
+ find_all { |a| a.state == state }
134
+ end
135
+ end
136
+ end
137
+
138
+ class Collaborator
139
+ include MongoMapper::Document
140
+ key :project_id, ObjectId
141
+ key :name, String
142
+ belongs_to :project
143
+ end
144
+
145
+ class Status
146
+ include MongoMapper::Document
147
+
148
+ key :project_id, ObjectId
149
+ key :target_id, ObjectId
150
+ key :target_type, String
151
+ key :name, String, :required => true
152
+ key :position, Integer
153
+
154
+ belongs_to :project
155
+ belongs_to :target, :polymorphic => true
156
+ end
157
+
158
+ class Media
159
+ include MongoMapper::EmbeddedDocument
160
+
161
+ key :_type, String
162
+ key :file, String
163
+
164
+ key :visible, Boolean
165
+ end
166
+
167
+ class Video < Media
168
+ key :length, Integer
169
+ end
170
+
171
+ class Image < Media
172
+ key :width, Integer
173
+ key :height, Integer
174
+ end
175
+
176
+ class Music < Media
177
+ key :bitrate, String
178
+ end
179
+
180
+ class Catalog
181
+ include MongoMapper::Document
182
+
183
+ many :medias, :polymorphic => true do
184
+ def visible
185
+ # for some reason we can't use select here
186
+ find_all { |m| m.visible? }
187
+ end
188
+ end
189
+ end
190
+
191
+ module TrModels
192
+ class Transport
193
+ include MongoMapper::EmbeddedDocument
194
+
195
+ key :_type, String
196
+ key :license_plate, String
197
+ key :purchased_on, Date
198
+ end
199
+
200
+ class Car < TrModels::Transport
201
+ include MongoMapper::EmbeddedDocument
202
+
203
+ key :model, String
204
+ key :year, Integer
205
+ end
206
+
207
+ class Bus < TrModels::Transport
208
+ include MongoMapper::EmbeddedDocument
209
+
210
+ key :max_passengers, Integer
211
+ end
212
+
213
+ class Ambulance < TrModels::Transport
214
+ include MongoMapper::EmbeddedDocument
215
+
216
+ key :icu, Boolean
217
+ end
218
+
219
+ class Fleet
220
+ include MongoMapper::Document
221
+
222
+ module TransportsExtension
223
+ def to_be_replaced
224
+ # for some reason we can't use select
225
+ find_all { |t| t.purchased_on < 2.years.ago.to_date }
226
+ end
227
+ end
228
+
229
+ many :transports, :polymorphic => true, :class_name => "TrModels::Transport", :extend => TransportsExtension
230
+ key :name, String
231
+ end
232
+ end
@@ -0,0 +1,55 @@
1
+ module CustomMatchers
2
+ custom_matcher :be_nil do |receiver, matcher, args|
3
+ matcher.positive_failure_message = "Expected #{receiver} to be nil but it wasn't"
4
+ matcher.negative_failure_message = "Expected #{receiver} not to be nil but it was"
5
+ receiver.nil?
6
+ end
7
+
8
+ custom_matcher :be_blank do |receiver, matcher, args|
9
+ matcher.positive_failure_message = "Expected #{receiver} to be blank but it wasn't"
10
+ matcher.negative_failure_message = "Expected #{receiver} not to be blank but it was"
11
+ receiver.blank?
12
+ end
13
+
14
+ custom_matcher :be_true do |receiver, matcher, args|
15
+ matcher.positive_failure_message = "Expected #{receiver} to be true but it wasn't"
16
+ matcher.negative_failure_message = "Expected #{receiver} not to be true but it was"
17
+ receiver.eql?(true)
18
+ end
19
+
20
+ custom_matcher :be_false do |receiver, matcher, args|
21
+ matcher.positive_failure_message = "Expected #{receiver} to be false but it wasn't"
22
+ matcher.negative_failure_message = "Expected #{receiver} not to be false but it was"
23
+ receiver.eql?(false)
24
+ end
25
+
26
+ custom_matcher :be_valid do |receiver, matcher, args|
27
+ matcher.positive_failure_message = "Expected to be valid but it was invalid #{receiver.errors.inspect}"
28
+ matcher.negative_failure_message = "Expected to be invalid but it was valid #{receiver.errors.inspect}"
29
+ receiver.valid?
30
+ end
31
+
32
+ custom_matcher :have_error_on do |receiver, matcher, args|
33
+ receiver.valid?
34
+ attribute = args[0]
35
+ expected_message = args[1]
36
+
37
+ if expected_message.nil?
38
+ matcher.positive_failure_message = "#{receiver} had no errors on #{attribute}"
39
+ matcher.negative_failure_message = "#{receiver} had errors on #{attribute} #{receiver.errors.inspect}"
40
+ !receiver.errors.on(attribute).blank?
41
+ else
42
+ actual = receiver.errors.on(attribute)
43
+ matcher.positive_failure_message = %Q(Expected error on #{attribute} to be "#{expected_message}" but was "#{actual}")
44
+ matcher.negative_failure_message = %Q(Expected error on #{attribute} not to be "#{expected_message}" but was "#{actual}")
45
+ actual == expected_message
46
+ end
47
+ end
48
+
49
+ custom_matcher :have_index do |receiver, matcher, args|
50
+ index_name = args[0]
51
+ matcher.positive_failure_message = "#{receiver} does not have index named #{index_name}, but should"
52
+ matcher.negative_failure_message = "#{receiver} does have index named #{index_name}, but should not"
53
+ !receiver.collection.index_information.detect { |index| index[0] == index_name }.nil?
54
+ end
55
+ end
@@ -0,0 +1,16 @@
1
+ class Test::Unit::TestCase
2
+ def run_with_test_timing(*args, &block)
3
+ begin_time = Time.now
4
+ run_without_test_timing(*args, &block)
5
+ end_time = Time.now
6
+
7
+ duration = end_time - begin_time
8
+ threshold = 1.0
9
+
10
+ if duration > threshold
11
+ puts "\nSLOW TEST: #{duration} - #{self.name}"
12
+ end
13
+ end
14
+
15
+ alias_method_chain :run, :test_timing unless method_defined?(:run_without_test_timing)
16
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/mongo_mapper')
2
+
3
+ gem 'jnunemaker-matchy', '0.4.0'
4
+ gem 'shoulda', '2.10.2'
5
+ gem 'timecop', '0.3.1'
6
+ gem 'mocha', '0.9.8'
7
+
8
+ require 'matchy'
9
+ require 'shoulda'
10
+ require 'timecop'
11
+ require 'mocha'
12
+ require 'pp'
13
+
14
+ require 'support/custom_matchers'
15
+ require 'support/timing'
16
+
17
+ class Test::Unit::TestCase
18
+ include CustomMatchers
19
+
20
+ cattr_accessor :mm_document_count
21
+ self.mm_document_count = 0
22
+
23
+ def Doc(name=nil, &block)
24
+ Test::Unit::TestCase.mm_document_count += 1
25
+
26
+ klass = Class.new do
27
+ include MongoMapper::Document
28
+ set_collection_name "test#{rand(20)}"
29
+
30
+ if name
31
+ class_eval "def self.name; '#{name}' end"
32
+ class_eval "def self.to_s; '#{name}' end"
33
+ end
34
+ end
35
+ klass.class_eval(&block) if block_given?
36
+ klass.collection.remove
37
+ klass
38
+ end
39
+
40
+ def EDoc(name=nil, &block)
41
+ Class.new do
42
+ include MongoMapper::EmbeddedDocument
43
+
44
+ if name
45
+ class_eval "def self.name; '#{name}' end"
46
+ class_eval "def self.to_s; '#{name}' end"
47
+ end
48
+
49
+ class_eval(&block) if block_given?
50
+ end
51
+ end
52
+ end
53
+
54
+ test_dir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
55
+ FileUtils.mkdir_p(test_dir) unless File.exist?(test_dir)
56
+
57
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, {
58
+ :logger => Logger.new(test_dir + '/test.log')
59
+ })
60
+ MongoMapper.database = 'test'
@@ -0,0 +1,207 @@
1
+ require 'test_helper'
2
+ require 'models'
3
+
4
+ class FooMonster; end
5
+
6
+ class AssociationBaseTest < Test::Unit::TestCase
7
+ include MongoMapper::Plugins::Associations
8
+
9
+ should "initialize with type and name" do
10
+ base = Base.new(:many, :foos)
11
+ base.type.should == :many
12
+ base.name.should == :foos
13
+ end
14
+
15
+ should "also allow options when initializing" do
16
+ base = Base.new(:many, :foos, :polymorphic => true)
17
+ base.options[:polymorphic].should be_true
18
+ end
19
+
20
+ context "class_name" do
21
+ should "work for belongs_to" do
22
+ Base.new(:belongs_to, :user).class_name.should == 'User'
23
+ end
24
+
25
+ should "work for many" do
26
+ Base.new(:many, :smart_people).class_name.should == 'SmartPerson'
27
+ end
28
+
29
+ should "be changeable using class_name option" do
30
+ base = Base.new(:many, :smart_people, :class_name => 'IntelligentPerson')
31
+ base.class_name.should == 'IntelligentPerson'
32
+ end
33
+ end
34
+
35
+ context "klass" do
36
+ should "default to class_name constantized" do
37
+ Base.new(:belongs_to, :foo_monster).klass.should == FooMonster
38
+ end
39
+
40
+ should "be the specified class" do
41
+ anonnymous_class = Class.new
42
+ Base.new(:belongs_to, :foo_monster, :class => anonnymous_class).klass.should == anonnymous_class
43
+ end
44
+ end
45
+
46
+ context "many?" do
47
+ should "be true if many" do
48
+ Base.new(:many, :foos).many?.should be_true
49
+ end
50
+
51
+ should "be false if not many" do
52
+ Base.new(:belongs_to, :foo).many?.should be_false
53
+ Base.new(:one, :foo).many?.should be_false
54
+ end
55
+ end
56
+
57
+ context "one?" do
58
+ should "be true if one" do
59
+ Base.new(:one, :foo).one?.should be_true
60
+ end
61
+
62
+ should "be false if not one" do
63
+ Base.new(:many, :foo).one?.should be_false
64
+ end
65
+ end
66
+
67
+ context "belongs_to?" do
68
+ should "be true if belongs_to" do
69
+ Base.new(:belongs_to, :foo).belongs_to?.should be_true
70
+ end
71
+
72
+ should "be false if not belongs_to" do
73
+ Base.new(:many, :foos).belongs_to?.should be_false
74
+ end
75
+ end
76
+
77
+ context "polymorphic?" do
78
+ should "be true if polymorphic" do
79
+ Base.new(:many, :foos, :polymorphic => true).polymorphic?.should be_true
80
+ end
81
+
82
+ should "be false if not polymorphic" do
83
+ Base.new(:many, :bars).polymorphic?.should be_false
84
+ end
85
+ end
86
+
87
+ context "as?" do
88
+ should "be true if one" do
89
+ Base.new(:one, :foo, :as => :commentable).as?.should be_true
90
+ end
91
+
92
+ should "be false if not one" do
93
+ Base.new(:many, :foo).as?.should be_false
94
+ end
95
+ end
96
+
97
+ context "in_array?" do
98
+ should "be true if one" do
99
+ Base.new(:one, :foo, :in => :list_ids).in_array?.should be_true
100
+ end
101
+
102
+ should "be false if not one" do
103
+ Base.new(:many, :foo).in_array?.should be_false
104
+ end
105
+ end
106
+
107
+ context "finder_options" do
108
+ should "default to empty hash" do
109
+ base = Base.new(:many, :foos)
110
+ base.finder_options.should == {}
111
+ end
112
+
113
+ should "work with order" do
114
+ base = Base.new(:many, :foos, :order => 'position')
115
+ base.finder_options.should == {:order => 'position'}
116
+ end
117
+
118
+ should "correctly parse from options" do
119
+ base = Base.new(:many, :foos, :order => 'position', :somekey => 'somevalue')
120
+ base.finder_options.should == {:order => 'position', :somekey => 'somevalue'}
121
+ end
122
+ end
123
+
124
+ context "type_key_name" do
125
+ should "be _type for many" do
126
+ Base.new(:many, :foos).type_key_name.should == '_type'
127
+ end
128
+
129
+ should "be association name _ type for belongs_to" do
130
+ Base.new(:belongs_to, :foo).type_key_name.should == 'foo_type'
131
+ end
132
+ end
133
+
134
+ context "foreign_key" do
135
+ should "default to assocation name _id for belongs to" do
136
+ base = Base.new(:belongs_to, :foo)
137
+ base.foreign_key.should == 'foo_id'
138
+ end
139
+
140
+ should "be overridable with :foreign_key option" do
141
+ base = Base.new(:belongs_to, :foo, :foreign_key => 'foobar_id')
142
+ base.foreign_key.should == 'foobar_id'
143
+ end
144
+ end
145
+
146
+ should "have ivar that is association name" do
147
+ Base.new(:belongs_to, :foo).ivar.should == '@_foo'
148
+ end
149
+
150
+ context "embeddable?" do
151
+ should "be true if class is embeddable" do
152
+ base = Base.new(:many, :medias)
153
+ base.embeddable?.should be_true
154
+ end
155
+
156
+ should "be false if class is not embeddable" do
157
+ base = Base.new(:many, :statuses)
158
+ base.embeddable?.should be_false
159
+
160
+ base = Base.new(:belongs_to, :project)
161
+ base.embeddable?.should be_false
162
+ end
163
+ end
164
+
165
+ context "proxy_class" do
166
+ should "be ManyDocumentsProxy for many" do
167
+ base = Base.new(:many, :statuses)
168
+ base.proxy_class.should == ManyDocumentsProxy
169
+ end
170
+
171
+ should "be ManyPolymorphicProxy for polymorphic many" do
172
+ base = Base.new(:many, :messages, :polymorphic => true)
173
+ base.proxy_class.should == ManyPolymorphicProxy
174
+ end
175
+
176
+ should "be ManyEmbeddedProxy for many embedded" do
177
+ base = Base.new(:many, :medias)
178
+ base.proxy_class.should == ManyEmbeddedProxy
179
+ end
180
+
181
+ should "be ManyEmbeddedPolymorphicProxy for polymorphic many embedded" do
182
+ base = Base.new(:many, :medias, :polymorphic => true)
183
+ base.proxy_class.should == ManyEmbeddedPolymorphicProxy
184
+ end
185
+
186
+ should "be BelongsToProxy for belongs_to" do
187
+ base = Base.new(:belongs_to, :project)
188
+ base.proxy_class.should == BelongsToProxy
189
+ end
190
+
191
+ should "be BelongsToPolymorphicProxy for polymorphic belongs_to" do
192
+ base = Base.new(:belongs_to, :target, :polymorphic => true)
193
+ base.proxy_class.should == BelongsToPolymorphicProxy
194
+ end
195
+
196
+ should "be OneProxy for one" do
197
+ base = Base.new(:one, :target, :polymorphic => true)
198
+ base.proxy_class.should == OneProxy
199
+ end
200
+
201
+ should "be InArrayProxy for many with :in option" do
202
+ base = Base.new(:many, :messages, :in => :message_ids)
203
+ base.proxy_class.should == InArrayProxy
204
+ end
205
+ end
206
+
207
+ end