zanox_publisher 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +178 -0
- data/Rakefile +10 -0
- data/lib/zanox_publisher/ad_medium.rb +232 -0
- data/lib/zanox_publisher/ad_space.rb +159 -0
- data/lib/zanox_publisher/base.rb +69 -0
- data/lib/zanox_publisher/category.rb +57 -0
- data/lib/zanox_publisher/connection.rb +291 -0
- data/lib/zanox_publisher/exclusive_incentive.rb +135 -0
- data/lib/zanox_publisher/format.rb +19 -0
- data/lib/zanox_publisher/incentive.rb +135 -0
- data/lib/zanox_publisher/incentive_base.rb +89 -0
- data/lib/zanox_publisher/policy.rb +42 -0
- data/lib/zanox_publisher/prize.rb +18 -0
- data/lib/zanox_publisher/product.rb +263 -0
- data/lib/zanox_publisher/profile.rb +123 -0
- data/lib/zanox_publisher/program.rb +241 -0
- data/lib/zanox_publisher/program_application.rb +135 -0
- data/lib/zanox_publisher/tracking_link.rb +42 -0
- data/lib/zanox_publisher/version.rb +3 -0
- data/lib/zanox_publisher/vertical.rb +19 -0
- data/lib/zanox_publisher.rb +39 -0
- data/spec/config/credentials.example.yml +2 -0
- data/spec/lib/requirements_spec.rb +9 -0
- data/spec/lib/zanox_publisher/ad_medium_spec.rb +162 -0
- data/spec/lib/zanox_publisher/ad_space_spec.rb +56 -0
- data/spec/lib/zanox_publisher/base_spec.rb +35 -0
- data/spec/lib/zanox_publisher/connection_spec.rb +68 -0
- data/spec/lib/zanox_publisher/exclusive_incentive_spec.rb +104 -0
- data/spec/lib/zanox_publisher/incentive_spec.rb +112 -0
- data/spec/lib/zanox_publisher/product_spec.rb +223 -0
- data/spec/lib/zanox_publisher/profile_spec.rb +26 -0
- data/spec/lib/zanox_publisher/program_application_spec.rb +51 -0
- data/spec/lib/zanox_publisher/program_spec.rb +192 -0
- data/spec/lib/zanox_ruby_spec.rb +17 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/credentials.rb +3 -0
- data/spec/support/vcr.rb +8 -0
- data/spec/vcr_cassettes/.gitignore +4 -0
- data/zanox_publisher.gemspec +27 -0
- metadata +203 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::AdSpace do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
describe '::page', :vcr do
|
8
|
+
subject(:adspaces) { ZanoxPublisher::AdSpace.page }
|
9
|
+
|
10
|
+
it { is_expected.to be_kind_of Array }
|
11
|
+
it { expect(adspaces.first).to be_kind_of ZanoxPublisher::AdSpace }
|
12
|
+
|
13
|
+
it { expect(adspaces.count).to be > 0 }
|
14
|
+
it 'sets the AdSpace total count' do
|
15
|
+
ZanoxPublisher::AdSpace.total = nil
|
16
|
+
adspaces
|
17
|
+
expect(ZanoxPublisher::AdSpace.total).to be > 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '::all', :vcr do
|
22
|
+
subject(:adspaces) { ZanoxPublisher::AdSpace.all }
|
23
|
+
|
24
|
+
it { is_expected.to be_kind_of Array }
|
25
|
+
it { expect(adspaces.first).to be_kind_of ZanoxPublisher::AdSpace }
|
26
|
+
|
27
|
+
it { expect(adspaces.count).to be == ZanoxPublisher::AdSpace.total }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '::find', vcr: { record: :new_episodes } do
|
31
|
+
let(:first) do
|
32
|
+
ZanoxPublisher::AdSpace.all.first
|
33
|
+
end
|
34
|
+
|
35
|
+
subject(:find) { ZanoxPublisher::AdSpace.find(first.id) }
|
36
|
+
|
37
|
+
it { is_expected.to be_kind_of ZanoxPublisher::AdSpace }
|
38
|
+
|
39
|
+
it { expect(find.id).to be == first.id }
|
40
|
+
it { expect(find.name).to be == first.name }
|
41
|
+
it { expect(find.url).to be == first.url }
|
42
|
+
it { expect(find.description).to be == first.description }
|
43
|
+
it { expect(find.adspace_type).to be == first.adspace_type }
|
44
|
+
it { expect(find.visitors).to be == first.visitors }
|
45
|
+
it { expect(find.impressions).to be == first.impressions }
|
46
|
+
it { expect(find.language).to be == first.language }
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'item', :vcr do
|
50
|
+
subject(:adspace) { ZanoxPublisher::AdSpace.all.first }
|
51
|
+
|
52
|
+
it 'responds to to_i with its ID' do
|
53
|
+
expect(adspace.to_i).to be == adspace.id
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::Base do
|
4
|
+
subject { ZanoxPublisher::Base }
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :maximum_per_page }
|
7
|
+
|
8
|
+
it { is_expected.to respond_to :per_page }
|
9
|
+
it { is_expected.to respond_to :per_page= }
|
10
|
+
|
11
|
+
it { is_expected.to respond_to :total }
|
12
|
+
it { is_expected.to respond_to :total= }
|
13
|
+
|
14
|
+
# The order can not be :random here but must follow code definition
|
15
|
+
describe "::per_page", :order => :defined do
|
16
|
+
subject { ZanoxPublisher::Base.per_page }
|
17
|
+
|
18
|
+
it { is_expected.to be == ZanoxPublisher::Base.class_variable_get(:@@default_per_page) }
|
19
|
+
|
20
|
+
it "is greater than or equal to 0" do
|
21
|
+
ZanoxPublisher::Base.per_page = -1
|
22
|
+
expect(subject).to be == 0
|
23
|
+
end
|
24
|
+
|
25
|
+
it "is not greater than the maximum page size" do
|
26
|
+
ZanoxPublisher::Base.per_page = 1_000_000
|
27
|
+
expect(subject).to be == ZanoxPublisher::Base.class_variable_get(:@@maximum_per_page)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "accepts valid values" do
|
31
|
+
ZanoxPublisher::Base.per_page = 5
|
32
|
+
expect(subject).to be == 5
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::Connection do
|
4
|
+
describe "#initialize" do
|
5
|
+
|
6
|
+
it { is_expected.to respond_to :relative_path }
|
7
|
+
|
8
|
+
context "with parameters" do
|
9
|
+
before(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
10
|
+
after(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
11
|
+
subject(:connection) { ZanoxPublisher::Connection.new('', credentials['connect_id'], credentials['secret_key']) }
|
12
|
+
|
13
|
+
it "should set connect ID and secret key" do
|
14
|
+
expect(connection.instance_variable_get(:@connect_id)).to eql credentials['connect_id']
|
15
|
+
expect(connection.instance_variable_get(:@secret_key)).to eql credentials['secret_key']
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have '' as relative path" do
|
19
|
+
expect(connection.relative_path).to eql ''
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with ZanoxPublisher::authenticate" do
|
24
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
25
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
26
|
+
subject(:connection) { ZanoxPublisher::Connection.new('/profiles') }
|
27
|
+
|
28
|
+
it "should default to authenticate parameters" do
|
29
|
+
expect(connection.instance_variable_get(:@connect_id)).to eql credentials['connect_id']
|
30
|
+
expect(connection.instance_variable_get(:@secret_key)).to eql credentials['secret_key']
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be able to set the relative path" do
|
34
|
+
expect(connection.relative_path).to eql '/profiles'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'AuthenticationError' do
|
40
|
+
before(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
41
|
+
after(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
42
|
+
subject(:connection) { ZanoxPublisher::Connection.new() }
|
43
|
+
|
44
|
+
it 'when public resource is accessed without connect ID' do
|
45
|
+
expect{connection.get}.to raise_error(ZanoxPublisher::AuthenticationError)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'when private resource is accessed without connect ID or secret' do
|
49
|
+
expect{connection.signature_get}.to raise_error(ZanoxPublisher::AuthenticationError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'Unauthorized' do
|
54
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], 'INVALID') }
|
55
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
56
|
+
subject(:connection) { ZanoxPublisher::Connection.new() }
|
57
|
+
|
58
|
+
it { expect{ connection.signature_get('/profiles') }.to raise_error(ZanoxPublisher::Unauthorized) }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'NotFound' do
|
62
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
63
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
64
|
+
subject(:connection) { ZanoxPublisher::Connection.new() }
|
65
|
+
|
66
|
+
it { expect{ connection.get('/no_where') }.to raise_error(ZanoxPublisher::NotFound) }
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::ExclusiveIncentive do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
let(:program) { ZanoxPublisher::Program.page.first }
|
8
|
+
let(:adspace) { ZanoxPublisher::AdSpace.page.first }
|
9
|
+
let(:incentive_type) { ZanoxPublisher::ExclusiveIncentive::incentive_types.first }
|
10
|
+
let(:region) { 'DE' }
|
11
|
+
let(:exclusive_incentives_total) do
|
12
|
+
ZanoxPublisher::ExclusiveIncentive.page
|
13
|
+
ZanoxPublisher::ExclusiveIncentive.total
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '::page', :vcr do
|
17
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page }
|
18
|
+
|
19
|
+
it { is_expected.to be_kind_of Array }
|
20
|
+
it { expect(incentives.first).to be_nil or be_kind_of ZanoxPublisher::ExclusiveIncentive }
|
21
|
+
|
22
|
+
it { expect(incentives.count).to be >= 0 }
|
23
|
+
it 'to set the ExclusiveIncentive total count' do
|
24
|
+
ZanoxPublisher::ExclusiveIncentive.total = nil
|
25
|
+
incentives
|
26
|
+
expect(ZanoxPublisher::ExclusiveIncentive.total).to be >= 0
|
27
|
+
end
|
28
|
+
it { expect(incentives.all? { |incentive| incentive.exclusive == true}).to be true}
|
29
|
+
|
30
|
+
context 'with progam' do
|
31
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page(0, program: program) }
|
32
|
+
|
33
|
+
it { expect(incentives.all? { |incentive| incentive.program.id == program.id }).to be true }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with adspace' do
|
37
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page(0, adspace: adspace) }
|
38
|
+
|
39
|
+
it 'incentives have tracking link associated with this AdSpace' do
|
40
|
+
admedia = incentives.map { |incentive| incentive.admedia }
|
41
|
+
expect(admedia.all? { |admedium| admedium.tracking_links.first.adspace == adspace.id}).to be true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with incentive_type' do
|
46
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page(0, incentive_type: incentive_type ) }
|
47
|
+
|
48
|
+
it { expect(incentives.all? { |incentive| incentive.incentive_type == incentive_type }).to be true }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with incentiveType' do
|
52
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page(0, incentiveType: incentive_type ) }
|
53
|
+
|
54
|
+
it { expect(incentives.all? { |incentive| incentive.incentive_type == incentive_type }).to be true }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with region' do
|
58
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.page(0, region: region) }
|
59
|
+
|
60
|
+
it 'limits results to programs from a particular region' do
|
61
|
+
programs = []
|
62
|
+
|
63
|
+
incentives.each do |incentive|
|
64
|
+
program = ZanoxPublisher::Program.find(incentive.program.id)
|
65
|
+
programs << program
|
66
|
+
end
|
67
|
+
|
68
|
+
expect(programs.all? { |program| program.regions.include? region }).to be true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '::all', :vcr do
|
74
|
+
subject(:incentives) { ZanoxPublisher::ExclusiveIncentive.all region: region, incentive_type: incentive_type }
|
75
|
+
|
76
|
+
it { is_expected.to be_kind_of Array }
|
77
|
+
it { expect(incentives.first).to be_nil or be_kind_of ZanoxPublisher::ExclusiveIncentive }
|
78
|
+
|
79
|
+
it { expect(incentives.count).to be == ZanoxPublisher::ExclusiveIncentive.total }
|
80
|
+
end
|
81
|
+
|
82
|
+
# NO ACCESS TO EXCLUSIVE INCENTIVE SO THIS REMAINS UNTESTED
|
83
|
+
# describe '::find', vcr: { record: :new_episodes } do
|
84
|
+
# let(:first) do
|
85
|
+
# ZanoxPublisher::ExclusiveIncentive.page(0, adspace: adspace).first
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# subject(:find) { ZanoxPublisher::ExclusiveIncentive.find(first) }
|
89
|
+
#
|
90
|
+
# it { is_expected.to be_kind_of ZanoxPublisher::ExclusiveIncentive }
|
91
|
+
#
|
92
|
+
# it { expect(find.id).to be == first.id }
|
93
|
+
# it { expect(find.name).to be == first.name }
|
94
|
+
# it { expect(find.incentive_type).to be == first.incentive_type }
|
95
|
+
# it { expect(find.admedia.id).to be == first.admedia.id }
|
96
|
+
# it { expect(find.program.id).to be == first.program.id }
|
97
|
+
#
|
98
|
+
# context 'with adspace' do
|
99
|
+
# subject(:find) { ZanoxPublisher::ExclusiveIncentive.find(first, adspace: adspace)}
|
100
|
+
#
|
101
|
+
# it { expect(find.admedia.tracking_links.first.adspace).to be == adspace.id }
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::Incentive do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
let(:program) { ZanoxPublisher::Program.page.first }
|
8
|
+
let(:adspace) { ZanoxPublisher::AdSpace.page.first }
|
9
|
+
let(:incentive_type) { ZanoxPublisher::Incentive::incentive_types.first }
|
10
|
+
let(:region) { 'DE' }
|
11
|
+
let(:incentives_total) do
|
12
|
+
ZanoxPublisher::Incentive.page
|
13
|
+
ZanoxPublisher::Incentive.total
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '::page', :vcr do
|
17
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page }
|
18
|
+
|
19
|
+
it { is_expected.to be_kind_of Array }
|
20
|
+
it { expect(incentives.first).to be_kind_of ZanoxPublisher::Incentive }
|
21
|
+
|
22
|
+
it { expect(incentives.count).to be >= 0 }
|
23
|
+
it 'to set the Incentive total count' do
|
24
|
+
ZanoxPublisher::Incentive.total = nil
|
25
|
+
incentives
|
26
|
+
expect(ZanoxPublisher::Incentive.total).to be >= 0
|
27
|
+
end
|
28
|
+
it { expect(incentives.all? { |incentive| incentive.exclusive == false}).to be true}
|
29
|
+
|
30
|
+
context 'page size is one' do
|
31
|
+
subject(:incentive) { ZanoxPublisher::Incentive.page(0, per_page: 1) }
|
32
|
+
|
33
|
+
it { is_expected.to be_kind_of Array }
|
34
|
+
it { expect(incentive.first).to be_kind_of ZanoxPublisher::Incentive }
|
35
|
+
it { expect(incentive.count).to be == 1 }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with progam' do
|
39
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page(0, program: program) }
|
40
|
+
|
41
|
+
it { expect(incentives.all? { |incentive| incentive.program.id == program.id }).to be true }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with adspace' do
|
45
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page(0, adspace: adspace) }
|
46
|
+
|
47
|
+
it 'incentives have tracking link associated with this AdSpace' do
|
48
|
+
admedia = incentives.map { |incentive| incentive.admedia }
|
49
|
+
expect(admedia.all? { |admedium| admedium.tracking_links.first.adspace == adspace.id}).to be true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with incentive_type' do
|
54
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page(0, incentive_type: incentive_type ) }
|
55
|
+
|
56
|
+
it { expect(incentives.all? { |incentive| incentive.incentive_type == incentive_type }).to be true }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with incentiveType' do
|
60
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page(0, incentiveType: incentive_type ) }
|
61
|
+
|
62
|
+
it { expect(incentives.all? { |incentive| incentive.incentive_type == incentive_type }).to be true }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with region' do
|
66
|
+
subject(:incentives) { ZanoxPublisher::Incentive.page(0, region: region) }
|
67
|
+
|
68
|
+
it 'limits results to programs from a particular region' do
|
69
|
+
programs = []
|
70
|
+
|
71
|
+
incentives.each do |incentive|
|
72
|
+
program = ZanoxPublisher::Program.find(incentive.program)
|
73
|
+
programs << program
|
74
|
+
end
|
75
|
+
|
76
|
+
expect(programs.all? { |program| program.regions.include? region }).to be true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '::all', :vcr do
|
82
|
+
subject(:incentives) { ZanoxPublisher::Incentive.all region: region, incentive_type: incentive_type }
|
83
|
+
|
84
|
+
it { is_expected.to be_kind_of Array }
|
85
|
+
it { expect(incentives.first).to be_kind_of ZanoxPublisher::Incentive }
|
86
|
+
|
87
|
+
it { expect(incentives.count).to be == ZanoxPublisher::Incentive.total }
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '::find', vcr: { record: :new_episodes } do
|
91
|
+
let(:first) do
|
92
|
+
ZanoxPublisher::Incentive.page(0, adspace: adspace).first
|
93
|
+
end
|
94
|
+
|
95
|
+
subject(:find) { ZanoxPublisher::Incentive.find(first) }
|
96
|
+
|
97
|
+
it { is_expected.to be_kind_of ZanoxPublisher::Incentive }
|
98
|
+
|
99
|
+
it { expect(find.id).to be == first.id }
|
100
|
+
it { expect(find.name).to be == first.name }
|
101
|
+
it { expect(find.incentive_type).to be == first.incentive_type }
|
102
|
+
it { expect(find.admedia.id).to be == first.admedia.id }
|
103
|
+
it { expect(find.program.id).to be == first.program.id }
|
104
|
+
|
105
|
+
# Seems to be implementation error in Zanox API
|
106
|
+
context 'with adspace' do
|
107
|
+
subject(:find) { ZanoxPublisher::Incentive.find(first, adspace: adspace)}
|
108
|
+
|
109
|
+
it { expect(find.admedia.tracking_links.first.adspace).to be == adspace.id }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::Product do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
let(:product_total) do
|
8
|
+
ZanoxPublisher::Product.page
|
9
|
+
ZanoxPublisher::Product.total
|
10
|
+
end
|
11
|
+
let(:query_phrase) { 'mobile' }
|
12
|
+
let(:query_contextual) { 'Discover everything iPhone' }
|
13
|
+
let(:region) { 'DE' }
|
14
|
+
let(:minimum_price) { 10 }
|
15
|
+
let(:maximum_price) { 50 }
|
16
|
+
let(:programs) do
|
17
|
+
confirmed = ZanoxPublisher::ProgramApplication.page(0, status: 'confirmed').map(&:program)
|
18
|
+
confirmed.map { |program| ZanoxPublisher::Program.find(program) }
|
19
|
+
end
|
20
|
+
let(:program) do
|
21
|
+
confirmed = ZanoxPublisher::ProgramApplication.page(0, status: 'confirmed').first.program
|
22
|
+
ZanoxPublisher::Program.find(confirmed)
|
23
|
+
end
|
24
|
+
let(:program_not_confirmed) { ZanoxPublisher::Program.page.first }
|
25
|
+
let(:adspace) { ZanoxPublisher::AdSpace.page.first }
|
26
|
+
let(:ean) { ZanoxPublisher::Product.page.first.ean }
|
27
|
+
let(:merchant_category_ary) { program.categories.map(&:name) }
|
28
|
+
let(:merchant_category) { program.categories.first.name }
|
29
|
+
|
30
|
+
describe '::page', :vcr do
|
31
|
+
subject(:products) { ZanoxPublisher::Product.page }
|
32
|
+
|
33
|
+
it { is_expected.to be_kind_of Array }
|
34
|
+
it { expect(products.first).to be_kind_of ZanoxPublisher::Product }
|
35
|
+
|
36
|
+
it { expect(products.count).to be > 0 }
|
37
|
+
it 'to set the Product total count' do
|
38
|
+
ZanoxPublisher::Product.total = nil
|
39
|
+
products
|
40
|
+
expect(ZanoxPublisher::Product.total).to be > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with phrase query' do
|
44
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { query: query_phrase }) }
|
45
|
+
|
46
|
+
it 'limits results to products associated with search string' do
|
47
|
+
products
|
48
|
+
expect(ZanoxPublisher::Product.total).to be < product_total
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Seems to have no effect
|
53
|
+
context 'with contextual query' do
|
54
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { query: query_contextual }) }
|
55
|
+
|
56
|
+
it 'limits results to products associated with search string' do
|
57
|
+
products
|
58
|
+
expect(ZanoxPublisher::Product.total).to be < product_total
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with q' do
|
63
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { q: query_contextual }) }
|
64
|
+
|
65
|
+
it 'limits results to products associated with search string' do
|
66
|
+
products
|
67
|
+
expect(ZanoxPublisher::Product.total).to be < product_total
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with region' do
|
72
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { region: region }) }
|
73
|
+
|
74
|
+
it 'limits results to programs from a particular region' do
|
75
|
+
programs = []
|
76
|
+
|
77
|
+
products.each do |product|
|
78
|
+
program = ZanoxPublisher::Program.find(product.program)
|
79
|
+
programs << program
|
80
|
+
end
|
81
|
+
|
82
|
+
expect(programs.all? { |program| program.regions.include? region }).to be true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'with minimum_price' do
|
87
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { minimum_price: minimum_price }) }
|
88
|
+
|
89
|
+
it { expect(products.all? { |product| product.price > minimum_price }).to be true }
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with minprice' do
|
93
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { minprice: minimum_price }) }
|
94
|
+
|
95
|
+
it { expect(products.all? { |product| product.price > minimum_price }).to be true }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with maximum_price' do
|
99
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { maximum_price: maximum_price }) }
|
100
|
+
|
101
|
+
it { expect(products.all? { |product| product.price < maximum_price }).to be true }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'with maxprice' do
|
105
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { maxprice: maximum_price }) }
|
106
|
+
|
107
|
+
it { expect(products.all? { |product| product.price < maximum_price }).to be true }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'with one progam' do
|
111
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { programs: program }) }
|
112
|
+
|
113
|
+
it { expect(products.all? { |product| product.program.id == program.id }).to be true}
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'with multiple programs' do
|
117
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { programs: programs }) }
|
118
|
+
let(:program_ids) { programs.map(&:id) }
|
119
|
+
|
120
|
+
it { expect(products.all? { |product| program_ids.include? product.program.id }).to be true}
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'with not confirmed program' do
|
124
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { programs: program_not_confirmed })}
|
125
|
+
|
126
|
+
it { expect{subject}.to raise_error(ZanoxPublisher::Unauthorized)}
|
127
|
+
end
|
128
|
+
|
129
|
+
context 'with has_images' do
|
130
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { has_images: true }) }
|
131
|
+
|
132
|
+
it { expect(products.all? { |product| product.image != nil }).to be true}
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'with hasimages' do
|
136
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { hasimages: true }) }
|
137
|
+
|
138
|
+
it { expect(products.all? { |product| product.image != nil }).to be true}
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'with adspace' do
|
142
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { adspace: adspace }) }
|
143
|
+
|
144
|
+
it 'products have tracking link associated with this AdSpace' do
|
145
|
+
expect(products.all? { |prouct| prouct.tracking_links.first.adspace == adspace.id}).to be true
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'with all partnership' do
|
150
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { partnership: 'all' }) }
|
151
|
+
|
152
|
+
it 'has more products than with confirmed' do
|
153
|
+
products
|
154
|
+
expect(ZanoxPublisher::Product.total).to be > product_total
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'with confirmed partnership' do
|
159
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { partnership: 'confirmed' }) }
|
160
|
+
|
161
|
+
it 'has same products count' do
|
162
|
+
products
|
163
|
+
expect(ZanoxPublisher::Product.total).to be == product_total
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'with partnership' do
|
168
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { ean: ean }) }
|
169
|
+
|
170
|
+
it { expect(products.all? { |product| product.ean == ean }).to be true}
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'with merchant_category array' do
|
174
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { merchant_category: merchant_category_ary }) }
|
175
|
+
|
176
|
+
it { expect(products.all? { |product| merchant_category_ary.include? product.category }).to be true }
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'with merchant_category' do
|
180
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { merchant_category: merchant_category }) }
|
181
|
+
|
182
|
+
it { expect(products.all? { |product| product.category == merchant_category }).to be true }
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'with merchantcategory' do
|
186
|
+
subject(:products) { ZanoxPublisher::Product.page(0, { merchantcategory: merchant_category }) }
|
187
|
+
|
188
|
+
it { expect(products.all? { |product| product.category == merchant_category }).to be true }
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '::all', :vcr do
|
193
|
+
subject(:products) { ZanoxPublisher::Product.all query: query_phrase, region: region, minimum_price: minimum_price }
|
194
|
+
|
195
|
+
it { is_expected.to be_kind_of Array }
|
196
|
+
it { expect(products.first).to be_kind_of ZanoxPublisher::Product }
|
197
|
+
|
198
|
+
it { expect(products.count).to be == ZanoxPublisher::Product.total }
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '::find', vcr: { record: :new_episodes } do
|
202
|
+
let(:first) do
|
203
|
+
ZanoxPublisher::Product.page.first
|
204
|
+
end
|
205
|
+
|
206
|
+
subject(:find) { ZanoxPublisher::Product.find(first) }
|
207
|
+
|
208
|
+
it { is_expected.to be_kind_of ZanoxPublisher::Product }
|
209
|
+
|
210
|
+
it { expect(find.id).to be == first.id }
|
211
|
+
it { expect(find.name).to be == first.name }
|
212
|
+
it { expect(find.program.id).to be == first.program.id }
|
213
|
+
it { expect(find.price).to be == first.price }
|
214
|
+
it { expect(find.currency).to be == first.currency }
|
215
|
+
|
216
|
+
# Seems to be implementation error in Zanox API
|
217
|
+
context 'with adspace' do
|
218
|
+
subject(:find) { ZanoxPublisher::Product.find(first, adspace: adspace)}
|
219
|
+
|
220
|
+
it { expect(find.tracking_links.first.adspace). to be == adspace.id }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::Profile do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
describe '::all', :vcr do
|
8
|
+
subject(:profiles) { ZanoxPublisher::Profile.all }
|
9
|
+
|
10
|
+
it { is_expected.to be_kind_of Array }
|
11
|
+
|
12
|
+
it { expect(profiles.count).to be > 0 }
|
13
|
+
|
14
|
+
it { expect(profiles.first).to be_kind_of ZanoxPublisher::Profile }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '::first', :vcr do
|
18
|
+
subject(:profile) { ZanoxPublisher::Profile.first }
|
19
|
+
|
20
|
+
it { is_expected.to be_kind_of ZanoxPublisher::Profile }
|
21
|
+
|
22
|
+
it 'responds to to_i with its ID' do
|
23
|
+
expect(profile.to_i).to be == profile.id
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZanoxPublisher::ProgramApplication do
|
4
|
+
before(:all) { ZanoxPublisher::authenticate(credentials['connect_id'], credentials['secret_key']) }
|
5
|
+
after(:all) { ZanoxPublisher::authenticate(nil, nil) }
|
6
|
+
|
7
|
+
let(:program) { ZanoxPublisher::Program.page.first }
|
8
|
+
let(:adspace) { ZanoxPublisher::AdSpace.page.first }
|
9
|
+
let(:status) { ZanoxPublisher::ProgramApplication.const_get(:PROGRAM_APPLICATION_STATUS_ENUM).first }
|
10
|
+
|
11
|
+
describe '::page', :vcr do
|
12
|
+
subject(:applications) { ZanoxPublisher::ProgramApplication.page }
|
13
|
+
|
14
|
+
it { is_expected.to be_kind_of Array }
|
15
|
+
it { expect(applications.first).to be_kind_of ZanoxPublisher::ProgramApplication }
|
16
|
+
|
17
|
+
it { expect(applications.count).to be > 0 }
|
18
|
+
it 'to set the ProgramApplication total count' do
|
19
|
+
ZanoxPublisher::ProgramApplication.total = nil
|
20
|
+
applications
|
21
|
+
expect(ZanoxPublisher::ProgramApplication.total).to be > 0
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with program' do
|
25
|
+
subject(:applications) { ZanoxPublisher::ProgramApplication.page(0, program: program) }
|
26
|
+
|
27
|
+
it { expect(applications.all? { |application| application.program.id == program.id }).to be true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with adspace' do
|
31
|
+
subject(:applications) { ZanoxPublisher::ProgramApplication.page(0, adspace: adspace) }
|
32
|
+
|
33
|
+
it { expect(applications.all? { |application| application.adspace.id == adspace.id }).to be true }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with status' do
|
37
|
+
subject(:applications) { ZanoxPublisher::ProgramApplication.page(0, status: status) }
|
38
|
+
|
39
|
+
it { expect(applications.all? { |application| application.status == status }).to be true }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '::all' , :vcr do
|
44
|
+
subject(:applications) { ZanoxPublisher::ProgramApplication.all adspace: adspace }
|
45
|
+
|
46
|
+
it { is_expected.to be_kind_of Array }
|
47
|
+
it { expect(applications.first).to be_kind_of ZanoxPublisher::ProgramApplication }
|
48
|
+
|
49
|
+
it { expect(applications.count).to be == ZanoxPublisher::ProgramApplication.total }
|
50
|
+
end
|
51
|
+
end
|