epom_rails 0.2 → 0.3
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 +24 -16
- data/lib/epom_rails/version.rb +1 -1
- data/lib/epom_rails.rb +2 -0
- data/test/dummy/app/assets/javascripts/banners.js +2 -0
- data/test/dummy/app/assets/stylesheets/banners.css +4 -0
- data/test/dummy/app/controllers/banners_controller.rb +58 -0
- data/test/dummy/app/helpers/banners_helper.rb +2 -0
- data/test/dummy/app/models/banner.rb +3 -0
- data/test/dummy/app/views/banners/_form.html.erb +61 -0
- data/test/dummy/app/views/banners/edit.html.erb +6 -0
- data/test/dummy/app/views/banners/index.html.erb +47 -0
- data/test/dummy/app/views/banners/new.html.erb +5 -0
- data/test/dummy/app/views/banners/show.html.erb +59 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/db/migrate/20150608195747_add_epom_id_to_campaigns.rb +5 -0
- data/test/dummy/db/migrate/20150609175407_create_banners.rb +19 -0
- data/test/dummy/db/schema.rb +17 -1
- data/test/dummy/test/controllers/banners_controller_test.rb +49 -0
- data/test/dummy/test/fixtures/banners.yml +13 -0
- data/test/dummy/test/models/banner_test.rb +7 -0
- data/test/epom_rails/acts_as_banner_test.rb +42 -0
- data/test/epom_rails/acts_as_campaign_test.rb +40 -0
- data/test/test_helper.rb +1 -3
- metadata +35 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d88b3789f18a9ff4b47d9318c70280bed18fd8b
|
4
|
+
data.tar.gz: 9264c734b76b1fc35c6e1a7e23cf951a845c47eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 983f66102b4a91e1c8a835bf1ba8d358dbcb4620dc28e4296e5aefeb71a0e39fd199596dc1cd177655dc74386b80f340f7e791e1e987e44db40dd70cd3e2891d
|
7
|
+
data.tar.gz: d4b82d0b69e798fb4f0b5ab45ac2d7246f8e385d5d648b1893f5283cee6107484ee8864acf6af9e1995c36b9cec2281d56df073509bba17aaba1b3f896d30afb
|
data/lib/epom_rails/acts_as.rb
CHANGED
@@ -8,6 +8,10 @@ class ActiveRecord::Base
|
|
8
8
|
acts_as(Epom::Campaign, fields)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.acts_as_banner(fields = {})
|
12
|
+
acts_as(Epom::Banner, fields)
|
13
|
+
end
|
14
|
+
|
11
15
|
private
|
12
16
|
|
13
17
|
def self.acts_as(klass, fields = {})
|
@@ -26,21 +30,25 @@ class ActiveRecord::Base
|
|
26
30
|
before_save do
|
27
31
|
klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
method = if self.send fields.key('id') then "update_#{klass_name.downcase}" else "create_#{klass_name.downcase}" end
|
34
|
+
|
35
|
+
url_params = {}
|
36
|
+
if klass.extended_methods[method.to_sym][:url_parameters]
|
37
|
+
klass.extended_methods[method.to_sym][:url_parameters].each do |parameter|
|
38
|
+
url_params[parameter] = self.send(fields.key(parameter.to_s)) if fields.key(parameter.to_s)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
body_params = {}
|
43
|
+
if klass.extended_methods[method.to_sym][:body_parameters]
|
44
|
+
klass.extended_methods[method.to_sym][:body_parameters].each do |parameter|
|
45
|
+
body_params[parameter] = self.send(fields.key(parameter.to_s)) if fields.key(parameter.to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
epom_response = klass.send method, url_params, body_params
|
50
|
+
|
51
|
+
unless self.send fields.key('id')
|
44
52
|
# save id value returned from Epom in an Advertiser column
|
45
53
|
self.send "#{fields.key('id')}=", epom_response['id']
|
46
54
|
end
|
@@ -55,7 +63,7 @@ class ActiveRecord::Base
|
|
55
63
|
if self.send fields.key('id')
|
56
64
|
klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
|
57
65
|
epom_response = klass.send "delete_#{klass_name.downcase}", {"#{klass_name.downcase}Id" => self.send(fields.key('id'))}, {}
|
58
|
-
epom_response['success']
|
66
|
+
epom_response['success'] if epom_response
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
data/lib/epom_rails/version.rb
CHANGED
data/lib/epom_rails.rb
CHANGED
@@ -4,6 +4,8 @@ require 'epom_rails/acts_as'
|
|
4
4
|
module EpomRails
|
5
5
|
attr_accessor :epom_klass, :epom_fields
|
6
6
|
|
7
|
+
Epom::EpomElement.login(ENV['username'], ENV['password'])
|
8
|
+
|
7
9
|
def method_missing(method_name, *args)
|
8
10
|
if epom_klass.respond_to?(method_name)
|
9
11
|
epom_klass.send(method_name, args[0], args[1])
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class BannersController < ApplicationController
|
2
|
+
before_action :set_banner, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
# GET /banners
|
5
|
+
def index
|
6
|
+
@banners = Banner.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /banners/1
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /banners/new
|
14
|
+
def new
|
15
|
+
@banner = Banner.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /banners/1/edit
|
19
|
+
def edit
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /banners
|
23
|
+
def create
|
24
|
+
@banner = Banner.new(banner_params)
|
25
|
+
|
26
|
+
if @banner.save
|
27
|
+
redirect_to @banner, notice: 'Banner was successfully created.'
|
28
|
+
else
|
29
|
+
render :new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# PATCH/PUT /banners/1
|
34
|
+
def update
|
35
|
+
if @banner.update(banner_params)
|
36
|
+
redirect_to @banner, notice: 'Banner was successfully updated.'
|
37
|
+
else
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /banners/1
|
43
|
+
def destroy
|
44
|
+
@banner.destroy
|
45
|
+
redirect_to banners_url, notice: 'Banner was successfully destroyed.'
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
# Use callbacks to share common setup or constraints between actions.
|
50
|
+
def set_banner
|
51
|
+
@banner = Banner.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only allow a trusted parameter "white list" through.
|
55
|
+
def banner_params
|
56
|
+
params.require(:banner).permit(:epom_id, :placement_type, :campaign_id, :weight, :image_banner_link, :url, :name, :banner_type, :ad_unit_id, :ad_unit_width, :ad_unit_height)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,3 @@
|
|
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'
|
3
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<%= form_for(@banner) do |f| %>
|
2
|
+
<% if @banner.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@banner.errors.count, "error") %> prohibited this banner from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @banner.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :epom_id %><br>
|
16
|
+
<%= f.number_field :epom_id %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :placement_type %><br>
|
20
|
+
<%= f.text_field :placement_type %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :campaign_id %><br>
|
24
|
+
<%= f.number_field :campaign_id %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :weight %><br>
|
28
|
+
<%= f.number_field :weight %>
|
29
|
+
</div>
|
30
|
+
<div class="field">
|
31
|
+
<%= f.label :image_banner_link %><br>
|
32
|
+
<%= f.text_field :image_banner_link %>
|
33
|
+
</div>
|
34
|
+
<div class="field">
|
35
|
+
<%= f.label :url %><br>
|
36
|
+
<%= f.text_field :url %>
|
37
|
+
</div>
|
38
|
+
<div class="field">
|
39
|
+
<%= f.label :name %><br>
|
40
|
+
<%= f.text_field :name %>
|
41
|
+
</div>
|
42
|
+
<div class="field">
|
43
|
+
<%= f.label :banner_type %><br>
|
44
|
+
<%= f.text_field :banner_type %>
|
45
|
+
</div>
|
46
|
+
<div class="field">
|
47
|
+
<%= f.label :ad_unit_id %><br>
|
48
|
+
<%= f.number_field :ad_unit_id %>
|
49
|
+
</div>
|
50
|
+
<div class="field">
|
51
|
+
<%= f.label :ad_unit_width %><br>
|
52
|
+
<%= f.number_field :ad_unit_width %>
|
53
|
+
</div>
|
54
|
+
<div class="field">
|
55
|
+
<%= f.label :ad_unit_height %><br>
|
56
|
+
<%= f.number_field :ad_unit_height %>
|
57
|
+
</div>
|
58
|
+
<div class="actions">
|
59
|
+
<%= f.submit %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Listing Banners</h1>
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>Epom</th>
|
9
|
+
<th>Placement type</th>
|
10
|
+
<th>Campaign</th>
|
11
|
+
<th>Weight</th>
|
12
|
+
<th>Image banner link</th>
|
13
|
+
<th>Url</th>
|
14
|
+
<th>Name</th>
|
15
|
+
<th>Banner type</th>
|
16
|
+
<th>Ad unit</th>
|
17
|
+
<th>Ad unit width</th>
|
18
|
+
<th>Ad unit height</th>
|
19
|
+
<th colspan="3"></th>
|
20
|
+
</tr>
|
21
|
+
</thead>
|
22
|
+
|
23
|
+
<tbody>
|
24
|
+
<% @banners.each do |banner| %>
|
25
|
+
<tr>
|
26
|
+
<td><%= banner.epom_id %></td>
|
27
|
+
<td><%= banner.placement_type %></td>
|
28
|
+
<td><%= banner.campaign_id %></td>
|
29
|
+
<td><%= banner.weight %></td>
|
30
|
+
<td><%= banner.image_banner_link %></td>
|
31
|
+
<td><%= banner.url %></td>
|
32
|
+
<td><%= banner.name %></td>
|
33
|
+
<td><%= banner.banner_type %></td>
|
34
|
+
<td><%= banner.ad_unit_id %></td>
|
35
|
+
<td><%= banner.ad_unit_width %></td>
|
36
|
+
<td><%= banner.ad_unit_height %></td>
|
37
|
+
<td><%= link_to 'Show', banner %></td>
|
38
|
+
<td><%= link_to 'Edit', edit_banner_path(banner) %></td>
|
39
|
+
<td><%= link_to 'Destroy', banner, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
42
|
+
</tbody>
|
43
|
+
</table>
|
44
|
+
|
45
|
+
<br>
|
46
|
+
|
47
|
+
<%= link_to 'New Banner', new_banner_path %>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Epom:</strong>
|
5
|
+
<%= @banner.epom_id %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Placement type:</strong>
|
10
|
+
<%= @banner.placement_type %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<strong>Campaign:</strong>
|
15
|
+
<%= @banner.campaign_id %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<strong>Weight:</strong>
|
20
|
+
<%= @banner.weight %>
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<p>
|
24
|
+
<strong>Image banner link:</strong>
|
25
|
+
<%= @banner.image_banner_link %>
|
26
|
+
</p>
|
27
|
+
|
28
|
+
<p>
|
29
|
+
<strong>Url:</strong>
|
30
|
+
<%= @banner.url %>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<p>
|
34
|
+
<strong>Name:</strong>
|
35
|
+
<%= @banner.name %>
|
36
|
+
</p>
|
37
|
+
|
38
|
+
<p>
|
39
|
+
<strong>Banner type:</strong>
|
40
|
+
<%= @banner.banner_type %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
<p>
|
44
|
+
<strong>Ad unit:</strong>
|
45
|
+
<%= @banner.ad_unit_id %>
|
46
|
+
</p>
|
47
|
+
|
48
|
+
<p>
|
49
|
+
<strong>Ad unit width:</strong>
|
50
|
+
<%= @banner.ad_unit_width %>
|
51
|
+
</p>
|
52
|
+
|
53
|
+
<p>
|
54
|
+
<strong>Ad unit height:</strong>
|
55
|
+
<%= @banner.ad_unit_height %>
|
56
|
+
</p>
|
57
|
+
|
58
|
+
<%= link_to 'Edit', edit_banner_path(@banner) %> |
|
59
|
+
<%= link_to 'Back', banners_path %>
|
data/test/dummy/config/routes.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateBanners < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :banners do |t|
|
4
|
+
t.integer :epom_id
|
5
|
+
t.string :placement_type
|
6
|
+
t.integer :campaign_id
|
7
|
+
t.integer :weight
|
8
|
+
t.string :image_banner_link
|
9
|
+
t.string :url
|
10
|
+
t.string :name
|
11
|
+
t.string :banner_type
|
12
|
+
t.integer :ad_unit_id
|
13
|
+
t.integer :ad_unit_width
|
14
|
+
t.integer :ad_unit_height
|
15
|
+
|
16
|
+
t.timestamps null: false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
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: 20150609175407) do
|
15
15
|
|
16
16
|
create_table "advertisers", force: :cascade do |t|
|
17
17
|
t.string "name"
|
@@ -23,6 +23,22 @@ ActiveRecord::Schema.define(version: 20150608195747) do
|
|
23
23
|
t.integer "epom_id"
|
24
24
|
end
|
25
25
|
|
26
|
+
create_table "banners", force: :cascade do |t|
|
27
|
+
t.integer "epom_id"
|
28
|
+
t.string "placement_type"
|
29
|
+
t.integer "campaign_id"
|
30
|
+
t.integer "weight"
|
31
|
+
t.string "image_banner_link"
|
32
|
+
t.string "url"
|
33
|
+
t.string "name"
|
34
|
+
t.string "banner_type"
|
35
|
+
t.integer "ad_unit_id"
|
36
|
+
t.integer "ad_unit_width"
|
37
|
+
t.integer "ad_unit_height"
|
38
|
+
t.datetime "created_at", null: false
|
39
|
+
t.datetime "updated_at", null: false
|
40
|
+
end
|
41
|
+
|
26
42
|
create_table "campaigns", force: :cascade do |t|
|
27
43
|
t.string "name"
|
28
44
|
t.integer "advertiser_id"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BannersControllerTest < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@banner = banners(:one)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get index" do
|
9
|
+
get :index
|
10
|
+
assert_response :success
|
11
|
+
assert_not_nil assigns(:banners)
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should get new" do
|
15
|
+
get :new
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should create banner" do
|
20
|
+
assert_difference('Banner.count') do
|
21
|
+
post :create, banner: { ad_unit_height: @banner.ad_unit_height, ad_unit_id: @banner.ad_unit_id, ad_unit_width: @banner.ad_unit_width, banner_type: @banner.banner_type, campaign_id: @banner.campaign_id, epom_id: @banner.epom_id, image_banner_link: @banner.image_banner_link, name: @banner.name, placement_type: @banner.placement_type, url: @banner.url, weight: @banner.weight }
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_redirected_to banner_path(assigns(:banner))
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should show banner" do
|
28
|
+
get :show, id: @banner
|
29
|
+
assert_response :success
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should get edit" do
|
33
|
+
get :edit, id: @banner
|
34
|
+
assert_response :success
|
35
|
+
end
|
36
|
+
|
37
|
+
test "should update banner" do
|
38
|
+
patch :update, id: @banner, banner: { ad_unit_height: @banner.ad_unit_height, ad_unit_id: @banner.ad_unit_id, ad_unit_width: @banner.ad_unit_width, banner_type: @banner.banner_type, campaign_id: @banner.campaign_id, epom_id: @banner.epom_id, image_banner_link: @banner.image_banner_link, name: @banner.name, placement_type: @banner.placement_type, url: @banner.url, weight: @banner.weight }
|
39
|
+
assert_redirected_to banner_path(assigns(:banner))
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should destroy banner" do
|
43
|
+
assert_difference('Banner.count', -1) do
|
44
|
+
delete :destroy, id: @banner
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_redirected_to banners_path
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
placement_type: SITE_PLACEMENT
|
5
|
+
campaign_id: 1247
|
6
|
+
weight: 1
|
7
|
+
image_banner_link: http://www.kewelta.com/images/imago_kewelta.png
|
8
|
+
url: http://www.kewelta.com
|
9
|
+
name: kewelta
|
10
|
+
banner_type: EXTERNAL_FILE
|
11
|
+
ad_unit_id: 10
|
12
|
+
ad_unit_width: 164
|
13
|
+
ad_unit_height: 182
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActsAsBannerTest < ActiveSupport::TestCase
|
4
|
+
def epom_field(field)
|
5
|
+
Banner.epom_fields.key(field)
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'fancy_method' do
|
9
|
+
assert_raises NoMethodError do Banner.fancy_method end
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'save an banner' do
|
13
|
+
banner = banners(:one)
|
14
|
+
|
15
|
+
assert banner.save
|
16
|
+
assert_instance_of Fixnum, banner.send(epom_field('id'))
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'delete an banner' do
|
20
|
+
banner = banners(:one)
|
21
|
+
|
22
|
+
assert banner.save
|
23
|
+
assert_instance_of Fixnum, banner.send(epom_field('id'))
|
24
|
+
|
25
|
+
epom_id = banner.send(epom_field('id'))
|
26
|
+
assert banner.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'epom methods' do
|
30
|
+
banner = banners(:one)
|
31
|
+
|
32
|
+
assert banner.save
|
33
|
+
assert_instance_of Fixnum, banner.send(epom_field('id'))
|
34
|
+
|
35
|
+
response = Banner.get_banner({:bannerId => banner.send(epom_field('id'))}, {})
|
36
|
+
assert_equal banner.campaign_id, response['campaignId']
|
37
|
+
assert_equal banner.weight, response['weight']
|
38
|
+
assert_equal banner.url, response['url']
|
39
|
+
assert_equal banner.name, response['name']
|
40
|
+
assert_equal banner.image_banner_link, response['imageBannerLink']
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActsAsCampaignTest < ActiveSupport::TestCase
|
4
|
+
def epom_field(field)
|
5
|
+
Campaign.epom_fields.key(field)
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'fancy_method' do
|
9
|
+
assert_raises NoMethodError do Campaign.fancy_method end
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'save an campaign' do
|
13
|
+
campaign = campaigns(:one)
|
14
|
+
|
15
|
+
assert campaign.save
|
16
|
+
assert_instance_of Fixnum, campaign.send(epom_field('id'))
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'delete an campaign' do
|
20
|
+
campaign = campaigns(:one)
|
21
|
+
|
22
|
+
assert campaign.save
|
23
|
+
assert_instance_of Fixnum, campaign.send(epom_field('id'))
|
24
|
+
|
25
|
+
epom_id = campaign.send(epom_field('id'))
|
26
|
+
assert campaign.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'epom methods' do
|
30
|
+
campaign = campaigns(:one)
|
31
|
+
|
32
|
+
assert campaign.save
|
33
|
+
assert_instance_of Fixnum, campaign.send(epom_field('id'))
|
34
|
+
|
35
|
+
response = Campaign.get_campaign({:campaignId => campaign.send(epom_field('id'))}, {})
|
36
|
+
assert_equal campaign.send(epom_field('id')), response['id']
|
37
|
+
assert_equal campaign.send(epom_field('name')), response['name']
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -22,6 +22,4 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
22
22
|
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
23
23
|
ActiveSupport::TestCase.fixture_path = File.expand_path("../dummy/test/fixtures", __FILE__)
|
24
24
|
ActiveSupport::TestCase.fixtures :all
|
25
|
-
end
|
26
|
-
|
27
|
-
Epom::EpomElement.login(ENV['username'], ENV['password'])
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epom_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Chang
|
@@ -70,24 +70,34 @@ files:
|
|
70
70
|
- test/dummy/Rakefile
|
71
71
|
- test/dummy/app/assets/javascripts/advertisers.js
|
72
72
|
- test/dummy/app/assets/javascripts/application.js
|
73
|
+
- test/dummy/app/assets/javascripts/banners.js
|
73
74
|
- test/dummy/app/assets/javascripts/campaigns.js
|
74
75
|
- test/dummy/app/assets/stylesheets/advertisers.css
|
75
76
|
- test/dummy/app/assets/stylesheets/application.css
|
77
|
+
- test/dummy/app/assets/stylesheets/banners.css
|
76
78
|
- test/dummy/app/assets/stylesheets/campaigns.css
|
77
79
|
- test/dummy/app/assets/stylesheets/scaffold.css
|
78
80
|
- test/dummy/app/controllers/advertisers_controller.rb
|
79
81
|
- test/dummy/app/controllers/application_controller.rb
|
82
|
+
- test/dummy/app/controllers/banners_controller.rb
|
80
83
|
- test/dummy/app/controllers/campaigns_controller.rb
|
81
84
|
- test/dummy/app/helpers/advertisers_helper.rb
|
82
85
|
- test/dummy/app/helpers/application_helper.rb
|
86
|
+
- test/dummy/app/helpers/banners_helper.rb
|
83
87
|
- test/dummy/app/helpers/campaigns_helper.rb
|
84
88
|
- test/dummy/app/models/advertiser.rb
|
89
|
+
- test/dummy/app/models/banner.rb
|
85
90
|
- test/dummy/app/models/campaign.rb
|
86
91
|
- test/dummy/app/views/advertisers/_form.html.erb
|
87
92
|
- test/dummy/app/views/advertisers/edit.html.erb
|
88
93
|
- test/dummy/app/views/advertisers/index.html.erb
|
89
94
|
- test/dummy/app/views/advertisers/new.html.erb
|
90
95
|
- test/dummy/app/views/advertisers/show.html.erb
|
96
|
+
- test/dummy/app/views/banners/_form.html.erb
|
97
|
+
- test/dummy/app/views/banners/edit.html.erb
|
98
|
+
- test/dummy/app/views/banners/index.html.erb
|
99
|
+
- test/dummy/app/views/banners/new.html.erb
|
100
|
+
- test/dummy/app/views/banners/show.html.erb
|
91
101
|
- test/dummy/app/views/campaigns/_form.html.erb
|
92
102
|
- test/dummy/app/views/campaigns/edit.html.erb
|
93
103
|
- test/dummy/app/views/campaigns/index.html.erb
|
@@ -120,18 +130,25 @@ files:
|
|
120
130
|
- test/dummy/db/migrate/20150603151041_create_advertisers.rb
|
121
131
|
- test/dummy/db/migrate/20150604125603_add_epom_id_to_advertiser.rb
|
122
132
|
- test/dummy/db/migrate/20150608194916_create_campaigns.rb
|
133
|
+
- test/dummy/db/migrate/20150608195747_add_epom_id_to_campaigns.rb
|
134
|
+
- test/dummy/db/migrate/20150609175407_create_banners.rb
|
123
135
|
- test/dummy/db/schema.rb
|
124
136
|
- test/dummy/public/404.html
|
125
137
|
- test/dummy/public/422.html
|
126
138
|
- test/dummy/public/500.html
|
127
139
|
- test/dummy/public/favicon.ico
|
128
140
|
- test/dummy/test/controllers/advertisers_controller_test.rb
|
141
|
+
- test/dummy/test/controllers/banners_controller_test.rb
|
129
142
|
- test/dummy/test/controllers/campaigns_controller_test.rb
|
130
143
|
- test/dummy/test/fixtures/advertisers.yml
|
144
|
+
- test/dummy/test/fixtures/banners.yml
|
131
145
|
- test/dummy/test/fixtures/campaigns.yml
|
132
146
|
- test/dummy/test/models/advertiser_test.rb
|
147
|
+
- test/dummy/test/models/banner_test.rb
|
133
148
|
- test/dummy/test/models/campaign_test.rb
|
134
149
|
- test/epom_rails/acts_as_advertiser_test.rb
|
150
|
+
- test/epom_rails/acts_as_banner_test.rb
|
151
|
+
- test/epom_rails/acts_as_campaign_test.rb
|
135
152
|
- test/epom_rails_test.rb
|
136
153
|
- test/test_helper.rb
|
137
154
|
homepage: https://github.com/kewelta/epom_rails
|
@@ -161,21 +178,28 @@ summary: EpomRails gem.
|
|
161
178
|
test_files:
|
162
179
|
- test/test_helper.rb
|
163
180
|
- test/epom_rails_test.rb
|
181
|
+
- test/epom_rails/acts_as_campaign_test.rb
|
182
|
+
- test/epom_rails/acts_as_banner_test.rb
|
164
183
|
- test/epom_rails/acts_as_advertiser_test.rb
|
165
184
|
- test/dummy/config.ru
|
166
185
|
- test/dummy/Rakefile
|
167
186
|
- test/dummy/README.rdoc
|
168
187
|
- test/dummy/test/models/campaign_test.rb
|
188
|
+
- test/dummy/test/models/banner_test.rb
|
169
189
|
- test/dummy/test/models/advertiser_test.rb
|
170
190
|
- test/dummy/test/fixtures/campaigns.yml
|
191
|
+
- test/dummy/test/fixtures/banners.yml
|
171
192
|
- test/dummy/test/fixtures/advertisers.yml
|
172
193
|
- test/dummy/test/controllers/campaigns_controller_test.rb
|
194
|
+
- test/dummy/test/controllers/banners_controller_test.rb
|
173
195
|
- test/dummy/test/controllers/advertisers_controller_test.rb
|
174
196
|
- test/dummy/public/favicon.ico
|
175
197
|
- test/dummy/public/500.html
|
176
198
|
- test/dummy/public/422.html
|
177
199
|
- test/dummy/public/404.html
|
178
200
|
- test/dummy/db/schema.rb
|
201
|
+
- test/dummy/db/migrate/20150609175407_create_banners.rb
|
202
|
+
- test/dummy/db/migrate/20150608195747_add_epom_id_to_campaigns.rb
|
179
203
|
- test/dummy/db/migrate/20150608194916_create_campaigns.rb
|
180
204
|
- test/dummy/db/migrate/20150604125603_add_epom_id_to_advertiser.rb
|
181
205
|
- test/dummy/db/migrate/20150603151041_create_advertisers.rb
|
@@ -207,23 +231,33 @@ test_files:
|
|
207
231
|
- test/dummy/app/views/campaigns/index.html.erb
|
208
232
|
- test/dummy/app/views/campaigns/edit.html.erb
|
209
233
|
- test/dummy/app/views/campaigns/_form.html.erb
|
234
|
+
- test/dummy/app/views/banners/show.html.erb
|
235
|
+
- test/dummy/app/views/banners/new.html.erb
|
236
|
+
- test/dummy/app/views/banners/index.html.erb
|
237
|
+
- test/dummy/app/views/banners/edit.html.erb
|
238
|
+
- test/dummy/app/views/banners/_form.html.erb
|
210
239
|
- test/dummy/app/views/advertisers/show.html.erb
|
211
240
|
- test/dummy/app/views/advertisers/new.html.erb
|
212
241
|
- test/dummy/app/views/advertisers/index.html.erb
|
213
242
|
- test/dummy/app/views/advertisers/edit.html.erb
|
214
243
|
- test/dummy/app/views/advertisers/_form.html.erb
|
215
244
|
- test/dummy/app/models/campaign.rb
|
245
|
+
- test/dummy/app/models/banner.rb
|
216
246
|
- test/dummy/app/models/advertiser.rb
|
217
247
|
- test/dummy/app/helpers/campaigns_helper.rb
|
248
|
+
- test/dummy/app/helpers/banners_helper.rb
|
218
249
|
- test/dummy/app/helpers/application_helper.rb
|
219
250
|
- test/dummy/app/helpers/advertisers_helper.rb
|
220
251
|
- test/dummy/app/controllers/campaigns_controller.rb
|
252
|
+
- test/dummy/app/controllers/banners_controller.rb
|
221
253
|
- test/dummy/app/controllers/application_controller.rb
|
222
254
|
- test/dummy/app/controllers/advertisers_controller.rb
|
223
255
|
- test/dummy/app/assets/stylesheets/scaffold.css
|
224
256
|
- test/dummy/app/assets/stylesheets/campaigns.css
|
257
|
+
- test/dummy/app/assets/stylesheets/banners.css
|
225
258
|
- test/dummy/app/assets/stylesheets/application.css
|
226
259
|
- test/dummy/app/assets/stylesheets/advertisers.css
|
227
260
|
- test/dummy/app/assets/javascripts/campaigns.js
|
261
|
+
- test/dummy/app/assets/javascripts/banners.js
|
228
262
|
- test/dummy/app/assets/javascripts/application.js
|
229
263
|
- test/dummy/app/assets/javascripts/advertisers.js
|