tessa 0.3.0 → 0.3.1

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: 7d4243471a3a0dcf4a53293162987585ea1077e9
4
- data.tar.gz: 5124637e6f8064d3389b12e9d56f8c5451de28b2
3
+ metadata.gz: 834d04ed4ba25a28ea451b5949d747bf38b8d3da
4
+ data.tar.gz: 2cf692ef3814562a77da8672a3e530d251a496e2
5
5
  SHA512:
6
- metadata.gz: accbf3e68da83af76335f1b1f64368b3a579141c3e7657cff1a49d2b0418ac90ee422f246f8e18dd7f8584f27e1b0afe7ff1479ab0f3067cb42a92f984b940a2
7
- data.tar.gz: a2a7691c6dc45057a2acbcd8996c7ce56b53ea7cc6dbc710be51dfc59ab9197140cea91caaf0792a37f69bb25f8f51a14a5d39ad16421cf7279cbda6a3bdf5f7
6
+ metadata.gz: 83141404ec0a5e0ca3539ce50d95f6966431f92995f3901de681dfd6d17f5d3231fa6e5b2da0b67a4b87bbace5209e4ecc842e257763f0707003cf93c703f618
7
+ data.tar.gz: 1fc5949c63c52b4f43c79d75cd1038700327d276b007d99a66f380a667bdfc33ae0b878a8ad7c56626bfa8967b7e0bb20e0bdff245d7bfaa2012c668a28dee86
data/lib/tessa/model.rb CHANGED
@@ -32,6 +32,14 @@ module Tessa
32
32
  end
33
33
  end
34
34
 
35
+ def fetch_tessa_remote_assets(ids)
36
+ if [*ids].empty?
37
+ [] if ids.is_a?(Array)
38
+ else
39
+ Tessa::Asset.find(ids)
40
+ end
41
+ end
42
+
35
43
  end
36
44
 
37
45
  module ClassMethods
@@ -45,7 +53,7 @@ module Tessa
45
53
  else
46
54
  instance_variable_set(
47
55
  ivar,
48
- Tessa::Asset.find(field.id(on: self))
56
+ fetch_tessa_remote_assets(field.id(on: self))
49
57
  )
50
58
  end
51
59
  end
data/lib/tessa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tessa
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -256,10 +256,19 @@ RSpec.describe Tessa::Model do
256
256
  end
257
257
 
258
258
  it "caches the result" do
259
+ instance.file_ids = [1]
259
260
  expect(Tessa::Asset).to receive(:find).and_return(:val).once
260
261
  instance.file
261
262
  instance.file
262
263
  end
264
+
265
+ context "with no values" do
266
+ it "does not call find" do
267
+ instance.file_ids = []
268
+ expect(Tessa::Asset).not_to receive(:find)
269
+ expect(instance.file).to eq([])
270
+ end
271
+ end
263
272
  end
264
273
 
265
274
  context "with a singular typed field" do
@@ -275,10 +284,19 @@ RSpec.describe Tessa::Model do
275
284
  end
276
285
 
277
286
  it "caches the result" do
287
+ instance.file_id = 1
278
288
  expect(Tessa::Asset).to receive(:find).and_return(:val).once
279
289
  instance.file
280
290
  instance.file
281
291
  end
292
+
293
+ context "with nil value" do
294
+ it "does not call find" do
295
+ instance.file_id = nil
296
+ expect(Tessa::Asset).not_to receive(:find)
297
+ expect(instance.file).to be_nil
298
+ end
299
+ end
282
300
  end
283
301
  end
284
302
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tessa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Powell