actv 2.10.4 → 2.10.5

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: 55c88c17c63b10181b8a35f05e531ffbddaa8c28
4
- data.tar.gz: 87bd4de570957919a559ff3672580cb46d0cbebc
3
+ metadata.gz: 4acedae60694fd977cd213ec94152f2d3a2a5df1
4
+ data.tar.gz: 114d23c0c8243189517c7278321b10c26c1d588a
5
5
  SHA512:
6
- metadata.gz: 2f2736832dc34099aeedea6c39f78ab2fd3fc08e675e735b1b63368ef675639fd289dbe74410eaa3aa2d6032d7eb8521a0543bfb5beeba5da627426045ac2386
7
- data.tar.gz: ec1a37dd4b19b1b4a0b47d87fad327fed310ae3525e15259f2e2e8423b77a7793acf4db865d906ff262a46e28324bd1b7906240a005dd21e5407cfe946dd73ee
6
+ metadata.gz: 44dd52836d871b2f2a7b3346baced7c754ebf79391834bba2b926c2f2528104da78335e20dd8fab0f71084f263855aa0eaf39a9d19d89a9b7f2e3de998293691
7
+ data.tar.gz: 923310e35af621dcb87436a464babf9896af461ba79fcf575720436b75ce342f405766719e216039f4a014552a35132107fd8269dd76006ddf075f111ca265f6
@@ -354,6 +354,10 @@ module ACTV
354
354
  @attrs[:organization] || {}
355
355
  end
356
356
 
357
+ def sponsored?
358
+ sponsoredContent.present? && sponsoredContent[:enabled].to_s == 'true' && sponsored_date_available?
359
+ end
360
+
357
361
  private
358
362
 
359
363
  def child_assets_filtered_by_category category
@@ -403,5 +407,15 @@ module ACTV
403
407
  interests = meta_interests.to_a.map(&:downcase)
404
408
  ['kids', 'family'].any? { |tag| interests.include? tag }
405
409
  end
410
+
411
+ def sponsoredContent
412
+ @sponsoredContent ||= @attrs[:sponsoredContent] unless @attrs[:sponsoredContent].nil?
413
+ end
414
+
415
+ def sponsored_date_available?
416
+ start_time = Time.parse(sponsoredContent[:startDate])
417
+ end_time = Time.parse(sponsoredContent[:endDate])
418
+ Time.now.between?(start_time, end_time)
419
+ end
406
420
  end
407
421
  end
@@ -1,3 +1,3 @@
1
1
  module ACTV
2
- VERSION = "2.10.4"
2
+ VERSION = "2.10.5"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'timecop'
2
3
 
3
4
  describe ACTV::Asset do
4
5
 
@@ -537,6 +538,7 @@ describe ACTV::Asset do
537
538
  let(:asset_references) { [] }
538
539
  let(:response) { { assetGuid: 1, assetReferences: asset_references } }
539
540
  let(:asset) { ACTV::Asset.new response }
541
+
540
542
  context 'when there are asset references' do
541
543
  let(:asset_references) { [ { referenceAsset: { assetGuid: "123" },
542
544
  referenceType: { referenceTypeName: "author" } } ] }
@@ -544,11 +546,13 @@ describe ACTV::Asset do
544
546
  expect(asset.references.first).to be_a ACTV::AssetReference
545
547
  end
546
548
  end
549
+
547
550
  context 'when there are no asset references' do
548
551
  it 'returns an empty array' do
549
552
  expect(asset.references).to be_empty
550
553
  end
551
554
  end
555
+
552
556
  context 'when there is no asset references field' do
553
557
  let(:response) { { assetGuid: 1 } }
554
558
  it 'returns an empty array' do
@@ -556,4 +560,33 @@ describe ACTV::Asset do
556
560
  end
557
561
  end
558
562
  end
559
- end
563
+
564
+ describe '#sponsored?' do
565
+ before { Timecop.freeze(2017,1,1,0,0,0) }
566
+ after { Timecop.return }
567
+
568
+ let(:response) { { assetGuid: 1 } }
569
+ let(:asset) { ACTV::Asset.new response }
570
+
571
+ context 'when sponsored status is disabled' do
572
+ let(:response) { { assetGuid: 1, sponsoredContent: { startDate: '2016-12-15T00:00:00', enabled: 'false', endDate: '2017-1-28T11:59:59' } } }
573
+ it 'returns false' do
574
+ expect(asset.sponsored?).to be_false
575
+ end
576
+ end
577
+
578
+ context 'when sponsored date is valid and status is enabled' do
579
+ let(:response) { { assetGuid: 1, sponsoredContent: { startDate: '2016-12-15T00:00:00', enabled: 'true', endDate: '2017-1-28T11:59:59' } } }
580
+ it 'returns true' do
581
+ expect(asset.sponsored?).to be_true
582
+ end
583
+ end
584
+
585
+ context 'when sponsored date is invalid and status is enabled' do
586
+ let(:response) { { assetGuid: 1, sponsoredContent: { startDate: '2015-12-15T00:00:00', enabled: 'true', endDate: '2016-10-28T11:59:59' } } }
587
+ it 'returns false' do
588
+ expect(asset.sponsored?).to be_false
589
+ end
590
+ end
591
+ end
592
+ 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.10.4
4
+ version: 2.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Barnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
407
  version: '0'
408
408
  requirements: []
409
409
  rubyforge_project:
410
- rubygems_version: 2.5.1
410
+ rubygems_version: 2.5.2
411
411
  signing_key:
412
412
  specification_version: 4
413
413
  summary: Active API