mongo_mapper_ign 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +35 -0
  4. data/Rakefile +37 -0
  5. data/bin/mmconsole +60 -0
  6. data/lib/mongo_mapper.rb +116 -0
  7. data/lib/mongo_mapper/document.rb +313 -0
  8. data/lib/mongo_mapper/embedded_document.rb +70 -0
  9. data/lib/mongo_mapper/plugins.rb +35 -0
  10. data/lib/mongo_mapper/plugins/associations.rb +114 -0
  11. data/lib/mongo_mapper/plugins/associations/base.rb +123 -0
  12. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +30 -0
  13. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +25 -0
  14. data/lib/mongo_mapper/plugins/associations/collection.rb +21 -0
  15. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +39 -0
  16. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +144 -0
  17. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +28 -0
  18. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +129 -0
  19. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +31 -0
  20. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +23 -0
  21. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +13 -0
  22. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +41 -0
  23. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +69 -0
  24. data/lib/mongo_mapper/plugins/associations/proxy.rb +124 -0
  25. data/lib/mongo_mapper/plugins/callbacks.rb +240 -0
  26. data/lib/mongo_mapper/plugins/clone.rb +13 -0
  27. data/lib/mongo_mapper/plugins/descendants.rb +16 -0
  28. data/lib/mongo_mapper/plugins/dirty.rb +119 -0
  29. data/lib/mongo_mapper/plugins/equality.rb +23 -0
  30. data/lib/mongo_mapper/plugins/identity_map.rb +122 -0
  31. data/lib/mongo_mapper/plugins/inspect.rb +14 -0
  32. data/lib/mongo_mapper/plugins/keys.rb +345 -0
  33. data/lib/mongo_mapper/plugins/logger.rb +17 -0
  34. data/lib/mongo_mapper/plugins/modifiers.rb +107 -0
  35. data/lib/mongo_mapper/plugins/pagination.rb +24 -0
  36. data/lib/mongo_mapper/plugins/pagination/proxy.rb +72 -0
  37. data/lib/mongo_mapper/plugins/persistence.rb +68 -0
  38. data/lib/mongo_mapper/plugins/protected.rb +45 -0
  39. data/lib/mongo_mapper/plugins/rails.rb +57 -0
  40. data/lib/mongo_mapper/plugins/serialization.rb +91 -0
  41. data/lib/mongo_mapper/plugins/serialization/array.rb +56 -0
  42. data/lib/mongo_mapper/plugins/serialization/xml_serializer.rb +240 -0
  43. data/lib/mongo_mapper/plugins/timestamps.rb +21 -0
  44. data/lib/mongo_mapper/plugins/userstamps.rb +14 -0
  45. data/lib/mongo_mapper/plugins/validations.rb +46 -0
  46. data/lib/mongo_mapper/query.rb +143 -0
  47. data/lib/mongo_mapper/support.rb +218 -0
  48. data/lib/mongo_mapper/support/descendant_appends.rb +46 -0
  49. data/lib/mongo_mapper/support/find.rb +77 -0
  50. data/lib/mongo_mapper/version.rb +3 -0
  51. data/mongo_mapper.gemspec +214 -0
  52. data/mongo_mapper_ign.gemspec +217 -0
  53. data/performance/read_write.rb +52 -0
  54. data/specs.watchr +51 -0
  55. data/test/NOTE_ON_TESTING +1 -0
  56. data/test/active_model_lint_test.rb +13 -0
  57. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +63 -0
  58. data/test/functional/associations/test_belongs_to_proxy.rb +101 -0
  59. data/test/functional/associations/test_in_array_proxy.rb +325 -0
  60. data/test/functional/associations/test_many_documents_as_proxy.rb +229 -0
  61. data/test/functional/associations/test_many_documents_proxy.rb +536 -0
  62. data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +176 -0
  63. data/test/functional/associations/test_many_embedded_proxy.rb +256 -0
  64. data/test/functional/associations/test_many_polymorphic_proxy.rb +302 -0
  65. data/test/functional/associations/test_one_embedded_proxy.rb +68 -0
  66. data/test/functional/associations/test_one_proxy.rb +196 -0
  67. data/test/functional/test_associations.rb +44 -0
  68. data/test/functional/test_binary.rb +27 -0
  69. data/test/functional/test_callbacks.rb +151 -0
  70. data/test/functional/test_dirty.rb +163 -0
  71. data/test/functional/test_document.rb +1219 -0
  72. data/test/functional/test_embedded_document.rb +210 -0
  73. data/test/functional/test_identity_map.rb +507 -0
  74. data/test/functional/test_indexing.rb +44 -0
  75. data/test/functional/test_logger.rb +20 -0
  76. data/test/functional/test_modifiers.rb +394 -0
  77. data/test/functional/test_pagination.rb +93 -0
  78. data/test/functional/test_protected.rb +163 -0
  79. data/test/functional/test_string_id_compatibility.rb +67 -0
  80. data/test/functional/test_timestamps.rb +64 -0
  81. data/test/functional/test_userstamps.rb +28 -0
  82. data/test/functional/test_validations.rb +342 -0
  83. data/test/models.rb +227 -0
  84. data/test/support/custom_matchers.rb +37 -0
  85. data/test/support/timing.rb +16 -0
  86. data/test/test_helper.rb +64 -0
  87. data/test/unit/associations/test_base.rb +212 -0
  88. data/test/unit/associations/test_proxy.rb +105 -0
  89. data/test/unit/serializers/test_json_serializer.rb +202 -0
  90. data/test/unit/test_descendant_appends.rb +71 -0
  91. data/test/unit/test_document.rb +225 -0
  92. data/test/unit/test_dynamic_finder.rb +123 -0
  93. data/test/unit/test_embedded_document.rb +657 -0
  94. data/test/unit/test_keys.rb +185 -0
  95. data/test/unit/test_mongo_mapper.rb +118 -0
  96. data/test/unit/test_pagination.rb +160 -0
  97. data/test/unit/test_plugins.rb +50 -0
  98. data/test/unit/test_query.rb +374 -0
  99. data/test/unit/test_rails.rb +181 -0
  100. data/test/unit/test_rails_compatibility.rb +52 -0
  101. data/test/unit/test_serialization.rb +51 -0
  102. data/test/unit/test_support.rb +382 -0
  103. data/test/unit/test_time_zones.rb +39 -0
  104. data/test/unit/test_validations.rb +544 -0
  105. metadata +327 -0
@@ -0,0 +1,227 @@
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 :room_id, ObjectId
71
+
72
+ belongs_to :room
73
+ end
74
+
75
+ class Enter < Message; end
76
+ class Exit < Message; end
77
+ class Chat < Message; end
78
+
79
+ class Room
80
+ include MongoMapper::Document
81
+
82
+ key :name, String
83
+ many :messages, :polymorphic => true, :order => 'position' do
84
+ def older
85
+ all(:position => {'$gt' => 5})
86
+ end
87
+ end
88
+ many :latest_messages, :class_name => 'Message', :order => 'position desc', :limit => 2
89
+
90
+ many :accounts, :polymorphic => true, :extend => AccountsExtensions
91
+ end
92
+
93
+ class Account
94
+ include MongoMapper::Document
95
+
96
+ key :room_id, ObjectId
97
+ key :last_logged_in, Time
98
+
99
+ belongs_to :room
100
+ end
101
+ class AccountUser < Account; end
102
+ class Bot < Account; end
103
+
104
+ class Answer
105
+ include MongoMapper::Document
106
+
107
+ key :body, String
108
+ end
109
+
110
+ module CollaboratorsExtensions
111
+ def top
112
+ first
113
+ end
114
+ end
115
+
116
+ class Project
117
+ include MongoMapper::Document
118
+
119
+ key :name, String
120
+
121
+ many :collaborators, :extend => CollaboratorsExtensions
122
+ many :statuses, :order => 'position' do
123
+ def open
124
+ all(:name => %w(New Assigned))
125
+ end
126
+ end
127
+
128
+ many :addresses do
129
+ def find_all_by_state(state)
130
+ # can't use select here for some reason
131
+ find_all { |a| a.state == state }
132
+ end
133
+ end
134
+ end
135
+
136
+ class Collaborator
137
+ include MongoMapper::Document
138
+ key :project_id, ObjectId
139
+ key :name, String
140
+ belongs_to :project
141
+ end
142
+
143
+ class Status
144
+ include MongoMapper::Document
145
+
146
+ key :project_id, ObjectId
147
+ key :target_id, ObjectId
148
+ key :target_type, String
149
+ key :name, String, :required => true
150
+ key :position, Integer
151
+
152
+ belongs_to :project
153
+ belongs_to :target, :polymorphic => true
154
+ end
155
+
156
+ class Media
157
+ include MongoMapper::EmbeddedDocument
158
+
159
+ key :file, String
160
+ key :visible, Boolean
161
+ end
162
+
163
+ class Video < Media
164
+ key :length, Integer
165
+ end
166
+
167
+ class Image < Media
168
+ key :width, Integer
169
+ key :height, Integer
170
+ end
171
+
172
+ class Music < Media
173
+ key :bitrate, String
174
+ end
175
+
176
+ class Catalog
177
+ include MongoMapper::Document
178
+
179
+ many :medias, :polymorphic => true do
180
+ def visible
181
+ # for some reason we can't use select here
182
+ find_all { |m| m.visible? }
183
+ end
184
+ end
185
+ end
186
+
187
+ module TrModels
188
+ class Transport
189
+ include MongoMapper::EmbeddedDocument
190
+
191
+ key :license_plate, String
192
+ key :purchased_on, Date
193
+ end
194
+
195
+ class Car < TrModels::Transport
196
+ include MongoMapper::EmbeddedDocument
197
+
198
+ key :model, String
199
+ key :year, Integer
200
+ end
201
+
202
+ class Bus < TrModels::Transport
203
+ include MongoMapper::EmbeddedDocument
204
+
205
+ key :max_passengers, Integer
206
+ end
207
+
208
+ class Ambulance < TrModels::Transport
209
+ include MongoMapper::EmbeddedDocument
210
+
211
+ key :icu, Boolean
212
+ end
213
+
214
+ class Fleet
215
+ include MongoMapper::Document
216
+
217
+ module TransportsExtension
218
+ def to_be_replaced
219
+ # for some reason we can't use select
220
+ find_all { |t| t.purchased_on < 2.years.ago.to_date }
221
+ end
222
+ end
223
+
224
+ many :transports, :polymorphic => true, :class_name => "TrModels::Transport", :extend => TransportsExtension
225
+ key :name, String
226
+ end
227
+ end
@@ -0,0 +1,37 @@
1
+ module CustomMatchers
2
+ custom_matcher :be_true do |receiver, matcher, args|
3
+ matcher.positive_failure_message = "Expected #{receiver} to be true but it wasn't"
4
+ matcher.negative_failure_message = "Expected #{receiver} not to be true but it was"
5
+ receiver.eql?(true)
6
+ end
7
+
8
+ custom_matcher :be_false do |receiver, matcher, args|
9
+ matcher.positive_failure_message = "Expected #{receiver} to be false but it wasn't"
10
+ matcher.negative_failure_message = "Expected #{receiver} not to be false but it was"
11
+ receiver.eql?(false)
12
+ end
13
+
14
+ custom_matcher :have_error_on do |receiver, matcher, args|
15
+ receiver.valid?
16
+ attribute = args[0]
17
+ expected_message = args[1]
18
+
19
+ if expected_message.nil?
20
+ matcher.positive_failure_message = "#{receiver} had no errors on #{attribute}"
21
+ matcher.negative_failure_message = "#{receiver} had errors on #{attribute} #{receiver.errors.inspect}"
22
+ !receiver.errors.on(attribute).blank?
23
+ else
24
+ actual = receiver.errors.on(attribute)
25
+ matcher.positive_failure_message = %Q(Expected error on #{attribute} to be "#{expected_message}" but was "#{actual}")
26
+ matcher.negative_failure_message = %Q(Expected error on #{attribute} not to be "#{expected_message}" but was "#{actual}")
27
+ actual == expected_message
28
+ end
29
+ end
30
+
31
+ custom_matcher :have_index do |receiver, matcher, args|
32
+ index_name = args[0]
33
+ matcher.positive_failure_message = "#{receiver} does not have index named #{index_name}, but should"
34
+ matcher.negative_failure_message = "#{receiver} does have index named #{index_name}, but should not"
35
+ !receiver.collection.index_information.detect { |index| index[0] == index_name }.nil?
36
+ end
37
+ 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 = 5.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,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/mongo_mapper')
2
+ require 'fileutils'
3
+
4
+ gem 'jnunemaker-matchy', '0.4.0'
5
+ gem 'shoulda', '2.10.2'
6
+ gem 'json', '>= 1.2.3'
7
+ gem 'timecop', '0.3.1'
8
+ gem 'mocha', '0.9.8'
9
+
10
+ require 'shoulda'
11
+ require 'timecop'
12
+ require 'matchy'
13
+ require 'mocha'
14
+ require 'json'
15
+ require 'pp'
16
+
17
+ require 'support/custom_matchers'
18
+ require 'support/timing'
19
+
20
+ class Test::Unit::TestCase
21
+ include CustomMatchers
22
+
23
+ def Doc(name=nil, &block)
24
+ klass = Class.new do
25
+ include MongoMapper::Document
26
+ set_collection_name "test#{rand(20)}"
27
+
28
+ if name
29
+ class_eval "def self.name; '#{name}' end"
30
+ class_eval "def self.to_s; '#{name}' end"
31
+ end
32
+ end
33
+
34
+ klass.class_eval(&block) if block_given?
35
+ klass.collection.remove
36
+ klass
37
+ end
38
+
39
+ def EDoc(name=nil, &block)
40
+ klass = Class.new do
41
+ include MongoMapper::EmbeddedDocument
42
+
43
+ if name
44
+ class_eval "def self.name; '#{name}' end"
45
+ class_eval "def self.to_s; '#{name}' end"
46
+ end
47
+ end
48
+
49
+ klass.class_eval(&block) if block_given?
50
+ klass
51
+ end
52
+
53
+ def drop_indexes(klass)
54
+ if klass.database.collection_names.include?(klass.collection.name)
55
+ klass.collection.drop_indexes
56
+ end
57
+ end
58
+ end
59
+
60
+ test_dir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
61
+ FileUtils.mkdir_p(test_dir) unless File.exist?(test_dir)
62
+
63
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, {:logger => Logger.new(test_dir + '/test.log')})
64
+ MongoMapper.database = 'test'
@@ -0,0 +1,212 @@
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 "query_options" do
108
+ should "default to empty hash" do
109
+ base = Base.new(:many, :foos)
110
+ base.query_options.should == {}
111
+ end
112
+
113
+ should "work with order" do
114
+ base = Base.new(:many, :foos, :order => 'position')
115
+ base.query_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.query_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, :status, :polymorphic => true)
198
+ base.proxy_class.should == OneProxy
199
+ end
200
+
201
+ should "be OneEmbeddedProxy for one embedded" do
202
+ base = Base.new(:one, :media)
203
+ base.proxy_class.should == OneEmbeddedProxy
204
+ end
205
+
206
+ should "be InArrayProxy for many with :in option" do
207
+ base = Base.new(:many, :messages, :in => :message_ids)
208
+ base.proxy_class.should == InArrayProxy
209
+ end
210
+ end
211
+
212
+ end