slim_form_object 0.5.22 → 0.5.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a1a89125979213f45b4bf5df265aaaf83c0c4a9
4
- data.tar.gz: 7b0a6cbab44b3b32c20d92d20e9d736f5c519b7b
3
+ metadata.gz: c790c09a7f14bba8e6919633cf1e42b329b28e09
4
+ data.tar.gz: 9a56d7be9abf5a89d75a0e1528e3f5379d1e7f93
5
5
  SHA512:
6
- metadata.gz: 1e38ae5d94058cd6f8b6ee7171bc7d2fc85c41aec3ee2ce1a31203dd52bf912699bc25a08cf62d7890da55b38dd63024385145aa8133a6fae3e8852aa77a5e33
7
- data.tar.gz: 51ed0c4650d16d2cde08d4670a3b1e3ec46900b37aa7a289783b861560ee351c3f8ac302eeca18c90b874be2c5897b76ebf946200d8b7f6c233d4f7f25d77566
6
+ metadata.gz: 41588b2e3ee7615fa00c64d8bf6358f28c7ba77775247a02af54e0ce87fee09f943bbce12832677b18a3d80b87a1f2c59bb95d0c18726df11e8b3dfac82824ca
7
+ data.tar.gz: 0b2adebf258a068570ab894e0e27babe9888ce33389db897b4704a98801dee89c3fac6a5dfdcff80fd7e3908fcac6b253dd4fc839f43d72e25dd89b18b68502d
@@ -37,7 +37,9 @@ module SlimFormObject
37
37
  end
38
38
 
39
39
  def submit
40
- @array_of_models ||= array_of_models.reject{ |model| array_of_models_without_validates.include?(model) }
40
+ @array_of_models ||= array_of_models.reject do |model|
41
+ array_of_models_without_validates.include?(model) if self.respond_to?(:array_of_models_without_validates)
42
+ end
41
43
  update_attributes
42
44
  update_attributes_for_collection
43
45
  self
@@ -155,7 +157,7 @@ module SlimFormObject
155
157
  end
156
158
 
157
159
  def get_association(class1, class2)
158
- class1.reflections.slice(snake(class2.to_s), class2.table_name).values.first.try(:macro)
160
+ class1.reflections.slice(snake(class2.to_s), class2.table_name).values.first&.macro
159
161
  end
160
162
 
161
163
  end
@@ -1,3 +1,3 @@
1
1
  module SlimFormObject
2
- VERSION = "0.5.22"
2
+ VERSION = "0.5.23"
3
3
  end
@@ -151,18 +151,18 @@ describe TestModule do
151
151
  end
152
152
 
153
153
  context 'validation_models' do
154
+ before do
155
+ object.instance_eval{ @array_of_models = [TestOneModel] }
156
+ end
157
+
154
158
  it 'errors is present' do
155
159
  object.stub(:test_one_model).and_return( TestOneModel.new(descr: 'desc') )
156
-
157
- expect(object).to receive(:array_of_models).and_return([TestOneModel])
158
160
  expect(object).to receive(:set_errors).and_return( true )
159
161
  object.send :validation_models
160
162
  end
161
163
 
162
164
  it 'errors is not exist' do
163
165
  object.stub(:test_one_model).and_return( TestOneModel.new(title: 'title', descr: 'desc') )
164
-
165
- expect(object).to receive(:array_of_models).and_return([TestOneModel])
166
166
  expect(object).not_to receive(:set_errors)
167
167
  object.send :validation_models
168
168
  end
@@ -173,7 +173,7 @@ describe TestModule do
173
173
  attributes_of_model = ["test_one_model_id", "test_one_model_title", "test_one_model_descr"]
174
174
  attributes_for_update = {"title"=>"Test Title", "descr"=>"Test Descr"}
175
175
 
176
- expect(object).to receive(:array_of_models).and_return( [TestOneModel] )
176
+ object.instance_eval{ @array_of_models = [TestOneModel] }
177
177
  expect(object).to receive(:make_attributes_of_model).and_return( attributes_of_model )
178
178
  expect(object).to receive(:get_attributes_for_update).and_return( attributes_for_update )
179
179
  object.stub(:test_one_model).and_return( TestOneModel.new )
@@ -226,6 +226,7 @@ describe TestModule do
226
226
 
227
227
  context 'keys_of_collections' do
228
228
  it 'must be return array with values' do
229
+ object.instance_eval{ @array_of_models = [TestOneModel] }
229
230
  object.stub(:params).and_return( {test_one_model_test_four_model_ids: [1, 2, 3]} )
230
231
  object.stub_chain(:method, :call) { TestOneModel.create(title:'title', descr:'descr') }
231
232
 
@@ -248,12 +249,12 @@ describe TestModule do
248
249
  def test_four_model
249
250
  TestFourModel.create(title:'title', descr:'descr')
250
251
  end
252
+ @array_of_models = [TestOneModel, TestFourModel]
251
253
  end
252
254
  end
253
255
 
254
256
  it 'must be return true' do
255
257
  object.stub(:keys_of_collections).and_return( ['test_one_model_ids', 'test_four_model_ids'] )
256
- object.stub(:array_of_models).and_return( [TestOneModel, TestFourModel] )
257
258
  object.stub(:valid?).and_return( false )
258
259
  object.stub_chain(:errors, :messages).and_return( {:test_one_models=>'error', :test_four_models=>'error'} )
259
260
 
@@ -267,7 +268,6 @@ describe TestModule do
267
268
  end
268
269
  end
269
270
  object.stub(:keys_of_collections).and_return( ['test_one_model_ids', 'test_four_model_ids'] )
270
- object.stub(:array_of_models).and_return( [TestOneModel, TestFourModel] )
271
271
  object.stub(:valid?).and_return( false )
272
272
  object.stub_chain(:errors, :messages).and_return( {:test_one_models=>'error', :test_four_models=>'error', :descr=>'error'} )
273
273
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_form_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - woodcrust
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel