modis 3.1.0 → 3.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac7dab784855560c744b5de5da3a74af89c62a705e7610fdbda79b76de63fa95
4
- data.tar.gz: dc899fdf26e84610340b49853697e25ed9ecbd4e2bf1688b816678b5cc7ee318
3
+ metadata.gz: '09f5ddeac3bce850c66441dc94fe6d485cfd37d8b6d1bad30e9c5318a46f4cbe'
4
+ data.tar.gz: 499d4e3b84569c92a130c3b8b831bc91e568f993b60b5a075448aa920b807eb1
5
5
  SHA512:
6
- metadata.gz: 0a62d99b1eb25f433443d9a82d64883241dd56da269c0acd7e05afce25b52d44ab6da9a468eff6cca35861f8e994879c4559f1516881ffdada6d386adefbef4f
7
- data.tar.gz: 473c5451144f796824e539e295bb8e9bdd9b966716a4b3ffe76c2345ed427e2b858d9588b54248830362d0fa7a922a446f59e701012f6342bb78725b05c776b1
6
+ metadata.gz: 4372de7a42905bf81d110ecc6fe265dcd17ef1c00938cda35f93984cc543e3d0d85d20f20315c0054ac47f392657dd14cf033b4cb084ab10d3525a57c170f42e
7
+ data.tar.gz: 5efcd9e86a4dafff8f5e5b53922f9a9a181dfceef4963af27890e7aad6e4b378820f138e974a848c8e03deafd69ffcc3beda64ab500099ea81e7d1f87473afe5
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.6.3
@@ -1,5 +1,9 @@
1
1
  ## Unreleased
2
2
 
3
+ ## v3.2.0 - 2019-12-12
4
+
5
+ - Add missing `#update` and `#update!`. [#27](https://github.com/rpush/modis/pull/27) by [@dsantosmerino](https://github.com/dsantosmerino).
6
+
3
7
  ## v3.1.0 - 2019-10-18
4
8
 
5
9
  - Test with Rails 6
@@ -158,16 +158,22 @@ module Modis
158
158
  save(validate: false)
159
159
  end
160
160
 
161
- def update_attributes(attrs)
161
+ def update(attrs)
162
162
  assign_attributes(attrs)
163
163
  save
164
164
  end
165
165
 
166
- def update_attributes!(attrs)
166
+ alias update_attributes update
167
+ deprecate update_attributes: 'please, use update instead'
168
+
169
+ def update!(attrs)
167
170
  assign_attributes(attrs)
168
171
  save!
169
172
  end
170
173
 
174
+ alias update_attributes! update!
175
+ deprecate update_attributes!: 'please, use update! instead'
176
+
171
177
  private
172
178
 
173
179
  def coerce_for_persistence(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modis
4
- VERSION = '3.1.0'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -249,6 +249,33 @@ describe Modis::Persistence do
249
249
  end
250
250
  end
251
251
 
252
+ describe 'update!' do
253
+ it 'updates the given attributes' do
254
+ model.update!(name: 'Derp', age: 29)
255
+ model.reload
256
+ expect(model.name).to eq 'Derp'
257
+ expect(model.age).to eq 29
258
+ end
259
+
260
+ it 'invokes callbacks' do
261
+ model.update!(name: 'Derp')
262
+ expect(model.called_callbacks).to_not be_empty
263
+ end
264
+
265
+ it 'updates all dirty attributes' do
266
+ model.age = 29
267
+ model.update!(name: 'Derp')
268
+ model.reload
269
+ expect(model.age).to eq 29
270
+ end
271
+
272
+ it 'raises an error if the model is invalid' do
273
+ expect do
274
+ model.update!(name: nil).to be false
275
+ end.to raise_error(Modis::RecordInvalid)
276
+ end
277
+ end
278
+
252
279
  describe 'update_attributes!' do
253
280
  it 'updates the given attributes' do
254
281
  model.update_attributes!(name: 'Derp', age: 29)
@@ -276,6 +303,31 @@ describe Modis::Persistence do
276
303
  end
277
304
  end
278
305
 
306
+ describe 'update' do
307
+ it 'updates the given attributes' do
308
+ model.update(name: 'Derp', age: 29)
309
+ model.reload
310
+ expect(model.name).to eq('Derp')
311
+ expect(model.age).to eq(29)
312
+ end
313
+
314
+ it 'invokes callbacks' do
315
+ model.update(name: 'Derp')
316
+ expect(model.called_callbacks).to_not be_empty
317
+ end
318
+
319
+ it 'updates all dirty attributes' do
320
+ model.age = 29
321
+ model.update(name: 'Derp')
322
+ model.reload
323
+ expect(model.age).to eq(29)
324
+ end
325
+
326
+ it 'returns false if the model is invalid' do
327
+ expect(model.update(name: nil)).to be false
328
+ end
329
+ end
330
+
279
331
  describe 'update_attributes' do
280
332
  it 'updates the given attributes' do
281
333
  model.update_attributes(name: 'Derp', age: 29)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modis
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Leitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-18 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -259,8 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  - !ruby/object:Gem::Version
260
260
  version: '0'
261
261
  requirements: []
262
- rubyforge_project:
263
- rubygems_version: 2.7.6
262
+ rubygems_version: 3.0.4
264
263
  signing_key:
265
264
  specification_version: 4
266
265
  summary: ActiveModel + Redis