epom_rails 1.3.2 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epom_rails/acts_as.rb +30 -27
- data/lib/epom_rails/acts_as_advertiser.rb +1 -25
- data/lib/epom_rails/acts_as_analytic.rb +2 -3
- data/lib/epom_rails/acts_as_campaign.rb +0 -19
- data/lib/epom_rails/acts_as_zone.rb +0 -19
- data/lib/epom_rails/version.rb +1 -1
- data/lib/generators/epom_rails/config/templates/epom_rails.rb +0 -10
- data/test/dummy/app/models/user.rb +2 -0
- data/test/dummy/db/migrate/20150927121727_create_users.rb +9 -0
- data/test/dummy/db/schema.rb +7 -1
- data/test/dummy/test/fixtures/banners.yml +1 -2
- data/test/dummy/test/fixtures/users.yml +7 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/epom_rails/acts_as_advertiser_test.rb +0 -52
- data/test/epom_rails/acts_as_analytic_test.rb +5 -3
- data/test/epom_rails/acts_as_banner_test.rb +0 -2
- data/test/epom_rails/acts_as_campaign_test.rb +0 -10
- data/test/epom_rails/acts_as_zone_test.rb +0 -13
- data/test/test_helper.rb +0 -10
- metadata +23 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4308159e730d6ae58a3f618044c7a10753c1ef2c
|
4
|
+
data.tar.gz: 27350447fbc8f632fd3c98aa5df0d23c104a93f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2534bf04d8756a7aea004916c841cfa051b282903510beb301eef246290b87f86c1e7d020d94b91151a6ea28e7249233a0b460fe9be4f1e0d8050b08e17adbcb
|
7
|
+
data.tar.gz: 2bb8a6e3344ce600dce39bb6a6bf1e42b0a8e026cb8a37a2f4348b109e0aa761aa6f69b461b240079b8c449e4369a25758eb2cb1b76e7bcf09e0fac759013a8b
|
data/lib/epom_rails/acts_as.rb
CHANGED
@@ -1,36 +1,12 @@
|
|
1
1
|
class ActiveRecord::Base
|
2
2
|
|
3
|
-
def method_missing(method_name, *args)
|
4
|
-
fields = self.class.get_config[:fields]
|
5
|
-
|
6
|
-
# shortcut for epom fields, instead of self.send(fields.key(epom_field))
|
7
|
-
# use self.send(epom_field)
|
8
|
-
if fields.values.include?(method_name.to_s)
|
9
|
-
real_method = fields.key(method_name.to_s)
|
10
|
-
return self.send(real_method)
|
11
|
-
# when self.send('advertiser.epom_id')
|
12
|
-
elsif method_name.to_s.include?('.')
|
13
|
-
methods = method_name.to_s.split('.')
|
14
|
-
target = self
|
15
|
-
methods.each do |method|
|
16
|
-
if method == methods.last
|
17
|
-
target = target.send(method, *args)
|
18
|
-
else
|
19
|
-
target = target.send(method)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
return target
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
3
|
private
|
29
4
|
|
30
5
|
def self.acts_as(klass, params)
|
31
6
|
extend EpomRails
|
32
7
|
|
33
8
|
override_config(klass, params)
|
9
|
+
define_method_missing
|
34
10
|
define_before_save(klass)
|
35
11
|
define_before_destroy(klass)
|
36
12
|
end
|
@@ -48,8 +24,35 @@ class ActiveRecord::Base
|
|
48
24
|
def self.override_config(klass, params)
|
49
25
|
config = get_config
|
50
26
|
config[:fields] = params[:fields] if params[:fields]
|
51
|
-
|
52
|
-
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.define_method_missing
|
30
|
+
self.class_eval do
|
31
|
+
def method_missing(method_name, *args)
|
32
|
+
fields = self.class.get_config[:fields]
|
33
|
+
|
34
|
+
# shortcut for epom fields, instead of self.send(fields.key(epom_field))
|
35
|
+
# use self.send(epom_field)
|
36
|
+
if fields.values.include?(method_name.to_s)
|
37
|
+
real_method = fields.key(method_name.to_s)
|
38
|
+
return self.send(real_method)
|
39
|
+
# when self.send('advertiser.epom_id')
|
40
|
+
elsif method_name.to_s.include?('.')
|
41
|
+
methods = method_name.to_s.split('.')
|
42
|
+
target = self
|
43
|
+
methods.each do |method|
|
44
|
+
if method == methods.last
|
45
|
+
target = target.send(method, *args)
|
46
|
+
else
|
47
|
+
target = target.send(method)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return target
|
51
|
+
else
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
53
56
|
end
|
54
57
|
|
55
58
|
def self.define_before_save(klass)
|
@@ -3,30 +3,6 @@ class ActiveRecord::Base
|
|
3
3
|
def self.acts_as_advertiser(params = {})
|
4
4
|
EpomRails.config.advertiser[:model] = self
|
5
5
|
acts_as(Epom::Advertiser, params)
|
6
|
-
|
7
|
-
define_before_add_and_before_remove_for_campaigns
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.define_before_add_and_before_remove_for_campaigns
|
11
|
-
campaigns_association = EpomRails.config.advertiser[:has_many].find{|a| a[:epom_element]=="Campaign"}
|
12
|
-
|
13
|
-
if campaigns_association
|
14
|
-
before_add_for_campaigns << proc do |callback, advertiser, campaign|
|
15
|
-
puts callback
|
16
|
-
if campaign.advertiser_id and advertiser.id != campaign.advertiser_id
|
17
|
-
# remove in Epom this campaign from his older advertiser
|
18
|
-
Advertiser.find(campaign.advertiser_id).campaigns.delete(campaign)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
before_remove_for_campaigns << proc do |callback, advertiser, campaign|
|
22
|
-
puts callback
|
23
|
-
fields = EpomRails.config.campaign[:fields]
|
24
|
-
# delete this campaign in Epom
|
25
|
-
Campaign.delete_campaign({campaignId: campaign.send(fields.key('id'))})
|
26
|
-
# set nil epom_id field for this campaign
|
27
|
-
campaign.send "#{fields.key('id')}=", nil
|
28
|
-
end
|
29
|
-
end
|
30
6
|
end
|
31
|
-
|
7
|
+
|
32
8
|
end
|
@@ -18,14 +18,13 @@ class ActiveRecord::Base
|
|
18
18
|
:groupBy => 'ADVERTISER,CAMPAIGN,BANNER,SITE,ZONE,PLACEMENT,CHANNEL,COUNTRY',
|
19
19
|
:groupRange => 'DAY',
|
20
20
|
}
|
21
|
-
analytics = JSON.parse(
|
22
|
-
# analytics = [{"Date"=>"01/08/2015", "Advertiser"=>"Praneet Shrivastava", "Advertiser ID"=>"911", "Campaign"=>"Camoaign by Praneet", "Campaign ID"=>"1409", "Banner"=>"Banner1", "Banner ID"=>"2364", "Site"=>"CN Beauty", "Site ID"=>"687", "Zone"=>"Zone Malaysia", "Zone ID"=>"762", "Placement"=>"CN Beauty site", "Placement ID"=>"1308", "Channel"=>"", "Country"=>"Malaysia", "Impressions"=>"642", "Clicks"=>"0", "CTR"=>"0.0000%", "Conversions"=>"0", "I2C"=>"0.0000%", "CCR"=>"0.0000%", "Net"=>"0.000", "Gross"=>"0.000", "Profit"=>"0.000", "eCPM Net"=>"0.000", "eCPM Gross"=>"0.000", "eCPM Profit"=>"0.000", "Status"=>"Preliminary confirmed"}, {"Date"=>"01/08/2015", "Advertiser"=>"Praneet Shrivastava", "Advertiser ID"=>"911", "Campaign"=>"Camoaign by Praneet", "Campaign ID"=>"1409", "Banner"=>"Banner1", "Banner ID"=>"2364", "Site"=>"CN Beauty", "Site ID"=>"687", "Zone"=>"Zone Malaysia", "Zone ID"=>"762", "Placement"=>"CN Beauty site", "Placement ID"=>"1308", "Channel"=>"", "Country"=>"Indonesia", "Impressions"=>"33", "Clicks"=>"0", "CTR"=>"0.0000%", "Conversions"=>"0", "I2C"=>"0.0000%", "CCR"=>"0.0000%", "Net"=>"0.000", "Gross"=>"0.000", "Profit"=>"0.000", "eCPM Net"=>"0.000", "eCPM Gross"=>"0.000", "eCPM Profit"=>"0.000", "Status"=>"Preliminary confirmed"}, {"Date"=>"01/08/2015", "Advertiser"=>"Praneet Shrivastava", "Advertiser ID"=>"911", "Campaign"=>"Camoaign by Praneet", "Campaign ID"=>"1409", "Banner"=>"Banner1", "Banner ID"=>"2364", "Site"=>"CN Beauty", "Site ID"=>"687", "Zone"=>"Zone Malaysia", "Zone ID"=>"762", "Placement"=>"CN Beauty site", "Placement ID"=>"1308", "Channel"=>"", "Country"=>"Brunei Darussalam", "Impressions"=>"31", "Clicks"=>"0", "CTR"=>"0.0000%", "Conversions"=>"0", "I2C"=>"0.0000%", "CCR"=>"0.0000%", "Net"=>"0.000", "Gross"=>"0.000", "Profit"=>"0.000", "eCPM Net"=>"0.000", "eCPM Gross"=>"0.000", "eCPM Profit"=>"0.000", "Status"=>"Preliminary confirmed"}, {"Date"=>"01/08/2015", "Advertiser"=>"Praneet Shrivastava", "Advertiser ID"=>"911", "Campaign"=>"Camoaign by Praneet", "Campaign ID"=>"1409", "Banner"=>"Banner1", "Banner ID"=>"2364", "Site"=>"CN Beauty", "Site ID"=>"687", "Zone"=>"Zone Malaysia", "Zone ID"=>"762", "Placement"=>"CN Beauty site", "Placement ID"=>"1308", "Channel"=>"", "Country"=>"Singapore", "Impressions"=>"31", "Clicks"=>"0", "CTR"=>"0.0000%", "Conversions"=>"0", "I2C"=>"0.0000%", "CCR"=>"0.0000%", "Net"=>"0.000", "Gross"=>"0.000", "Profit"=>"0.000", "eCPM Net"=>"0.000", "eCPM Gross"=>"0.000", "eCPM Profit"=>"0.000", "Status"=>"Preliminary confirmed"}, {"Date"=>"01/08/2015", "Advertiser"=>"NetUy", "Advertiser ID"=>"1253", "Campaign"=>"Netuy Envios de Titulares Matinales Campaña 2015", "Campaign ID"=>"1661", "Banner"=>"NetUy envíos", "Banner ID"=>"2598", "Site"=>"El Observador", "Site ID"=>"1059", "Zone"=>"Newsletters", "Zone ID"=>"1211", "Placement"=>"Titulares_Matinal_Cabezal", "Placement ID"=>"1704", "Channel"=>"", "Country"=>"Uruguay", "Impressions"=>"8", "Clicks"=>"0", "CTR"=>"0.0000%", "Conversions"=>"0", "I2C"=>"0.0000%", "CCR"=>"0.0000%", "Net"=>"0.000", "Gross"=>"0.000", "Profit"=>"0.000", "eCPM Net"=>"0.000", "eCPM Gross"=>"0.000", "eCPM Profit"=>"0.000", "Status"=>"Preliminary confirmed"}]
|
21
|
+
analytics = JSON.parse(Epom::Analytic.analytics(default.merge(params)))
|
23
22
|
fields = get_config[:fields]
|
24
23
|
analytics.map do |analytic|
|
25
24
|
data = {}
|
26
25
|
fields.map {|key, value| data[key] = analytic[value]}
|
27
26
|
data[:date] = Date.parse(data[:date]) if data[:date].is_a?(String)
|
28
|
-
|
27
|
+
self.new(data)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -3,25 +3,6 @@ class ActiveRecord::Base
|
|
3
3
|
def self.acts_as_campaign(params = {})
|
4
4
|
EpomRails.config.campaign[:model] = self
|
5
5
|
acts_as(Epom::Campaign, params)
|
6
|
-
|
7
|
-
override_belongs_to_advertiser
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.override_belongs_to_advertiser
|
11
|
-
advertiser_association = EpomRails.config.campaign[:belongs_to].find{|a| a[:epom_element]=="Advertiser"}
|
12
|
-
|
13
|
-
if advertiser_association
|
14
|
-
# overriding belongs_to: advertiser
|
15
|
-
define_method advertiser_association[:name] do
|
16
|
-
fields = EpomRails.config.campaign[:fields]
|
17
|
-
object = super()
|
18
|
-
|
19
|
-
if object.respond_to?(fields.key('id')) and object.send(fields.key('id'))
|
20
|
-
# here, retrieve this advertiser from Epom
|
21
|
-
end
|
22
|
-
object
|
23
|
-
end
|
24
|
-
end
|
25
6
|
end
|
26
7
|
|
27
8
|
end
|
@@ -3,25 +3,6 @@ class ActiveRecord::Base
|
|
3
3
|
def self.acts_as_zone(params = {})
|
4
4
|
EpomRails.config.zone[:model] = self
|
5
5
|
acts_as(Epom::Zone, params)
|
6
|
-
|
7
|
-
override_belongs_to_zone
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.override_belongs_to_zone
|
11
|
-
site_association = EpomRails.config.zone[:belongs_to].find{|a| a[:epom_element]=="Site"}
|
12
|
-
|
13
|
-
if site_association
|
14
|
-
# overriding belongs_to: site
|
15
|
-
define_method site_association[:name] do
|
16
|
-
fields = EpomRails.config.zone[:fields]
|
17
|
-
object = super()
|
18
|
-
|
19
|
-
if object.respond_to?(fields.key('id')) and object.send(fields.key('id'))
|
20
|
-
# here, retrieve this site from Epom
|
21
|
-
end
|
22
|
-
object
|
23
|
-
end
|
24
|
-
end
|
25
6
|
end
|
26
7
|
|
27
8
|
end
|
data/lib/epom_rails/version.rb
CHANGED
@@ -3,31 +3,21 @@ EpomRails.configure do |config|
|
|
3
3
|
|
4
4
|
config.advertiser = {}
|
5
5
|
config.advertiser[:fields] = {epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'}
|
6
|
-
config.advertiser[:has_many] = [{:name => 'campaigns', :epom_element => 'Campaign', :model => 'Campaign'}]
|
7
6
|
|
8
7
|
config.campaign = {}
|
9
8
|
config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', weight: 'weight', 'advertiser.epom_id' => 'advertiserId'}
|
10
|
-
config.campaign[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
|
11
|
-
config.campaign[:belongs_to] = [{:name => 'advertiser', :epom_element => 'Advertiser', :model => 'Advertiser'}]
|
12
9
|
|
13
10
|
config.banner = {}
|
14
11
|
config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', 'campaign.epom_id' => 'campaignId', weight: 'weight', image_banner_link: 'imageBannerLink', url: 'url', name: 'name', banner_type: 'bannerType', ad_unit_id: 'adUnitId', ad_unit_width: 'adUnitWidth', ad_unit_height: 'adUnitHeight'}
|
15
|
-
config.banner[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
|
16
|
-
config.banner[:belongs_to] = [{:name => 'campaign', :epom_element => 'Campaign', :model => 'Campaign'}]
|
17
12
|
|
18
13
|
config.site = {}
|
19
14
|
config.site[:fields] = {epom_id: 'id', name: 'name', url: 'url', description: 'description', email: 'email', category_id: 'categoryId'}
|
20
|
-
config.site[:has_many] = [{:name => 'zones', :epom_element => 'Zone', :model => 'Zone'}]
|
21
15
|
|
22
16
|
config.zone = {}
|
23
17
|
config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', 'site.epom_id' => 'siteId'}
|
24
|
-
config.zone[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
|
25
|
-
config.zone[:belongs_to] = [{:name => 'site', :epom_element => 'Site', :model => 'Site'}]
|
26
18
|
|
27
19
|
config.placement = {}
|
28
20
|
config.placement[:fields] = {epom_id: 'id', 'zone.epom_id' => 'zoneId', placement_type: 'type', name: 'name', ad_unit_id: 'adUnitId', size_height: 'size.height', size_width: 'size.width'}
|
29
|
-
config.placement[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
|
30
|
-
config.placement[:belongs_to] = [{:name => 'zone', :epom_element => 'Zone', :model => 'Zone'}]
|
31
21
|
|
32
22
|
config.analytic = {}
|
33
23
|
config.analytic[:fields] = {date: "Date", hour: "Hour", advertiser: "Advertiser", advertiser_id: "Advertiser ID", campaign: "Campaign", campaign_id: "Campaign ID", banner: "Banner", banner_id: "Banner ID", site: "Site", site_id: "Site ID", zone: "Zone", zone_id: "Zone ID", placement: "Placement", placement_id: "Placement ID", channel: "Channel", country: "Country", impressions: "Impressions", clicks: "Clicks", ctr: "CTR", conversions: "Conversions", i2c: "I2C", ccr: "CCR", net: "Net", gross: "Gross", profit: "Profit", ecpm_net: "eCPM Net", ecpm_gross: "eCPM Gross", ecpm_profit: "eCPM Profit", status: "Status"}
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150927121727) do
|
15
15
|
|
16
16
|
create_table "advertisers", force: :cascade do |t|
|
17
17
|
t.string "name"
|
@@ -106,6 +106,12 @@ ActiveRecord::Schema.define(version: 20150821041145) do
|
|
106
106
|
t.datetime "updated_at", null: false
|
107
107
|
end
|
108
108
|
|
109
|
+
create_table "users", force: :cascade do |t|
|
110
|
+
t.string "name"
|
111
|
+
t.datetime "created_at", null: false
|
112
|
+
t.datetime "updated_at", null: false
|
113
|
+
end
|
114
|
+
|
109
115
|
create_table "zones", force: :cascade do |t|
|
110
116
|
t.integer "epom_id"
|
111
117
|
t.string "name"
|
@@ -5,16 +5,6 @@ class ActsAsAdvertiserTest < ActiveSupport::TestCase
|
|
5
5
|
EpomRails.config.advertiser[:fields].key(field)
|
6
6
|
end
|
7
7
|
|
8
|
-
def check_campaigns_list(campaigns1, campaigns2)
|
9
|
-
assert_equal campaigns1.count, campaigns2.count
|
10
|
-
campaigns1.each do |campaign|
|
11
|
-
epom_campaign = campaigns2.find{|c| c['id'] == campaign.send(epom_field('id'))}
|
12
|
-
assert epom_campaign
|
13
|
-
assert_instance_of Hash, epom_campaign
|
14
|
-
assert_equal campaign.name, epom_campaign['name']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
8
|
test 'fancy_method' do
|
19
9
|
assert_raises NoMethodError do Advertiser.fancy_method end
|
20
10
|
end
|
@@ -79,46 +69,4 @@ class ActsAsAdvertiserTest < ActiveSupport::TestCase
|
|
79
69
|
end
|
80
70
|
end
|
81
71
|
|
82
|
-
test 'define_before_add_and_before_remove_for_campaigns' do
|
83
|
-
a1 = Advertiser.create(name: 'advertiser 1')
|
84
|
-
a2 = Advertiser.create(name: 'advertiser 2')
|
85
|
-
c = Campaign.create(name: 'campaign', advertiser_id: a2.id)
|
86
|
-
|
87
|
-
puts 'a1.campaigns << c'
|
88
|
-
a1.campaigns << c
|
89
|
-
unless EpomRails.config.offline
|
90
|
-
# TODO: replace for a1.get_campaigns_for_advertiser
|
91
|
-
campaigns = Advertiser.get_campaigns_for_advertiser({advertiserId: a1.send(epom_field('id'))})
|
92
|
-
check_campaigns_list(a1.campaigns(true), campaigns)
|
93
|
-
end
|
94
|
-
|
95
|
-
puts 'a2.campaigns << c'
|
96
|
-
a2.campaigns << c
|
97
|
-
unless EpomRails.config.offline
|
98
|
-
# TODO: replace for a1.get_campaigns_for_advertiser
|
99
|
-
campaigns = Advertiser.get_campaigns_for_advertiser({advertiserId: a1.send(epom_field('id'))})
|
100
|
-
check_campaigns_list(a1.campaigns(true), campaigns)
|
101
|
-
|
102
|
-
# TODO: replace for a2.get_campaigns_for_advertiser
|
103
|
-
campaigns = Advertiser.get_campaigns_for_advertiser({advertiserId: a2.send(epom_field('id'))})
|
104
|
-
check_campaigns_list(a2.campaigns(true), campaigns)
|
105
|
-
end
|
106
|
-
|
107
|
-
puts 'a2.campaigns = [Campaign.create, Campaign.create]'
|
108
|
-
a2.campaigns = [Campaign.create(name: 'campaign 1', advertiser_id: a2.id), Campaign.create(name: 'campaign 2', advertiser_id: a2.id)]
|
109
|
-
assert_nil Campaign.find(c.id).advertiser
|
110
|
-
unless EpomRails.config.offline
|
111
|
-
# TODO: replace for a2.get_campaigns_for_advertiser
|
112
|
-
campaigns = Advertiser.get_campaigns_for_advertiser({advertiserId: a2.send(epom_field('id'))})
|
113
|
-
check_campaigns_list(a2.campaigns(true), campaigns)
|
114
|
-
end
|
115
|
-
|
116
|
-
puts 'a2.campaigns = []'
|
117
|
-
a2.campaigns = []
|
118
|
-
unless EpomRails.config.offline
|
119
|
-
# TODO: replace for a2.get_campaigns_for_advertiser
|
120
|
-
campaigns = Advertiser.get_campaigns_for_advertiser({advertiserId: a2.send(epom_field('id'))})
|
121
|
-
check_campaigns_list(a2.campaigns(true), campaigns)
|
122
|
-
end
|
123
|
-
end
|
124
72
|
end
|
@@ -2,8 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ActsAsAnalyticTest < ActiveSupport::TestCase
|
4
4
|
test 'analytic_from_epom' do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
unless EpomRails.config.offline
|
6
|
+
analytics = Analytic.analytic_from_epom({range: 'CURRENT_MONTH'})
|
7
|
+
assert_instance_of Array, analytics
|
8
|
+
assert_instance_of Analytic, analytics[0] if analytics.count > 0
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -23,12 +23,10 @@ class ActsAsBannerTest < ActiveSupport::TestCase
|
|
23
23
|
unless EpomRails.config.offline
|
24
24
|
banner = banners(:two)
|
25
25
|
banner.epom_id = nil
|
26
|
-
banner.save
|
27
26
|
|
28
27
|
assert banner.save
|
29
28
|
assert_instance_of Fixnum, banner.send(epom_field('id'))
|
30
29
|
|
31
|
-
epom_id = banner.send(epom_field('id'))
|
32
30
|
assert banner.destroy
|
33
31
|
end
|
34
32
|
end
|
@@ -51,14 +51,4 @@ class ActsAsCampaignTest < ActiveSupport::TestCase
|
|
51
51
|
assert campaign.advertiser_id, campaign.advertiserId
|
52
52
|
end
|
53
53
|
|
54
|
-
test 'belongs to advertiser' do
|
55
|
-
campaign = campaigns(:one)
|
56
|
-
advertiser = advertisers(:one)
|
57
|
-
campaign.advertiser = advertiser
|
58
|
-
# ensure epom id is setted
|
59
|
-
advertiser.save
|
60
|
-
|
61
|
-
assert Advertiser.find(campaign.advertiser_id), campaign.advertiser
|
62
|
-
end
|
63
|
-
|
64
54
|
end
|
@@ -48,17 +48,4 @@ class ActsAsZoneTest < ActiveSupport::TestCase
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
test 'belongs_to config' do
|
52
|
-
assert [{:name => 'publisher', :epom_element => 'Site', :model => 'Publisher'}], EpomRails.config.zone[:belongs_to]
|
53
|
-
end
|
54
|
-
|
55
|
-
test 'belongs to publisher' do
|
56
|
-
zone = zones(:one)
|
57
|
-
publisher = publishers(:one)
|
58
|
-
zone.publisher = publisher
|
59
|
-
# ensure epom id is setted
|
60
|
-
publisher.save
|
61
|
-
|
62
|
-
assert Publisher.find(zone.publisher_id), zone.publisher
|
63
|
-
end
|
64
51
|
end
|
data/test/test_helper.rb
CHANGED
@@ -40,31 +40,21 @@ EpomRails.configure do |config|
|
|
40
40
|
|
41
41
|
config.advertiser = {}
|
42
42
|
config.advertiser[:fields] = {epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'}
|
43
|
-
config.advertiser[:has_many] = [{:name => 'campaigns', :epom_element => 'Campaign', :model => 'Campaign'}]
|
44
43
|
|
45
44
|
config.campaign = {}
|
46
45
|
config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', weight: 'weight', 'advertiser.epom_id' => 'advertiserId'}
|
47
|
-
config.campaign[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
|
48
|
-
config.campaign[:belongs_to] = [{:name => 'advertiser', :epom_element => 'Advertiser', :model => 'Advertiser'}]
|
49
46
|
|
50
47
|
config.banner = {}
|
51
48
|
config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', 'campaign.epom_id' => 'campaignId', weight: 'weight', image_banner_link: 'imageBannerLink', url: 'url', name: 'name', banner_type: 'bannerType', ad_unit_id: 'adUnitId', ad_unit_width: 'adUnitWidth', ad_unit_height: 'adUnitHeight'}
|
52
|
-
config.banner[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
|
53
|
-
config.banner[:belongs_to] = [{:name => 'campaign', :epom_element => 'Campaign', :model => 'Campaign'}]
|
54
49
|
|
55
50
|
config.site = {}
|
56
51
|
config.site[:fields] = {epom_id: 'id', name: 'name', url: 'url', description: 'description', email: 'email', category_id: 'categoryId'}
|
57
|
-
config.site[:has_many] = [{:name => 'zones', :epom_element => 'Zone', :model => 'Zone'}]
|
58
52
|
|
59
53
|
config.zone = {}
|
60
54
|
config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', 'publisher.epom_id' => 'siteId'}
|
61
|
-
config.zone[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
|
62
|
-
config.zone[:belongs_to] = [{:name => 'publisher', :epom_element => 'Site', :model => 'Publisher'}]
|
63
55
|
|
64
56
|
config.placement = {}
|
65
57
|
config.placement[:fields] = {epom_id: 'id', 'zone.epom_id' => 'zoneId', placement_type: 'type', name: 'name', ad_unit_id: 'adUnitId', size_height: 'size.height', size_width: 'size.width'}
|
66
|
-
config.placement[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
|
67
|
-
config.placement[:belongs_to] = [{:name => 'zone', :epom_element => 'Zone', :model => 'Zone'}]
|
68
58
|
|
69
59
|
config.analytic = {}
|
70
60
|
config.analytic[:fields] = {date: "Date", hour: "Hour", advertiser: "Advertiser", advertiser_id: "Advertiser ID", campaign: "Campaign", campaign_id: "Campaign ID", banner: "Banner", banner_id: "Banner ID", site: "Site", site_id: "Site ID", zone: "Zone", zone_id: "Zone ID", placement: "Placement", placement_id: "Placement ID", channel: "Channel", country: "Country", impressions: "Impressions", clicks: "Clicks", ctr: "CTR", conversions: "Conversions", i2c: "I2C", ccr: "CCR", net: "Net", gross: "Gross", profit: "Profit", ecpm_net: "eCPM Net", ecpm_gross: "eCPM Gross", ecpm_profit: "eCPM Profit", status: "Status"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epom_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Chang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- test/dummy/app/models/campaign.rb
|
119
119
|
- test/dummy/app/models/placement.rb
|
120
120
|
- test/dummy/app/models/publisher.rb
|
121
|
+
- test/dummy/app/models/user.rb
|
121
122
|
- test/dummy/app/models/zone.rb
|
122
123
|
- test/dummy/app/views/advertisers/_form.html.erb
|
123
124
|
- test/dummy/app/views/advertisers/edit.html.erb
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- test/dummy/db/migrate/20150731161340_create_publishers.rb
|
188
189
|
- test/dummy/db/migrate/20150803195716_create_zones.rb
|
189
190
|
- test/dummy/db/migrate/20150821041145_create_analytics.rb
|
191
|
+
- test/dummy/db/migrate/20150927121727_create_users.rb
|
190
192
|
- test/dummy/db/schema.rb
|
191
193
|
- test/dummy/public/404.html
|
192
194
|
- test/dummy/public/422.html
|
@@ -205,6 +207,7 @@ files:
|
|
205
207
|
- test/dummy/test/fixtures/campaigns.yml
|
206
208
|
- test/dummy/test/fixtures/placements.yml
|
207
209
|
- test/dummy/test/fixtures/publishers.yml
|
210
|
+
- test/dummy/test/fixtures/users.yml
|
208
211
|
- test/dummy/test/fixtures/zones.yml
|
209
212
|
- test/dummy/test/models/advertiser_test.rb
|
210
213
|
- test/dummy/test/models/analytic_test.rb
|
@@ -212,6 +215,7 @@ files:
|
|
212
215
|
- test/dummy/test/models/campaign_test.rb
|
213
216
|
- test/dummy/test/models/placement_test.rb
|
214
217
|
- test/dummy/test/models/publisher_test.rb
|
218
|
+
- test/dummy/test/models/user_test.rb
|
215
219
|
- test/dummy/test/models/zone_test.rb
|
216
220
|
- test/epom_rails/acts_as_advertiser_test.rb
|
217
221
|
- test/epom_rails/acts_as_analytic_test.rb
|
@@ -259,14 +263,16 @@ test_files:
|
|
259
263
|
- test/dummy/config.ru
|
260
264
|
- test/dummy/Rakefile
|
261
265
|
- test/dummy/README.rdoc
|
262
|
-
- test/dummy/test/models/analytic_test.rb
|
263
266
|
- test/dummy/test/models/zone_test.rb
|
267
|
+
- test/dummy/test/models/user_test.rb
|
264
268
|
- test/dummy/test/models/publisher_test.rb
|
265
269
|
- test/dummy/test/models/placement_test.rb
|
266
270
|
- test/dummy/test/models/campaign_test.rb
|
267
271
|
- test/dummy/test/models/banner_test.rb
|
272
|
+
- test/dummy/test/models/analytic_test.rb
|
268
273
|
- test/dummy/test/models/advertiser_test.rb
|
269
274
|
- test/dummy/test/fixtures/zones.yml
|
275
|
+
- test/dummy/test/fixtures/users.yml
|
270
276
|
- test/dummy/test/fixtures/publishers.yml
|
271
277
|
- test/dummy/test/fixtures/placements.yml
|
272
278
|
- test/dummy/test/fixtures/campaigns.yml
|
@@ -285,6 +291,7 @@ test_files:
|
|
285
291
|
- test/dummy/public/422.html
|
286
292
|
- test/dummy/public/404.html
|
287
293
|
- test/dummy/db/schema.rb
|
294
|
+
- test/dummy/db/migrate/20150927121727_create_users.rb
|
288
295
|
- test/dummy/db/migrate/20150821041145_create_analytics.rb
|
289
296
|
- test/dummy/db/migrate/20150803195716_create_zones.rb
|
290
297
|
- test/dummy/db/migrate/20150731161340_create_publishers.rb
|
@@ -294,8 +301,8 @@ test_files:
|
|
294
301
|
- test/dummy/db/migrate/20150608194916_create_campaigns.rb
|
295
302
|
- test/dummy/db/migrate/20150604125603_add_epom_id_to_advertiser.rb
|
296
303
|
- test/dummy/db/migrate/20150603151041_create_advertisers.rb
|
297
|
-
- test/dummy/config/routes.rb
|
298
304
|
- test/dummy/config/secrets.yml
|
305
|
+
- test/dummy/config/routes.rb
|
299
306
|
- test/dummy/config/environment.rb
|
300
307
|
- test/dummy/config/database.yml
|
301
308
|
- test/dummy/config/boot.rb
|
@@ -316,16 +323,11 @@ test_files:
|
|
316
323
|
- test/dummy/bin/rake
|
317
324
|
- test/dummy/bin/rails
|
318
325
|
- test/dummy/bin/bundle
|
319
|
-
- test/dummy/app/views/analytics/show.html.erb
|
320
|
-
- test/dummy/app/views/analytics/new.html.erb
|
321
|
-
- test/dummy/app/views/analytics/index.html.erb
|
322
|
-
- test/dummy/app/views/analytics/edit.html.erb
|
323
|
-
- test/dummy/app/views/analytics/_form.html.erb
|
324
326
|
- test/dummy/app/views/zones/show.html.erb
|
325
|
-
- test/dummy/app/views/zones/index.html.erb
|
326
|
-
- test/dummy/app/views/zones/_form.html.erb
|
327
327
|
- test/dummy/app/views/zones/new.html.erb
|
328
|
+
- test/dummy/app/views/zones/index.html.erb
|
328
329
|
- test/dummy/app/views/zones/edit.html.erb
|
330
|
+
- test/dummy/app/views/zones/_form.html.erb
|
329
331
|
- test/dummy/app/views/publishers/show.html.erb
|
330
332
|
- test/dummy/app/views/publishers/new.html.erb
|
331
333
|
- test/dummy/app/views/publishers/index.html.erb
|
@@ -347,35 +349,40 @@ test_files:
|
|
347
349
|
- test/dummy/app/views/banners/index.html.erb
|
348
350
|
- test/dummy/app/views/banners/edit.html.erb
|
349
351
|
- test/dummy/app/views/banners/_form.html.erb
|
352
|
+
- test/dummy/app/views/analytics/show.html.erb
|
353
|
+
- test/dummy/app/views/analytics/new.html.erb
|
354
|
+
- test/dummy/app/views/analytics/index.html.erb
|
355
|
+
- test/dummy/app/views/analytics/edit.html.erb
|
356
|
+
- test/dummy/app/views/analytics/_form.html.erb
|
350
357
|
- test/dummy/app/views/advertisers/show.html.erb
|
351
358
|
- test/dummy/app/views/advertisers/new.html.erb
|
352
359
|
- test/dummy/app/views/advertisers/index.html.erb
|
353
360
|
- test/dummy/app/views/advertisers/edit.html.erb
|
354
361
|
- test/dummy/app/views/advertisers/_form.html.erb
|
355
362
|
- test/dummy/app/models/zone.rb
|
363
|
+
- test/dummy/app/models/user.rb
|
356
364
|
- test/dummy/app/models/publisher.rb
|
357
365
|
- test/dummy/app/models/placement.rb
|
358
366
|
- test/dummy/app/models/campaign.rb
|
359
367
|
- test/dummy/app/models/banner.rb
|
360
368
|
- test/dummy/app/models/analytic.rb
|
361
369
|
- test/dummy/app/models/advertiser.rb
|
362
|
-
- test/dummy/app/helpers/analytics_helper.rb
|
363
370
|
- test/dummy/app/helpers/zones_helper.rb
|
364
371
|
- test/dummy/app/helpers/publishers_helper.rb
|
365
372
|
- test/dummy/app/helpers/placements_helper.rb
|
366
373
|
- test/dummy/app/helpers/campaigns_helper.rb
|
367
374
|
- test/dummy/app/helpers/banners_helper.rb
|
368
375
|
- test/dummy/app/helpers/application_helper.rb
|
376
|
+
- test/dummy/app/helpers/analytics_helper.rb
|
369
377
|
- test/dummy/app/helpers/advertisers_helper.rb
|
370
378
|
- test/dummy/app/controllers/zones_controller.rb
|
371
|
-
- test/dummy/app/controllers/analytics_controller.rb
|
372
379
|
- test/dummy/app/controllers/publishers_controller.rb
|
373
380
|
- test/dummy/app/controllers/placements_controller.rb
|
374
381
|
- test/dummy/app/controllers/campaigns_controller.rb
|
375
382
|
- test/dummy/app/controllers/banners_controller.rb
|
376
383
|
- test/dummy/app/controllers/application_controller.rb
|
384
|
+
- test/dummy/app/controllers/analytics_controller.rb
|
377
385
|
- test/dummy/app/controllers/advertisers_controller.rb
|
378
|
-
- test/dummy/app/assets/stylesheets/analytics.css
|
379
386
|
- test/dummy/app/assets/stylesheets/zones.css
|
380
387
|
- test/dummy/app/assets/stylesheets/scaffold.css
|
381
388
|
- test/dummy/app/assets/stylesheets/publishers.css
|
@@ -383,12 +390,13 @@ test_files:
|
|
383
390
|
- test/dummy/app/assets/stylesheets/campaigns.css
|
384
391
|
- test/dummy/app/assets/stylesheets/banners.css
|
385
392
|
- test/dummy/app/assets/stylesheets/application.css
|
393
|
+
- test/dummy/app/assets/stylesheets/analytics.css
|
386
394
|
- test/dummy/app/assets/stylesheets/advertisers.css
|
387
|
-
- test/dummy/app/assets/javascripts/analytics.js
|
388
395
|
- test/dummy/app/assets/javascripts/zones.js
|
389
396
|
- test/dummy/app/assets/javascripts/publishers.js
|
390
397
|
- test/dummy/app/assets/javascripts/placements.js
|
391
398
|
- test/dummy/app/assets/javascripts/campaigns.js
|
392
399
|
- test/dummy/app/assets/javascripts/banners.js
|
393
400
|
- test/dummy/app/assets/javascripts/application.js
|
401
|
+
- test/dummy/app/assets/javascripts/analytics.js
|
394
402
|
- test/dummy/app/assets/javascripts/advertisers.js
|