actv 2.1.1 → 2.2.0

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: 8bd0b193f76aa1a4cbdce17d9173bef9770919d0
4
- data.tar.gz: 80df1c83aec3d08883e9fe31fce091dc2eb303af
3
+ metadata.gz: eb543c20c467def2a700962992915afcc00671ca
4
+ data.tar.gz: a89b79de6924b3c7eec04a9f27fa8d7320dffc50
5
5
  SHA512:
6
- metadata.gz: 27bdf18386ecd2217b202ff91f19e3982b5bdaa205793cd4a020e8ab6bdd55f7d1e319b66b9e87a90dd63a4b9e4a3c77abcf326dbdbacb2741bc30df319292d9
7
- data.tar.gz: 8656a56bc1d7b329b2b5b90282470982e2f1f155d6a04a729e8170e50a67556b36cee0e67a6ebd8fb67a1dc79580eab8368e17a2c7cc5951e957df67712c6d41
6
+ metadata.gz: 6bbb2425e15b8d4d86c2e8d419167b1c772cc80f6fada11375df44214194da978e557e4db52895c5a9ea7822cfbd8cc96dbaf999b9733af060f158ba322d0eb6
7
+ data.tar.gz: b01a74be14c4f506b4533b39dc8ae4a17b2c5bef9a08b499e2b52ace3c3cd87e4b32e776bb436ce282525025deafac4b92b027e932380df22c7a1cfaeda096d5
data/lib/actv/asset.rb CHANGED
@@ -382,12 +382,15 @@ module ACTV
382
382
  private
383
383
 
384
384
  def child_assets_filtered_by_category category
385
- @children ||= Array(child_assets).compact
386
- @children.select { |child| child.category_is? category }
385
+ child_assets.select { |child| child.category_is? category }
387
386
  end
388
387
 
389
388
  def child_assets
390
- ACTV.asset components.map(&:assetGuid) if components.any?
389
+ @child_assets ||= if components.any?
390
+ ACTV.asset components.map(&:assetGuid)
391
+ else
392
+ []
393
+ end
391
394
  end
392
395
 
393
396
  def image_without_placeholder
data/lib/actv/quiz.rb CHANGED
@@ -11,5 +11,11 @@ module ACTV
11
11
  def outcomes
12
12
  @outcomes ||= child_assets_filtered_by_category 'outcome'
13
13
  end
14
+
15
+ def find_outcome_by_id guid
16
+ outcomes.find do |outcome|
17
+ outcome.assetGuid == guid
18
+ end
19
+ end
14
20
  end
15
21
  end
data/lib/actv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ACTV
2
- VERSION = "2.1.1"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -48,4 +48,22 @@ describe ACTV::Quiz do
48
48
  it { should be_empty }
49
49
  end
50
50
  end
51
+
52
+ describe '#find_outcome_by_id' do
53
+ subject(:outcome) { quiz.find_outcome_by_id "123" }
54
+
55
+ context 'when the outcome exists' do
56
+ it 'returns an outcome' do
57
+ outcome_a = double(:outcome_a, assetGuid: "123")
58
+ outcome_b = double(:outcome_b, assetGuid: "234")
59
+ outcomes = [outcome_a, outcome_b]
60
+ allow(quiz).to receive(:outcomes) { outcomes }
61
+
62
+ expect(outcome).to eq outcome_a
63
+ end
64
+ end
65
+ context 'when the outcome does not exist' do
66
+ it { should be_nil }
67
+ end
68
+ end
51
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Barnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday