epom_rails 0.4.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/epom_rails/acts_as.rb +27 -38
  3. data/lib/epom_rails/acts_as_advertiser.rb +8 -0
  4. data/lib/epom_rails/acts_as_banner.rb +8 -0
  5. data/lib/epom_rails/acts_as_campaign.rb +8 -0
  6. data/lib/epom_rails/acts_as_placement.rb +8 -0
  7. data/lib/epom_rails/acts_as_site.rb +8 -0
  8. data/lib/epom_rails/acts_as_zone.rb +8 -0
  9. data/lib/epom_rails/config.rb +29 -1
  10. data/lib/epom_rails/version.rb +1 -1
  11. data/lib/epom_rails.rb +19 -6
  12. data/lib/generators/epom_rails/config/templates/epom_rails.rb +29 -1
  13. data/test/dummy/app/controllers/publishers_controller.rb +58 -0
  14. data/test/dummy/app/helpers/publishers_helper.rb +2 -0
  15. data/test/dummy/app/models/advertiser.rb +1 -1
  16. data/test/dummy/app/models/banner.rb +1 -1
  17. data/test/dummy/app/models/campaign.rb +1 -1
  18. data/test/dummy/app/models/placement.rb +1 -1
  19. data/test/dummy/app/models/publisher.rb +3 -0
  20. data/test/dummy/app/models/zone.rb +1 -1
  21. data/test/dummy/app/views/{sites → publishers}/_form.html.erb +8 -8
  22. data/test/dummy/app/views/publishers/edit.html.erb +6 -0
  23. data/test/dummy/app/views/publishers/index.html.erb +37 -0
  24. data/test/dummy/app/views/publishers/new.html.erb +5 -0
  25. data/test/dummy/app/views/publishers/show.html.erb +34 -0
  26. data/test/dummy/config/routes.rb +1 -1
  27. data/test/dummy/db/migrate/{20150619174544_create_sites.rb → 20150731161340_create_publishers.rb} +3 -3
  28. data/test/dummy/db/schema.rb +3 -3
  29. data/test/dummy/test/controllers/publishers_controller_test.rb +49 -0
  30. data/test/dummy/test/fixtures/{sites.yml → publishers.yml} +2 -2
  31. data/test/dummy/test/models/{site_test.rb → publisher_test.rb} +1 -1
  32. data/test/epom_rails/acts_as_advertiser_test.rb +1 -1
  33. data/test/epom_rails/acts_as_banner_test.rb +1 -1
  34. data/test/epom_rails/acts_as_campaign_test.rb +1 -1
  35. data/test/epom_rails/acts_as_placement_test.rb +1 -1
  36. data/test/epom_rails/acts_as_site_test.rb +6 -6
  37. data/test/epom_rails/acts_as_zone_test.rb +5 -1
  38. data/test/test_helper.rb +29 -1
  39. metadata +36 -30
  40. data/test/dummy/app/controllers/sites_controller.rb +0 -58
  41. data/test/dummy/app/helpers/sites_helper.rb +0 -2
  42. data/test/dummy/app/models/site.rb +0 -3
  43. data/test/dummy/app/views/sites/edit.html.erb +0 -6
  44. data/test/dummy/app/views/sites/index.html.erb +0 -37
  45. data/test/dummy/app/views/sites/new.html.erb +0 -5
  46. data/test/dummy/app/views/sites/show.html.erb +0 -34
  47. data/test/dummy/test/controllers/sites_controller_test.rb +0 -49
  48. /data/test/dummy/app/assets/javascripts/{sites.js → publishers.js} +0 -0
  49. /data/test/dummy/app/assets/stylesheets/{sites.css → publishers.css} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9487c632ee64b76623635a73c7ea0fa1ebc24142
4
- data.tar.gz: 91b9485e01854440b99cbe9f7a029588f58ec1c6
3
+ metadata.gz: 4962f4fd1ba3541d9bef5d8636abd40adf73b026
4
+ data.tar.gz: f3357980470748efd86a47a01433253fe263cc86
5
5
  SHA512:
6
- metadata.gz: ce6449077d706236c930d7566723159184ce90c42ff81ead03d8dfa94e8432f0afd8f63f1ed4ce4861640a442a7062f40994244ceabc02257bc0e7fe64ef01d4
7
- data.tar.gz: 44efb423e734bd84f3f4ba87585af8bdfff2f5c9a70f59f24095315d77e3b9e284f031de862d3dd16d363cbb89c5cc87de4db455ff522a96c620f6770413085f
6
+ metadata.gz: c7ad76795810c969c0bfd976c0e8b4a1a6742f08f400f9ad6e29a97865322ed7b4454e3a34d3bda7125df6ef899172a0488cdf4d32a071002023dad3f2754de1
7
+ data.tar.gz: 7034623022877440f796d849336c92d1caf17d780e298d669000525dbe63c344532bdbe9f91eebb7c602534f49fe501d5e0eb593765705c479dffd8c3cd60699
@@ -1,48 +1,38 @@
1
1
  class ActiveRecord::Base
2
2
 
3
- def self.acts_as_advertiser(fields = {})
4
- acts_as(Epom::Advertiser, fields)
5
- end
6
-
7
- def self.acts_as_campaign(fields = {})
8
- acts_as(Epom::Campaign, fields)
9
- end
3
+ private
10
4
 
11
- def self.acts_as_banner(fields = {})
12
- acts_as(Epom::Banner, fields)
5
+ def self.acts_as(klass, params)
6
+ extend EpomRails
7
+
8
+ override_config(klass, params)
9
+ define_before_save(klass)
10
+ define_before_destroy(klass)
13
11
  end
14
12
 
15
- def self.acts_as_site(fields = {})
16
- acts_as(Epom::Site, fields)
13
+ def self.get_klass_name(klass)
14
+ klass.name.include?('::') ? klass.name.split('::').last : klass.name
17
15
  end
18
16
 
19
- def self.acts_as_zone(fields = {})
20
- acts_as(Epom::Zone, fields)
17
+ def self.get_config(klass)
18
+ klass_name = get_klass_name(klass)
19
+ EpomRails.config.send(klass_name.downcase)
21
20
  end
22
21
 
23
- def self.acts_as_placement(fields = {})
24
- acts_as(Epom::Placement, fields)
22
+ def self.override_config(klass, params)
23
+ fields ||= {}
24
+ config = get_config(klass)
25
+ config[:fields] = params[:fields] if params[:fields]
26
+ config[:has_many] = params[:has_many] if params[:has_many]
27
+ config[:belongs_to] = params[:belongs_to] if params[:belongs_to]
25
28
  end
26
29
 
27
- private
28
-
29
- def self.acts_as(klass, fields = {})
30
- extend EpomRails
31
-
32
- self.epom_klass = klass
33
- self.epom_fields = fields
34
-
35
- define_before_save
36
- define_before_destroy
37
- end
38
-
39
- def self.define_before_save
30
+ def self.define_before_save(klass)
40
31
  unless EpomRails.config.offline
41
- klass = self.epom_klass
42
- fields = self.epom_fields
43
- before_save do
44
- klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
32
+ klass_name = get_klass_name(klass)
33
+ fields = get_config(klass)[:fields]
45
34
 
35
+ before_save do
46
36
  method = if self.send fields.key('id') then "update_#{klass_name.downcase}" else "create_#{klass_name.downcase}" end
47
37
 
48
38
  url_params = {}
@@ -68,7 +58,7 @@ class ActiveRecord::Base
68
58
  epom_response = klass.send method, url_params, body_params
69
59
 
70
60
  unless self.send fields.key('id')
71
- # save id value returned from Epom in an Advertiser column
61
+ # save id value returned from Epom
72
62
  self.send "#{fields.key('id')}=", epom_response['id']
73
63
  end
74
64
  epom_response['success']
@@ -76,13 +66,12 @@ class ActiveRecord::Base
76
66
  end
77
67
  end
78
68
 
79
- def self.define_before_destroy
69
+ def self.define_before_destroy(klass)
80
70
  unless EpomRails.config.offline
81
- klass = self.epom_klass
82
- fields = self.epom_fields
71
+ klass_name = get_klass_name(klass)
72
+ fields = get_config(klass)[:fields]
83
73
  before_destroy do
84
- if self.send fields.key('id')
85
- klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
74
+ if self.send fields.key('id')
86
75
  epom_response = klass.send "delete_#{klass_name.downcase}", {"#{klass_name.downcase}Id" => self.send(fields.key('id'))}, {}
87
76
  epom_response['success'] if epom_response
88
77
  end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_advertiser(params = {})
4
+ EpomRails.config.advertiser[:model] = self
5
+ acts_as(Epom::Advertiser, params)
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_banner(params = {})
4
+ EpomRails.config.banner[:model] = self
5
+ acts_as(Epom::Banner, params)
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_campaign(params = {})
4
+ EpomRails.config.campaign[:model] = self
5
+ acts_as(Epom::Campaign, params)
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_placement(params = {})
4
+ EpomRails.config.placement[:model] = self
5
+ acts_as(Epom::Placement, params)
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_site(params = {})
4
+ EpomRails.config.site[:model] = self
5
+ acts_as(Epom::Site, params)
6
+ end
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_zone(params = {})
4
+ EpomRails.config.zone[:model] = self
5
+ acts_as(Epom::Zone, params)
6
+ end
7
+
8
+ end
@@ -17,7 +17,7 @@ module EpomRails
17
17
  # need a Class for 3.0
18
18
  class Configuration #:nodoc:
19
19
  include ActiveSupport::Configurable
20
- config_accessor :offline
20
+ config_accessor :offline, :advertiser, :campaign, :banner, :site, :zone, :placement
21
21
 
22
22
  def param_name
23
23
  config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
@@ -32,5 +32,33 @@ module EpomRails
32
32
  # this is ugly. why can't we pass the default value to config_accessor...?
33
33
  EpomRails.configure do |config|
34
34
  config.offline = false
35
+
36
+ config.advertiser = {}
37
+ config.advertiser[:fields] = {epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'}
38
+ config.advertiser[:has_many] = [{:name => 'campaigns', :epom_element => 'Campaign', :model => 'Campaign'}]
39
+
40
+ config.campaign = {}
41
+ config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'}
42
+ config.campaign[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
43
+ config.campaign[:belongs_to] = [{:name => 'advertiser', :epom_element => 'Advertiser', :model => 'Advertiser'}]
44
+
45
+ config.banner = {}
46
+ config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', campaign_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'}
47
+ config.banner[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
48
+ config.banner[:belongs_to] = [{:name => 'campaign', :epom_element => 'Campaign', :model => 'Campaign'}]
49
+
50
+ config.site = {}
51
+ config.site[:fields] = {epom_id: 'id', name: 'name', url: 'url', description: 'description', email: 'email', category_id: 'categoryId'}
52
+ config.site[:has_many] = [{:name => 'zones', :epom_element => 'Zone', :model => 'Zone'}]
53
+
54
+ config.zone = {}
55
+ config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', site_id: 'siteId'}
56
+ config.zone[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
57
+ config.zone[:belongs_to] = [{:name => 'site', :epom_element => 'Site', :model => 'Site'}]
58
+
59
+ config.placement = {}
60
+ config.placement[:fields] = {epom_id: 'id', zone_id: 'zoneId', placement_type: 'type', name: 'name', ad_unit_id: 'adUnitId', size_height: 'size.height', size_width: 'size.width'}
61
+ config.placement[:has_many] = [{:name => 'banners', :epom_element => 'Banner', :model => 'Banner'}]
62
+ config.placement[:belongs_to] = [{:name => 'zone', :epom_element => 'Zone', :model => 'Zone'}]
35
63
  end
36
64
  end
@@ -1,3 +1,3 @@
1
1
  module EpomRails
2
- VERSION = "0.4.9"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/epom_rails.rb CHANGED
@@ -1,18 +1,31 @@
1
1
  require 'epom'
2
2
  require 'epom_rails/acts_as'
3
+ require 'epom_rails/acts_as_advertiser'
4
+ require 'epom_rails/acts_as_campaign'
5
+ require 'epom_rails/acts_as_banner'
6
+ require 'epom_rails/acts_as_site'
7
+ require 'epom_rails/acts_as_zone'
8
+ require 'epom_rails/acts_as_placement'
3
9
 
4
10
  require 'epom_rails/config'
5
11
 
6
12
  module EpomRails
7
- attr_accessor :epom_klass, :epom_fields
8
-
9
- Epom::EpomElement.login(ENV['username'], ENV['password'])
10
-
11
13
  def method_missing(method_name, *args)
12
- if not EpomRails.config.offline and epom_klass.respond_to?(method_name)
13
- epom_klass.send(method_name, args[0], args[1])
14
+ if not EpomRails.config.offline and epom_class.respond_to?(method_name)
15
+ epom_class.send(method_name, args[0], args[1])
14
16
  else
15
17
  super
16
18
  end
17
19
  end
20
+
21
+ private
22
+
23
+ def epom_class
24
+ return Epom::Advertiser if EpomRails.config.advertiser[:model] == self
25
+ return Epom::Campaign if EpomRails.config.campaign[:model] == self
26
+ return Epom::Banner if EpomRails.config.banner[:model] == self
27
+ return Epom::Site if EpomRails.config.site[:model] == self
28
+ return Epom::Zone if EpomRails.config.zone[:model] == self
29
+ return Epom::Placement if EpomRails.config.placement[:model] == self
30
+ end
18
31
  end
@@ -1,3 +1,31 @@
1
1
  EpomRails.configure do |config|
2
- config.offline = false
2
+ config.offline = false
3
+
4
+ config.advertiser = {}
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
+
8
+ config.campaign = {}
9
+ config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'}
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
+
13
+ config.banner = {}
14
+ config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', campaign_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
+
18
+ config.site = {}
19
+ 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
+
22
+ config.zone = {}
23
+ config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', site_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
+
27
+ config.placement = {}
28
+ config.placement[:fields] = {epom_id: 'id', zone_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'}]
3
31
  end
@@ -0,0 +1,58 @@
1
+ class PublishersController < ApplicationController
2
+ before_action :set_publisher, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /publishers
5
+ def index
6
+ @publishers = Publisher.all
7
+ end
8
+
9
+ # GET /publishers/1
10
+ def show
11
+ end
12
+
13
+ # GET /publishers/new
14
+ def new
15
+ @publisher = Publisher.new
16
+ end
17
+
18
+ # GET /publishers/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /publishers
23
+ def create
24
+ @publisher = Publisher.new(publisher_params)
25
+
26
+ if @publisher.save
27
+ redirect_to @publisher, notice: 'Publisher was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /publishers/1
34
+ def update
35
+ if @publisher.update(publisher_params)
36
+ redirect_to @publisher, notice: 'Publisher was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /publishers/1
43
+ def destroy
44
+ @publisher.destroy
45
+ redirect_to publishers_url, notice: 'Publisher was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_publisher
51
+ @publisher = Publisher.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def publisher_params
56
+ params.require(:publisher).permit(:name, :url, :description, :email, :category_id, :epom_id)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module PublishersHelper
2
+ end
@@ -1,3 +1,3 @@
1
1
  class Advertiser < ActiveRecord::Base
2
- acts_as_advertiser epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'
2
+ acts_as_advertiser
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Banner < ActiveRecord::Base
2
- acts_as_banner epom_id: 'id', placement_type: 'placementType', campaign_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'
2
+ acts_as_banner
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Campaign < ActiveRecord::Base
2
- acts_as_campaign epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'
2
+ acts_as_campaign
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Placement < ActiveRecord::Base
2
- acts_as_placement epom_id: 'id', zone_id: 'zoneId', placement_type: 'type', name: 'name', ad_unit_id: 'adUnitId', size_height: 'size.height', size_width: 'size.width'
2
+ acts_as_placement
3
3
  end
@@ -0,0 +1,3 @@
1
+ class Publisher < ActiveRecord::Base
2
+ acts_as_site
3
+ end
@@ -1,3 +1,3 @@
1
1
  class Zone < ActiveRecord::Base
2
- acts_as_zone epom_id: 'id', name: 'name', description: 'description', site_id: 'siteId'
2
+ acts_as_zone belongs_to: [{:name => 'publisher', :epom_element => 'Site', :model => 'Publisher'}]
3
3
  end
@@ -1,20 +1,16 @@
1
- <%= form_for(@site) do |f| %>
2
- <% if @site.errors.any? %>
1
+ <%= form_for(@publisher) do |f| %>
2
+ <% if @publisher.errors.any? %>
3
3
  <div id="error_explanation">
4
- <h2><%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:</h2>
4
+ <h2><%= pluralize(@publisher.errors.count, "error") %> prohibited this publisher from being saved:</h2>
5
5
 
6
6
  <ul>
7
- <% @site.errors.full_messages.each do |message| %>
7
+ <% @publisher.errors.full_messages.each do |message| %>
8
8
  <li><%= message %></li>
9
9
  <% end %>
10
10
  </ul>
11
11
  </div>
12
12
  <% end %>
13
13
 
14
- <div class="field">
15
- <%= f.label :epom_id %><br>
16
- <%= f.number_field :epom_id %>
17
- </div>
18
14
  <div class="field">
19
15
  <%= f.label :name %><br>
20
16
  <%= f.text_field :name %>
@@ -35,6 +31,10 @@
35
31
  <%= f.label :category_id %><br>
36
32
  <%= f.number_field :category_id %>
37
33
  </div>
34
+ <div class="field">
35
+ <%= f.label :epom_id %><br>
36
+ <%= f.number_field :epom_id %>
37
+ </div>
38
38
  <div class="actions">
39
39
  <%= f.submit %>
40
40
  </div>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Publisher</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @publisher %> |
6
+ <%= link_to 'Back', publishers_path %>
@@ -0,0 +1,37 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing Publishers</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Url</th>
10
+ <th>Description</th>
11
+ <th>Email</th>
12
+ <th>Category</th>
13
+ <th>Epom</th>
14
+ <th colspan="3"></th>
15
+ </tr>
16
+ </thead>
17
+
18
+ <tbody>
19
+ <% @publishers.each do |publisher| %>
20
+ <tr>
21
+ <td><%= publisher.name %></td>
22
+ <td><%= publisher.url %></td>
23
+ <td><%= publisher.description %></td>
24
+ <td><%= publisher.email %></td>
25
+ <td><%= publisher.category_id %></td>
26
+ <td><%= publisher.epom_id %></td>
27
+ <td><%= link_to 'Show', publisher %></td>
28
+ <td><%= link_to 'Edit', edit_publisher_path(publisher) %></td>
29
+ <td><%= link_to 'Destroy', publisher, method: :delete, data: { confirm: 'Are you sure?' } %></td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+
35
+ <br>
36
+
37
+ <%= link_to 'New Publisher', new_publisher_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Publisher</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', publishers_path %>
@@ -0,0 +1,34 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @publisher.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Url:</strong>
10
+ <%= @publisher.url %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Description:</strong>
15
+ <%= @publisher.description %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong>Email:</strong>
20
+ <%= @publisher.email %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong>Category:</strong>
25
+ <%= @publisher.category_id %>
26
+ </p>
27
+
28
+ <p>
29
+ <strong>Epom:</strong>
30
+ <%= @publisher.epom_id %>
31
+ </p>
32
+
33
+ <%= link_to 'Edit', edit_publisher_path(@publisher) %> |
34
+ <%= link_to 'Back', publishers_path %>
@@ -1,9 +1,9 @@
1
1
  Rails.application.routes.draw do
2
+ resources :publishers
2
3
  resources :placements
3
4
  resources :placements
4
5
  resources :zones
5
6
  resources :sites
6
- resources :sites
7
7
  resources :banners
8
8
  resources :campaigns
9
9
  resources :campaigns
@@ -1,12 +1,12 @@
1
- class CreateSites < ActiveRecord::Migration
1
+ class CreatePublishers < ActiveRecord::Migration
2
2
  def change
3
- create_table :sites do |t|
4
- t.integer :epom_id
3
+ create_table :publishers do |t|
5
4
  t.string :name
6
5
  t.string :url
7
6
  t.text :description
8
7
  t.string :email
9
8
  t.integer :category_id
9
+ t.integer :epom_id
10
10
 
11
11
  t.timestamps null: false
12
12
  end
@@ -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: 20150622181754) do
14
+ ActiveRecord::Schema.define(version: 20150731161340) do
15
15
 
16
16
  create_table "advertisers", force: :cascade do |t|
17
17
  t.string "name"
@@ -61,13 +61,13 @@ ActiveRecord::Schema.define(version: 20150622181754) do
61
61
  t.datetime "updated_at", null: false
62
62
  end
63
63
 
64
- create_table "sites", force: :cascade do |t|
65
- t.integer "epom_id"
64
+ create_table "publishers", force: :cascade do |t|
66
65
  t.string "name"
67
66
  t.string "url"
68
67
  t.text "description"
69
68
  t.string "email"
70
69
  t.integer "category_id"
70
+ t.integer "epom_id"
71
71
  t.datetime "created_at", null: false
72
72
  t.datetime "updated_at", null: false
73
73
  end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class PublishersControllerTest < ActionController::TestCase
4
+ setup do
5
+ @publisher = publishers(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:publishers)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create publisher" do
20
+ assert_difference('Publisher.count') do
21
+ post :create, publisher: { category_id: @publisher.category_id, description: @publisher.description, email: @publisher.email, epom_id: @publisher.epom_id, name: @publisher.name, url: @publisher.url }
22
+ end
23
+
24
+ assert_redirected_to publisher_path(assigns(:publisher))
25
+ end
26
+
27
+ test "should show publisher" do
28
+ get :show, id: @publisher
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @publisher
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update publisher" do
38
+ patch :update, id: @publisher, publisher: { category_id: @publisher.category_id, description: @publisher.description, email: @publisher.email, epom_id: @publisher.epom_id, name: @publisher.name, url: @publisher.url }
39
+ assert_redirected_to publisher_path(assigns(:publisher))
40
+ end
41
+
42
+ test "should destroy publisher" do
43
+ assert_difference('Publisher.count', -1) do
44
+ delete :destroy, id: @publisher
45
+ end
46
+
47
+ assert_redirected_to publishers_path
48
+ end
49
+ end
@@ -5,11 +5,11 @@ one:
5
5
  url: http://www.example.com
6
6
  description: MyText
7
7
  email: user@example.com
8
- category_id: 2
8
+ category_id: 1
9
9
 
10
10
  two:
11
11
  name: MyString
12
12
  url: http://www.example.com
13
13
  description: MyText
14
14
  email: user@example.com
15
- category_id: 2
15
+ category_id: 1
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class SiteTest < ActiveSupport::TestCase
3
+ class PublisherTest < ActiveSupport::TestCase
4
4
  # test "the truth" do
5
5
  # assert true
6
6
  # end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsAdvertiserTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Advertiser.epom_fields.key(field)
5
+ EpomRails.config.advertiser[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsBannerTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Banner.epom_fields.key(field)
5
+ EpomRails.config.banner[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsCampaignTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Campaign.epom_fields.key(field)
5
+ EpomRails.config.campaign[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsPlacementTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Placement.epom_fields.key(field)
5
+ EpomRails.config.placement[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
@@ -2,16 +2,16 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsSiteTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Site.epom_fields.key(field)
5
+ EpomRails.config.site[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
9
- assert_raises NoMethodError do Site.fancy_method end
9
+ assert_raises NoMethodError do Publisher.fancy_method end
10
10
  end
11
11
 
12
12
  test 'save an site' do
13
13
  unless EpomRails.config.offline
14
- site = sites(:one)
14
+ site = publishers(:one)
15
15
 
16
16
  assert site.save
17
17
  assert_instance_of Fixnum, site.send(epom_field('id'))
@@ -33,7 +33,7 @@ class ActsAsSiteTest < ActiveSupport::TestCase
33
33
 
34
34
  test 'delete an site' do
35
35
  unless EpomRails.config.offline
36
- site = sites(:one)
36
+ site = publishers(:one)
37
37
 
38
38
  assert site.save
39
39
  assert_instance_of Fixnum, site.send(epom_field('id'))
@@ -45,12 +45,12 @@ class ActsAsSiteTest < ActiveSupport::TestCase
45
45
 
46
46
  test 'epom methods' do
47
47
  unless EpomRails.config.offline
48
- site = sites(:one)
48
+ site = publishers(:one)
49
49
 
50
50
  assert site.save
51
51
  assert_instance_of Fixnum, site.send(epom_field('id'))
52
52
 
53
- response = Site.get_sites_zones({:siteId => site.send(epom_field('id'))}, {})
53
+ response = Publisher.get_sites_zones({:siteId => site.send(epom_field('id'))}, {})
54
54
  assert_instance_of Array, response
55
55
  end
56
56
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class ActsAsZoneTest < ActiveSupport::TestCase
4
4
  def epom_field(field)
5
- Zone.epom_fields.key(field)
5
+ EpomRails.config.zone[:fields].key(field)
6
6
  end
7
7
 
8
8
  test 'fancy_method' do
@@ -44,4 +44,8 @@ class ActsAsZoneTest < ActiveSupport::TestCase
44
44
  assert_instance_of Array, response
45
45
  end
46
46
  end
47
+
48
+ test 'belongs_to config' do
49
+ assert [{:name => 'publisher', :epom_element => 'Site', :model => 'Publisher'}], EpomRails.config.zone[:belongs_to]
50
+ end
47
51
  end
data/test/test_helper.rb CHANGED
@@ -36,5 +36,33 @@ Epom.configure do |config|
36
36
  end
37
37
 
38
38
  EpomRails.configure do |config|
39
- config.offline = false
39
+ config.offline = false
40
+
41
+ config.advertiser = {}
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
+
45
+ config.campaign = {}
46
+ config.campaign[:fields] = {epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'}
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
+
50
+ config.banner = {}
51
+ config.banner[:fields] = {epom_id: 'id', placement_type: 'placementType', campaign_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
+
55
+ config.site = {}
56
+ 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
+
59
+ config.zone = {}
60
+ config.zone[:fields] = {epom_id: 'id', name: 'name', description: 'description', site_id: 'siteId'}
61
+ config.zone[:has_many] = [{:name => 'placements', :epom_element => 'Placement', :model => 'Placement'}]
62
+ config.zone[:belongs_to] = [{:name => 'site', :epom_element => 'Site', :model => 'Site'}]
63
+
64
+ config.placement = {}
65
+ config.placement[:fields] = {epom_id: 'id', zone_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'}]
40
68
  end
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: 0.4.9
4
+ version: 1.0.0
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-07-22 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -64,6 +64,12 @@ files:
64
64
  - Rakefile
65
65
  - lib/epom_rails.rb
66
66
  - lib/epom_rails/acts_as.rb
67
+ - lib/epom_rails/acts_as_advertiser.rb
68
+ - lib/epom_rails/acts_as_banner.rb
69
+ - lib/epom_rails/acts_as_campaign.rb
70
+ - lib/epom_rails/acts_as_placement.rb
71
+ - lib/epom_rails/acts_as_site.rb
72
+ - lib/epom_rails/acts_as_zone.rb
67
73
  - lib/epom_rails/config.rb
68
74
  - lib/epom_rails/version.rb
69
75
  - lib/generators/epom_rails/config/USAGE
@@ -77,35 +83,35 @@ files:
77
83
  - test/dummy/app/assets/javascripts/banners.js
78
84
  - test/dummy/app/assets/javascripts/campaigns.js
79
85
  - test/dummy/app/assets/javascripts/placements.js
80
- - test/dummy/app/assets/javascripts/sites.js
86
+ - test/dummy/app/assets/javascripts/publishers.js
81
87
  - test/dummy/app/assets/javascripts/zones.js
82
88
  - test/dummy/app/assets/stylesheets/advertisers.css
83
89
  - test/dummy/app/assets/stylesheets/application.css
84
90
  - test/dummy/app/assets/stylesheets/banners.css
85
91
  - test/dummy/app/assets/stylesheets/campaigns.css
86
92
  - test/dummy/app/assets/stylesheets/placements.css
93
+ - test/dummy/app/assets/stylesheets/publishers.css
87
94
  - test/dummy/app/assets/stylesheets/scaffold.css
88
- - test/dummy/app/assets/stylesheets/sites.css
89
95
  - test/dummy/app/assets/stylesheets/zones.css
90
96
  - test/dummy/app/controllers/advertisers_controller.rb
91
97
  - test/dummy/app/controllers/application_controller.rb
92
98
  - test/dummy/app/controllers/banners_controller.rb
93
99
  - test/dummy/app/controllers/campaigns_controller.rb
94
100
  - test/dummy/app/controllers/placements_controller.rb
95
- - test/dummy/app/controllers/sites_controller.rb
101
+ - test/dummy/app/controllers/publishers_controller.rb
96
102
  - test/dummy/app/controllers/zones_controller.rb
97
103
  - test/dummy/app/helpers/advertisers_helper.rb
98
104
  - test/dummy/app/helpers/application_helper.rb
99
105
  - test/dummy/app/helpers/banners_helper.rb
100
106
  - test/dummy/app/helpers/campaigns_helper.rb
101
107
  - test/dummy/app/helpers/placements_helper.rb
102
- - test/dummy/app/helpers/sites_helper.rb
108
+ - test/dummy/app/helpers/publishers_helper.rb
103
109
  - test/dummy/app/helpers/zones_helper.rb
104
110
  - test/dummy/app/models/advertiser.rb
105
111
  - test/dummy/app/models/banner.rb
106
112
  - test/dummy/app/models/campaign.rb
107
113
  - test/dummy/app/models/placement.rb
108
- - test/dummy/app/models/site.rb
114
+ - test/dummy/app/models/publisher.rb
109
115
  - test/dummy/app/models/zone.rb
110
116
  - test/dummy/app/views/advertisers/_form.html.erb
111
117
  - test/dummy/app/views/advertisers/edit.html.erb
@@ -128,11 +134,11 @@ files:
128
134
  - test/dummy/app/views/placements/index.html.erb
129
135
  - test/dummy/app/views/placements/new.html.erb
130
136
  - test/dummy/app/views/placements/show.html.erb
131
- - test/dummy/app/views/sites/_form.html.erb
132
- - test/dummy/app/views/sites/edit.html.erb
133
- - test/dummy/app/views/sites/index.html.erb
134
- - test/dummy/app/views/sites/new.html.erb
135
- - test/dummy/app/views/sites/show.html.erb
137
+ - test/dummy/app/views/publishers/_form.html.erb
138
+ - test/dummy/app/views/publishers/edit.html.erb
139
+ - test/dummy/app/views/publishers/index.html.erb
140
+ - test/dummy/app/views/publishers/new.html.erb
141
+ - test/dummy/app/views/publishers/show.html.erb
136
142
  - test/dummy/app/views/zones/_form.html.erb
137
143
  - test/dummy/app/views/zones/edit.html.erb
138
144
  - test/dummy/app/views/zones/index.html.erb
@@ -166,9 +172,9 @@ files:
166
172
  - test/dummy/db/migrate/20150608194916_create_campaigns.rb
167
173
  - test/dummy/db/migrate/20150608195747_add_epom_id_to_campaigns.rb
168
174
  - test/dummy/db/migrate/20150609175407_create_banners.rb
169
- - test/dummy/db/migrate/20150619174544_create_sites.rb
170
175
  - test/dummy/db/migrate/20150622160449_create_zones.rb
171
176
  - test/dummy/db/migrate/20150622181754_create_placements.rb
177
+ - test/dummy/db/migrate/20150731161340_create_publishers.rb
172
178
  - test/dummy/db/schema.rb
173
179
  - test/dummy/public/404.html
174
180
  - test/dummy/public/422.html
@@ -178,19 +184,19 @@ files:
178
184
  - test/dummy/test/controllers/banners_controller_test.rb
179
185
  - test/dummy/test/controllers/campaigns_controller_test.rb
180
186
  - test/dummy/test/controllers/placements_controller_test.rb
181
- - test/dummy/test/controllers/sites_controller_test.rb
187
+ - test/dummy/test/controllers/publishers_controller_test.rb
182
188
  - test/dummy/test/controllers/zones_controller_test.rb
183
189
  - test/dummy/test/fixtures/advertisers.yml
184
190
  - test/dummy/test/fixtures/banners.yml
185
191
  - test/dummy/test/fixtures/campaigns.yml
186
192
  - test/dummy/test/fixtures/placements.yml
187
- - test/dummy/test/fixtures/sites.yml
193
+ - test/dummy/test/fixtures/publishers.yml
188
194
  - test/dummy/test/fixtures/zones.yml
189
195
  - test/dummy/test/models/advertiser_test.rb
190
196
  - test/dummy/test/models/banner_test.rb
191
197
  - test/dummy/test/models/campaign_test.rb
192
198
  - test/dummy/test/models/placement_test.rb
193
- - test/dummy/test/models/site_test.rb
199
+ - test/dummy/test/models/publisher_test.rb
194
200
  - test/dummy/test/models/zone_test.rb
195
201
  - test/epom_rails/acts_as_advertiser_test.rb
196
202
  - test/epom_rails/acts_as_banner_test.rb
@@ -237,19 +243,19 @@ test_files:
237
243
  - test/dummy/Rakefile
238
244
  - test/dummy/README.rdoc
239
245
  - test/dummy/test/models/zone_test.rb
240
- - test/dummy/test/models/site_test.rb
246
+ - test/dummy/test/models/publisher_test.rb
241
247
  - test/dummy/test/models/placement_test.rb
242
248
  - test/dummy/test/models/campaign_test.rb
243
249
  - test/dummy/test/models/banner_test.rb
244
250
  - test/dummy/test/models/advertiser_test.rb
245
251
  - test/dummy/test/fixtures/zones.yml
246
- - test/dummy/test/fixtures/sites.yml
252
+ - test/dummy/test/fixtures/publishers.yml
247
253
  - test/dummy/test/fixtures/placements.yml
248
254
  - test/dummy/test/fixtures/campaigns.yml
249
255
  - test/dummy/test/fixtures/banners.yml
250
256
  - test/dummy/test/fixtures/advertisers.yml
251
257
  - test/dummy/test/controllers/zones_controller_test.rb
252
- - test/dummy/test/controllers/sites_controller_test.rb
258
+ - test/dummy/test/controllers/publishers_controller_test.rb
253
259
  - test/dummy/test/controllers/placements_controller_test.rb
254
260
  - test/dummy/test/controllers/campaigns_controller_test.rb
255
261
  - test/dummy/test/controllers/banners_controller_test.rb
@@ -259,9 +265,9 @@ test_files:
259
265
  - test/dummy/public/422.html
260
266
  - test/dummy/public/404.html
261
267
  - test/dummy/db/schema.rb
268
+ - test/dummy/db/migrate/20150731161340_create_publishers.rb
262
269
  - test/dummy/db/migrate/20150622181754_create_placements.rb
263
270
  - test/dummy/db/migrate/20150622160449_create_zones.rb
264
- - test/dummy/db/migrate/20150619174544_create_sites.rb
265
271
  - test/dummy/db/migrate/20150609175407_create_banners.rb
266
272
  - test/dummy/db/migrate/20150608195747_add_epom_id_to_campaigns.rb
267
273
  - test/dummy/db/migrate/20150608194916_create_campaigns.rb
@@ -294,11 +300,11 @@ test_files:
294
300
  - test/dummy/app/views/zones/index.html.erb
295
301
  - test/dummy/app/views/zones/edit.html.erb
296
302
  - test/dummy/app/views/zones/_form.html.erb
297
- - test/dummy/app/views/sites/show.html.erb
298
- - test/dummy/app/views/sites/new.html.erb
299
- - test/dummy/app/views/sites/index.html.erb
300
- - test/dummy/app/views/sites/edit.html.erb
301
- - test/dummy/app/views/sites/_form.html.erb
303
+ - test/dummy/app/views/publishers/show.html.erb
304
+ - test/dummy/app/views/publishers/new.html.erb
305
+ - test/dummy/app/views/publishers/index.html.erb
306
+ - test/dummy/app/views/publishers/edit.html.erb
307
+ - test/dummy/app/views/publishers/_form.html.erb
302
308
  - test/dummy/app/views/placements/show.html.erb
303
309
  - test/dummy/app/views/placements/new.html.erb
304
310
  - test/dummy/app/views/placements/index.html.erb
@@ -321,35 +327,35 @@ test_files:
321
327
  - test/dummy/app/views/advertisers/edit.html.erb
322
328
  - test/dummy/app/views/advertisers/_form.html.erb
323
329
  - test/dummy/app/models/zone.rb
324
- - test/dummy/app/models/site.rb
330
+ - test/dummy/app/models/publisher.rb
325
331
  - test/dummy/app/models/placement.rb
326
332
  - test/dummy/app/models/campaign.rb
327
333
  - test/dummy/app/models/banner.rb
328
334
  - test/dummy/app/models/advertiser.rb
329
335
  - test/dummy/app/helpers/zones_helper.rb
330
- - test/dummy/app/helpers/sites_helper.rb
336
+ - test/dummy/app/helpers/publishers_helper.rb
331
337
  - test/dummy/app/helpers/placements_helper.rb
332
338
  - test/dummy/app/helpers/campaigns_helper.rb
333
339
  - test/dummy/app/helpers/banners_helper.rb
334
340
  - test/dummy/app/helpers/application_helper.rb
335
341
  - test/dummy/app/helpers/advertisers_helper.rb
336
342
  - test/dummy/app/controllers/zones_controller.rb
337
- - test/dummy/app/controllers/sites_controller.rb
343
+ - test/dummy/app/controllers/publishers_controller.rb
338
344
  - test/dummy/app/controllers/placements_controller.rb
339
345
  - test/dummy/app/controllers/campaigns_controller.rb
340
346
  - test/dummy/app/controllers/banners_controller.rb
341
347
  - test/dummy/app/controllers/application_controller.rb
342
348
  - test/dummy/app/controllers/advertisers_controller.rb
343
349
  - test/dummy/app/assets/stylesheets/zones.css
344
- - test/dummy/app/assets/stylesheets/sites.css
345
350
  - test/dummy/app/assets/stylesheets/scaffold.css
351
+ - test/dummy/app/assets/stylesheets/publishers.css
346
352
  - test/dummy/app/assets/stylesheets/placements.css
347
353
  - test/dummy/app/assets/stylesheets/campaigns.css
348
354
  - test/dummy/app/assets/stylesheets/banners.css
349
355
  - test/dummy/app/assets/stylesheets/application.css
350
356
  - test/dummy/app/assets/stylesheets/advertisers.css
351
357
  - test/dummy/app/assets/javascripts/zones.js
352
- - test/dummy/app/assets/javascripts/sites.js
358
+ - test/dummy/app/assets/javascripts/publishers.js
353
359
  - test/dummy/app/assets/javascripts/placements.js
354
360
  - test/dummy/app/assets/javascripts/campaigns.js
355
361
  - test/dummy/app/assets/javascripts/banners.js
@@ -1,58 +0,0 @@
1
- class SitesController < ApplicationController
2
- before_action :set_site, only: [:show, :edit, :update, :destroy]
3
-
4
- # GET /sites
5
- def index
6
- @sites = Site.all
7
- end
8
-
9
- # GET /sites/1
10
- def show
11
- end
12
-
13
- # GET /sites/new
14
- def new
15
- @site = Site.new
16
- end
17
-
18
- # GET /sites/1/edit
19
- def edit
20
- end
21
-
22
- # POST /sites
23
- def create
24
- @site = Site.new(site_params)
25
-
26
- if @site.save
27
- redirect_to @site, notice: 'Site was successfully created.'
28
- else
29
- render :new
30
- end
31
- end
32
-
33
- # PATCH/PUT /sites/1
34
- def update
35
- if @site.update(site_params)
36
- redirect_to @site, notice: 'Site was successfully updated.'
37
- else
38
- render :edit
39
- end
40
- end
41
-
42
- # DELETE /sites/1
43
- def destroy
44
- @site.destroy
45
- redirect_to sites_url, notice: 'Site was successfully destroyed.'
46
- end
47
-
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_site
51
- @site = Site.find(params[:id])
52
- end
53
-
54
- # Only allow a trusted parameter "white list" through.
55
- def site_params
56
- params.require(:site).permit(:epom_id, :name, :url, :description, :email, :category_id)
57
- end
58
- end
@@ -1,2 +0,0 @@
1
- module SitesHelper
2
- end
@@ -1,3 +0,0 @@
1
- class Site < ActiveRecord::Base
2
- acts_as_site epom_id: 'id', name: 'name', url: 'url', description: 'description', email: 'email', category_id: 'categoryId'
3
- end
@@ -1,6 +0,0 @@
1
- <h1>Editing Site</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @site %> |
6
- <%= link_to 'Back', sites_path %>
@@ -1,37 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <h1>Listing Sites</h1>
4
-
5
- <table>
6
- <thead>
7
- <tr>
8
- <th>Epom</th>
9
- <th>Name</th>
10
- <th>Url</th>
11
- <th>Description</th>
12
- <th>Email</th>
13
- <th>Category</th>
14
- <th colspan="3"></th>
15
- </tr>
16
- </thead>
17
-
18
- <tbody>
19
- <% @sites.each do |site| %>
20
- <tr>
21
- <td><%= site.epom_id %></td>
22
- <td><%= site.name %></td>
23
- <td><%= site.url %></td>
24
- <td><%= site.description %></td>
25
- <td><%= site.email %></td>
26
- <td><%= site.category_id %></td>
27
- <td><%= link_to 'Show', site %></td>
28
- <td><%= link_to 'Edit', edit_site_path(site) %></td>
29
- <td><%= link_to 'Destroy', site, method: :delete, data: { confirm: 'Are you sure?' } %></td>
30
- </tr>
31
- <% end %>
32
- </tbody>
33
- </table>
34
-
35
- <br>
36
-
37
- <%= link_to 'New Site', new_site_path %>
@@ -1,5 +0,0 @@
1
- <h1>New Site</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', sites_path %>
@@ -1,34 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <strong>Epom:</strong>
5
- <%= @site.epom_id %>
6
- </p>
7
-
8
- <p>
9
- <strong>Name:</strong>
10
- <%= @site.name %>
11
- </p>
12
-
13
- <p>
14
- <strong>Url:</strong>
15
- <%= @site.url %>
16
- </p>
17
-
18
- <p>
19
- <strong>Description:</strong>
20
- <%= @site.description %>
21
- </p>
22
-
23
- <p>
24
- <strong>Email:</strong>
25
- <%= @site.email %>
26
- </p>
27
-
28
- <p>
29
- <strong>Category:</strong>
30
- <%= @site.category_id %>
31
- </p>
32
-
33
- <%= link_to 'Edit', edit_site_path(@site) %> |
34
- <%= link_to 'Back', sites_path %>
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SitesControllerTest < ActionController::TestCase
4
- setup do
5
- @site = sites(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:sites)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create site" do
20
- assert_difference('Site.count') do
21
- post :create, site: { category_id: @site.category_id, description: @site.description, email: @site.email, epom_id: @site.epom_id, name: @site.name, url: @site.url }
22
- end
23
-
24
- assert_redirected_to site_path(assigns(:site))
25
- end
26
-
27
- test "should show site" do
28
- get :show, id: @site
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @site
34
- assert_response :success
35
- end
36
-
37
- test "should update site" do
38
- patch :update, id: @site, site: { category_id: @site.category_id, description: @site.description, email: @site.email, epom_id: @site.epom_id, name: @site.name, url: @site.url }
39
- assert_redirected_to site_path(assigns(:site))
40
- end
41
-
42
- test "should destroy site" do
43
- assert_difference('Site.count', -1) do
44
- delete :destroy, id: @site
45
- end
46
-
47
- assert_redirected_to sites_path
48
- end
49
- end