couchrest_model 1.1.0.rc1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/README.md +4 -0
  2. data/VERSION +1 -1
  3. data/couchrest_model.gemspec +1 -1
  4. data/history.md +13 -1
  5. data/lib/couchrest/model/associations.rb +4 -4
  6. data/lib/couchrest/model/base.rb +25 -7
  7. data/lib/couchrest/model/callbacks.rb +13 -11
  8. data/lib/couchrest/model/{casted_model.rb → embeddable.rb} +22 -17
  9. data/lib/couchrest/model/persistence.rb +6 -1
  10. data/lib/couchrest/model/properties.rb +22 -34
  11. data/lib/couchrest/model/property.rb +1 -1
  12. data/lib/couchrest/model/validations.rb +19 -8
  13. data/lib/couchrest/railtie.rb +6 -3
  14. data/lib/couchrest_model.rb +2 -3
  15. data/lib/rails/generators/couchrest_model/config/config_generator.rb +18 -0
  16. data/lib/rails/generators/couchrest_model/config/templates/couchdb.yml +21 -0
  17. data/spec/fixtures/{more → models}/article.rb +0 -0
  18. data/spec/fixtures/{base.rb → models/base.rb} +11 -0
  19. data/spec/fixtures/{more → models}/card.rb +2 -0
  20. data/spec/fixtures/{more → models}/cat.rb +2 -2
  21. data/spec/fixtures/{more → models}/client.rb +0 -0
  22. data/spec/fixtures/{more → models}/course.rb +2 -2
  23. data/spec/fixtures/{more → models}/event.rb +0 -0
  24. data/spec/fixtures/{more → models}/invoice.rb +2 -2
  25. data/spec/fixtures/{more → models}/key_chain.rb +0 -0
  26. data/spec/fixtures/models/membership.rb +4 -0
  27. data/spec/fixtures/{more → models}/person.rb +4 -2
  28. data/spec/fixtures/models/project.rb +6 -0
  29. data/spec/fixtures/models/question.rb +7 -0
  30. data/spec/fixtures/{more → models}/sale_entry.rb +0 -0
  31. data/spec/fixtures/{more → models}/sale_invoice.rb +5 -4
  32. data/spec/fixtures/{more → models}/service.rb +0 -0
  33. data/spec/fixtures/{more → models}/user.rb +0 -0
  34. data/spec/functional/validations_spec.rb +8 -0
  35. data/spec/spec_helper.rb +23 -14
  36. data/spec/unit/active_model_lint_spec.rb +30 -0
  37. data/spec/{couchrest → unit}/assocations_spec.rb +1 -3
  38. data/spec/{couchrest → unit}/attachment_spec.rb +1 -1
  39. data/spec/{couchrest → unit}/base_spec.rb +59 -10
  40. data/spec/{couchrest → unit}/casted_spec.rb +1 -4
  41. data/spec/{couchrest → unit}/class_proxy_spec.rb +1 -1
  42. data/spec/{couchrest → unit}/collection_spec.rb +1 -2
  43. data/spec/{couchrest → unit}/configuration_spec.rb +2 -3
  44. data/spec/{couchrest → unit}/connection_spec.rb +2 -2
  45. data/spec/{couchrest → unit}/core_extensions/time_parsing.rb +0 -0
  46. data/spec/{couchrest → unit}/design_doc_spec.rb +2 -5
  47. data/spec/{couchrest → unit}/designs/view_spec.rb +0 -0
  48. data/spec/{couchrest → unit}/designs_spec.rb +2 -3
  49. data/spec/{couchrest → unit}/dirty_spec.rb +2 -8
  50. data/spec/{couchrest/casted_model_spec.rb → unit/embeddable_spec.rb} +49 -26
  51. data/spec/{couchrest → unit}/inherited_spec.rb +1 -1
  52. data/spec/{couchrest → unit}/persistence_spec.rb +23 -8
  53. data/spec/{couchrest → unit}/property_protection_spec.rb +1 -1
  54. data/spec/{couchrest → unit}/property_spec.rb +3 -14
  55. data/spec/{couchrest → unit}/proxyable_spec.rb +2 -4
  56. data/spec/{couchrest → unit}/subclass_spec.rb +1 -5
  57. data/spec/{couchrest → unit}/typecast_spec.rb +1 -4
  58. data/spec/{couchrest → unit}/validations_spec.rb +2 -10
  59. data/spec/{couchrest → unit}/view_spec.rb +2 -7
  60. metadata +49 -91
  61. data/spec/fixtures/more/question.rb +0 -7
data/README.md CHANGED
@@ -70,6 +70,10 @@ The example config above for example would use a database called "project_test".
70
70
 
71
71
  ## Generators
72
72
 
73
+ ### Configuration
74
+
75
+ $ rails generate couchrest_model:config
76
+
73
77
  ### Model
74
78
 
75
79
  $ rails generate model person --orm=couchrest_model
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0.rc1
1
+ 1.1.0
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
24
  s.require_paths = ["lib"]
25
25
 
26
- s.add_dependency(%q<couchrest>, "1.1.0.pre3")
26
+ s.add_dependency(%q<couchrest>, "1.1.0")
27
27
  s.add_dependency(%q<mime-types>, "~> 1.15")
28
28
  s.add_dependency(%q<activemodel>, "~> 3.0")
29
29
  s.add_dependency(%q<tzinfo>, "~> 0.3.22")
data/history.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # CouchRest Model Change History
2
2
 
3
- ## 1.1.0.rc - 2011-06-08
3
+ ## 1.1.0 - 2011-06-25
4
+
5
+ * Major Alterations
6
+ * CastedModel no longer requires a Hash. Automatically includes all required methods.
7
+ * CastedModel module renamed to Embeddable (old still works!)
8
+
9
+ * Minor Fixes
10
+ * Validation callbacks now support context (thanks kostia)
11
+ * Document comparisons now performed using database and document ID (pointer by neocsr)
12
+ * Automatic config generation now supported (thanks lucasrenan)
13
+ * Comparing documents resorts to Hash comparison if both IDs are nil. (pointer by kostia)
14
+
15
+ ## 1.1.0.rc1 - 2011-06-08
4
16
 
5
17
  * New Features
6
18
  * Properties with a nil value are now no longer sent to the database.
@@ -183,19 +183,19 @@ module CouchRest
183
183
  casted_by[casted_by_property.to_s] << obj.id
184
184
  end
185
185
  end
186
-
186
+
187
187
  def << obj
188
188
  check_obj(obj)
189
189
  casted_by[casted_by_property.to_s] << obj.id
190
190
  super(obj)
191
191
  end
192
-
192
+
193
193
  def push(obj)
194
194
  check_obj(obj)
195
195
  casted_by[casted_by_property.to_s].push obj.id
196
196
  super(obj)
197
197
  end
198
-
198
+
199
199
  def unshift(obj)
200
200
  check_obj(obj)
201
201
  casted_by[casted_by_property.to_s].unshift obj.id
@@ -212,7 +212,7 @@ module CouchRest
212
212
  casted_by[casted_by_property.to_s].pop
213
213
  super
214
214
  end
215
-
215
+
216
216
  def shift
217
217
  casted_by[casted_by_property.to_s].shift
218
218
  super
@@ -7,7 +7,6 @@ module CouchRest
7
7
  include CouchRest::Model::Configuration
8
8
  include CouchRest::Model::Connection
9
9
  include CouchRest::Model::Persistence
10
- include CouchRest::Model::Callbacks
11
10
  include CouchRest::Model::DocumentQueries
12
11
  include CouchRest::Model::Views
13
12
  include CouchRest::Model::DesignDoc
@@ -18,9 +17,11 @@ module CouchRest
18
17
  include CouchRest::Model::PropertyProtection
19
18
  include CouchRest::Model::Associations
20
19
  include CouchRest::Model::Validations
20
+ include CouchRest::Model::Callbacks
21
21
  include CouchRest::Model::Designs
22
22
  include CouchRest::Model::CastedBy
23
23
  include CouchRest::Model::Dirty
24
+ include CouchRest::Model::Callbacks
24
25
 
25
26
  def self.subclasses
26
27
  @subclasses ||= []
@@ -46,8 +47,8 @@ module CouchRest
46
47
  #
47
48
  # Options supported:
48
49
  #
49
- # * :directly_set_attributes: true when data comes directly from database
50
- # * :database: provide an alternative database
50
+ # * :directly_set_attributes, true when data comes directly from database
51
+ # * :database, provide an alternative database
51
52
  #
52
53
  # If a block is provided the new model will be passed into the
53
54
  # block so that it can be populated.
@@ -63,6 +64,7 @@ module CouchRest
63
64
  yield self if block_given?
64
65
 
65
66
  after_initialize if respond_to?(:after_initialize)
67
+ run_callbacks(:initialize) { self }
66
68
  end
67
69
 
68
70
 
@@ -80,10 +82,6 @@ module CouchRest
80
82
  super
81
83
  end
82
84
 
83
- def persisted?
84
- !new?
85
- end
86
-
87
85
  def to_key
88
86
  new? ? nil : [id]
89
87
  end
@@ -91,6 +89,26 @@ module CouchRest
91
89
  alias :to_param :id
92
90
  alias :new_record? :new?
93
91
  alias :new_document? :new?
92
+
93
+ # Compare this model with another by confirming to see
94
+ # if the IDs and their databases match!
95
+ #
96
+ # Camparison of the database is required in case the
97
+ # model has been proxied or loaded elsewhere.
98
+ #
99
+ # A Basic CouchRest document will only ever compare using
100
+ # a Hash comparison on the attributes.
101
+ def == other
102
+ return false unless other.is_a?(Base)
103
+ if id.nil? && other.id.nil?
104
+ # no ids? assume comparing nested and revert to hash comparison
105
+ to_hash == other.to_hash
106
+ else
107
+ database == other.database && id == other.id
108
+ end
109
+ end
110
+ alias :eql? :==
111
+
94
112
  end
95
113
  end
96
114
  end
@@ -5,21 +5,23 @@ module CouchRest #:nodoc:
5
5
 
6
6
  module Callbacks
7
7
  extend ActiveSupport::Concern
8
- included do
9
- extend ActiveModel::Callbacks
10
8
 
11
- define_model_callbacks \
12
- :create,
13
- :destroy,
14
- :save,
15
- :update
9
+ CALLBACKS = [
10
+ :before_validation, :after_validation,
11
+ :after_initialize,
12
+ :before_create, :around_create, :after_create,
13
+ :before_destroy, :around_destroy, :after_destroy,
14
+ :before_save, :around_save, :after_save,
15
+ :before_update, :around_update, :after_update,
16
+ ]
16
17
 
17
- end
18
+ included do
19
+ extend ActiveModel::Callbacks
20
+ include ActiveModel::Validations::Callbacks
18
21
 
19
- def valid?(*) #nodoc
20
- _run_validation_callbacks { super }
22
+ define_model_callbacks :initialize, :only => :after
23
+ define_model_callbacks :create, :destroy, :save, :update
21
24
  end
22
-
23
25
  end
24
26
 
25
27
  end
@@ -1,37 +1,34 @@
1
1
  module CouchRest::Model
2
- module CastedModel
3
-
2
+ module Embeddable
4
3
  extend ActiveSupport::Concern
5
4
 
6
5
  included do
6
+ include CouchRest::Attributes
7
7
  include CouchRest::Model::Configuration
8
- include CouchRest::Model::Callbacks
9
8
  include CouchRest::Model::Properties
10
9
  include CouchRest::Model::PropertyProtection
11
10
  include CouchRest::Model::Associations
12
11
  include CouchRest::Model::Validations
12
+ include CouchRest::Model::Callbacks
13
13
  include CouchRest::Model::CastedBy
14
14
  include CouchRest::Model::Dirty
15
+ include CouchRest::Model::Callbacks
16
+
15
17
  class_eval do
16
18
  # Override CastedBy's base_doc?
17
19
  def base_doc?
18
20
  false # Can never be base doc!
19
21
  end
20
- end
21
- end
22
-
23
- def initialize(keys = {})
24
- raise StandardError unless self.is_a? Hash
25
- prepare_all_attributes(keys)
26
- super()
27
- end
28
22
 
29
- def []= key, value
30
- super(key.to_s, value)
31
- end
32
-
33
- def [] key
34
- super(key.to_s)
23
+ # Initialize a new Casted Model. Accepts the same
24
+ # options as CouchRest::Model::Base for preparing and initializing
25
+ # attributes.
26
+ def initialize(keys = {}, options = {})
27
+ super()
28
+ prepare_all_attributes(keys, options)
29
+ run_callbacks(:initialize) { self }
30
+ end
31
+ end
35
32
  end
36
33
 
37
34
  # False if the casted model has already
@@ -65,6 +62,14 @@ module CouchRest::Model
65
62
  end
66
63
  alias :attributes= :update_attributes_without_saving
67
64
 
65
+ end # End Embeddable
66
+
67
+ # Provide backwards compatability with previous versions (pre 1.1.0)
68
+ module CastedModel
69
+ extend ActiveSupport::Concern
70
+ included do
71
+ include CouchRest::Model::Embeddable
72
+ end
68
73
  end
69
74
 
70
75
  end
@@ -28,7 +28,8 @@ module CouchRest
28
28
  # Trigger the callbacks (before, after, around)
29
29
  # only if the document isn't new
30
30
  def update(options = {})
31
- raise "Calling #{self.class.name}#update on document that has not been created!" if self.new?
31
+ raise "Cannot save a destroyed document!" if destroyed?
32
+ raise "Calling #{self.class.name}#update on document that has not been created!" if new?
32
33
  return false unless perform_validations(options)
33
34
  return true if !self.disable_dirty && !self.changed?
34
35
  _run_update_callbacks do
@@ -69,6 +70,10 @@ module CouchRest
69
70
  !!@_destroyed
70
71
  end
71
72
 
73
+ def persisted?
74
+ !new? && !destroyed?
75
+ end
76
+
72
77
  # Update the document's attributes and save. For example:
73
78
  #
74
79
  # doc.update_attributes :name => "Fred"
@@ -149,15 +149,13 @@ module CouchRest
149
149
  # These properties are casted as Time objects, so they should always
150
150
  # be set to UTC.
151
151
  def timestamps!
152
- class_eval <<-EOS, __FILE__, __LINE__
153
- property(:updated_at, Time, :read_only => true, :protected => true, :auto_validation => false)
154
- property(:created_at, Time, :read_only => true, :protected => true, :auto_validation => false)
152
+ property(:updated_at, Time, :read_only => true, :protected => true, :auto_validation => false)
153
+ property(:created_at, Time, :read_only => true, :protected => true, :auto_validation => false)
155
154
 
156
- set_callback :save, :before do |object|
157
- write_attribute('updated_at', Time.now)
158
- write_attribute('created_at', Time.now) if object.new?
159
- end
160
- EOS
155
+ set_callback :save, :before do |object|
156
+ write_attribute('updated_at', Time.now)
157
+ write_attribute('created_at', Time.now) if object.new?
158
+ end
161
159
  end
162
160
 
163
161
  protected
@@ -168,8 +166,8 @@ module CouchRest
168
166
  # check if this property is going to casted
169
167
  type = options.delete(:type) || options.delete(:cast_as)
170
168
  if block_given?
171
- type = Class.new(Hash) do
172
- include CastedModel
169
+ type = Class.new do
170
+ include Embeddable
173
171
  end
174
172
  if block.arity == 1 # Traditional, with options
175
173
  type.class_eval { yield type }
@@ -191,42 +189,32 @@ module CouchRest
191
189
 
192
190
  # defines the getter for the property (and optional aliases)
193
191
  def create_property_getter(property)
194
- # meth = property.name
195
- class_eval <<-EOS, __FILE__, __LINE__ + 1
196
- def #{property.name}
197
- read_attribute('#{property.name}')
198
- end
199
- EOS
192
+ define_method(property.name) do
193
+ read_attribute(property.name)
194
+ end
200
195
 
201
196
  if ['boolean', TrueClass.to_s.downcase].include?(property.type.to_s.downcase)
202
- class_eval <<-EOS, __FILE__, __LINE__
203
- def #{property.name}?
204
- value = read_attribute('#{property.name}')
205
- !(value.nil? || value == false)
206
- end
207
- EOS
197
+ define_method("#{property.name}?") do
198
+ value = read_attribute(property.name)
199
+ !(value.nil? || value == false)
200
+ end
208
201
  end
209
202
 
210
203
  if property.alias
211
- class_eval <<-EOS, __FILE__, __LINE__ + 1
212
- alias #{property.alias.to_sym} #{property.name.to_sym}
213
- EOS
204
+ alias_method(property.alias, property.name.to_sym)
214
205
  end
215
206
  end
216
207
 
217
208
  # defines the setter for the property (and optional aliases)
218
209
  def create_property_setter(property)
219
- property_name = property.name
220
- class_eval <<-EOS
221
- def #{property_name}=(value)
222
- write_attribute('#{property_name}', value)
223
- end
224
- EOS
210
+ name = property.name
211
+
212
+ define_method("#{name}=") do |value|
213
+ write_attribute(name, value)
214
+ end
225
215
 
226
216
  if property.alias
227
- class_eval <<-EOS
228
- alias #{property.alias.to_sym}= #{property_name.to_sym}=
229
- EOS
217
+ alias_method "#{property.alias}=", "#{name}="
230
218
  end
231
219
  end
232
220
 
@@ -45,7 +45,7 @@ module CouchRest::Model
45
45
 
46
46
  # Cast an individual value, not an array
47
47
  def cast_value(parent, value)
48
- raise "An array inside an array cannot be casted, use CastedModel" if value.is_a?(Array)
48
+ raise "An array inside an array cannot be casted, use Embeddable module" if value.is_a?(Array)
49
49
  value = typecast_value(value, self)
50
50
  associate_casted_value_to_parent(parent, value)
51
51
  end
@@ -13,22 +13,33 @@ module CouchRest
13
13
  # Validations may be applied to both Model::Base and Model::CastedModel
14
14
  module Validations
15
15
  extend ActiveSupport::Concern
16
- included do
17
- include ActiveModel::Validations
18
- include ActiveModel::Validations::Callbacks
16
+ include ActiveModel::Validations
17
+
18
+ # Determine if the document is valid.
19
+ #
20
+ # @example Is the document valid?
21
+ # person.valid?
22
+ #
23
+ # @example Is the document valid in a context?
24
+ # person.valid?(:create)
25
+ #
26
+ # @param [ Symbol ] context The optional validation context.
27
+ #
28
+ # @return [ true, false ] True if valid, false if not.
29
+ #
30
+ def valid?(context = nil)
31
+ super context ? context : (new? ? :create : :update)
19
32
  end
20
-
21
33
 
22
34
  module ClassMethods
23
-
24
- # Validates the associated casted model. This method should not be
35
+
36
+ # Validates the associated casted model. This method should not be
25
37
  # used within your code as it is automatically included when a CastedModel
26
38
  # is used inside the model.
27
- #
28
39
  def validates_casted_model(*args)
29
40
  validates_with(CastedModelValidator, _merge_attributes(args))
30
41
  end
31
-
42
+
32
43
  # Validates if the field is unique for this type of document. Automatically creates
33
44
  # a view if one does not already exist and performs a search for all matching
34
45
  # documents.
@@ -2,10 +2,13 @@ require "rails"
2
2
  require "active_model/railtie"
3
3
 
4
4
  module CouchRest
5
- # = Active Record Railtie
6
5
  class ModelRailtie < Rails::Railtie
7
- config.generators.orm :couchrest_model
8
- config.generators.test_framework :test_unit, :fixture => false
6
+ def self.generator
7
+ config.respond_to?(:app_generators) ? :app_generators : :generators
8
+ end
9
+
10
+ config.send(generator).orm :couchrest_model
11
+ config.send(generator).test_framework :test_unit, :fixture => false
9
12
 
10
13
  initializer "couchrest_model.configure_default_connection" do
11
14
  CouchRest::Model::Base.configure do |conf|
@@ -33,7 +33,6 @@ require "couchrest/model/property_protection"
33
33
  require "couchrest/model/properties"
34
34
  require "couchrest/model/casted_array"
35
35
  require "couchrest/model/casted_hash"
36
- require "couchrest/model/casted_model"
37
36
  require "couchrest/model/validations"
38
37
  require "couchrest/model/callbacks"
39
38
  require "couchrest/model/document_queries"
@@ -58,10 +57,10 @@ require "couchrest/model/core_extensions/hash"
58
57
  require "couchrest/model/core_extensions/time_parsing"
59
58
 
60
59
  # Base libraries
61
- require "couchrest/model/casted_model"
60
+ require "couchrest/model/embeddable"
62
61
  require "couchrest/model/base"
63
- # Add rails support *after* everything has loaded
64
62
 
63
+ # Add rails support *after* everything has loaded
65
64
  if defined?(Rails)
66
65
  require "couchrest/railtie"
67
66
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators/couchrest_model'
2
+
3
+ module CouchrestModel
4
+ module Generators
5
+ class ConfigGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def app_name
9
+ Rails::Application.subclasses.first.parent.to_s.underscore
10
+ end
11
+
12
+ def copy_configuration_file
13
+ template 'couchdb.yml', File.join('config', "couchdb.yml")
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ development: &development
2
+ protocol: 'http'
3
+ host: localhost
4
+ port: 5984
5
+ prefix: <%= app_name %>
6
+ suffix: development
7
+ username:
8
+ password:
9
+
10
+ test:
11
+ <<: *development
12
+ suffix: test
13
+
14
+ production:
15
+ protocol: 'https'
16
+ host: localhost
17
+ port: 5984
18
+ prefix: <%= app_name %>
19
+ suffix: production
20
+ username: root
21
+ password: 123
File without changes
@@ -83,6 +83,17 @@ class WithCallBacks < CouchRest::Model::Base
83
83
  end
84
84
  end
85
85
 
86
+ # Following two fixture classes have __intentionally__ diffent syntax for setting the validation context
87
+ class WithContextualValidationOnCreate < CouchRest::Model::Base
88
+ property(:name, String)
89
+ validates(:name, :presence => {:on => :create})
90
+ end
91
+
92
+ class WithContextualValidationOnUpdate < CouchRest::Model::Base
93
+ property(:name, String)
94
+ validates(:name, :presence => true, :on => :update)
95
+ end
96
+
86
97
  class WithTemplateAndUniqueID < CouchRest::Model::Base
87
98
  use_database TEST_SERVER.default_database
88
99
  unique_id do |model|
@@ -1,3 +1,5 @@
1
+ require 'person'
2
+
1
3
  class Card < CouchRest::Model::Base
2
4
  # Set the default database to use
3
5
  use_database DB
@@ -1,6 +1,6 @@
1
1
 
2
- class CatToy < Hash
3
- include ::CouchRest::Model::CastedModel
2
+ class CatToy
3
+ include CouchRest::Model::Embeddable
4
4
 
5
5
  property :name
6
6
 
File without changes
@@ -1,5 +1,5 @@
1
- require File.join(FIXTURE_PATH, 'more', 'question')
2
- require File.join(FIXTURE_PATH, 'more', 'person')
1
+ require 'question'
2
+ require 'person'
3
3
 
4
4
  class Course < CouchRest::Model::Base
5
5
  use_database TEST_SERVER.default_database
File without changes
@@ -6,9 +6,9 @@ class Invoice < CouchRest::Model::Base
6
6
  property :client_name
7
7
  property :employee_name
8
8
  property :location
9
-
9
+
10
10
  # Validation
11
11
  validates_presence_of :client_name, :employee_name
12
12
  validates_presence_of :location, :message => "Hey stupid!, you forgot the location"
13
-
13
+
14
14
  end
File without changes
@@ -0,0 +1,4 @@
1
+ class Membership
2
+ include CouchRest::Model::Embeddable
3
+
4
+ end
@@ -1,5 +1,7 @@
1
- class Person < Hash
2
- include ::CouchRest::Model::CastedModel
1
+ require 'cat'
2
+
3
+ class Person
4
+ include ::CouchRest::Model::Embeddable
3
5
  property :pet, Cat
4
6
  property :name, [String]
5
7
 
@@ -0,0 +1,6 @@
1
+ class Project < CouchRest::Model::Base
2
+ use_database DB
3
+ property :name, String
4
+ timestamps!
5
+ view_by :name
6
+ end
@@ -0,0 +1,7 @@
1
+ class Question
2
+ include ::CouchRest::Model::Embeddable
3
+
4
+ property :q
5
+ property :a
6
+
7
+ end
File without changes
@@ -1,6 +1,7 @@
1
- require File.join(FIXTURE_PATH, 'more', 'client')
2
- require File.join(FIXTURE_PATH, 'more', 'sale_entry')
3
- class SaleInvoice < CouchRest::Model::Base
1
+ require 'client'
2
+ require 'sale_entry'
3
+
4
+ class SaleInvoice < CouchRest::Model::Base
4
5
  use_database DB
5
6
 
6
7
  belongs_to :client
@@ -10,4 +11,4 @@ class SaleInvoice < CouchRest::Model::Base
10
11
 
11
12
  property :date, Date
12
13
  property :price, Integer
13
- end
14
+ end
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe CouchRest::Model::Validations do
4
+
5
+ let(:invoice) do
6
+ Invoice.new()
7
+ end
8
+ end