neuron-client 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,17 @@ module Neuron
58
58
  Ad.find(ad_id)
59
59
  end
60
60
 
61
- STATISTIC_TYPES = %w(requests blocks defaults unitloads selections undeliveries impressions redirects clicks)
61
+ STATISTIC_TYPES = {
62
+ 'requests' => [],
63
+ 'blocks' => ['reason'],
64
+ 'defaults' => [],
65
+ 'unitloads' => [],
66
+ 'selections' => ['ad'],
67
+ 'undeliveries' => ['ad'],
68
+ 'impressions' => ['ad'],
69
+ 'redirects' => ['ad'],
70
+ 'clicks' => ['ad']
71
+ }
62
72
 
63
73
  def recent(statistic, parameters={})
64
74
  connected_to_admin!
@@ -73,7 +83,7 @@ module Neuron
73
83
  unless STATISTIC_TYPES.include?(statistic.to_s)
74
84
  raise "Unsupported statistic: #{statistic}"
75
85
  end
76
- unless by.blank? || by == 'zone'
86
+ unless by.blank? || STATISTIC_TYPES[statistic.to_s].include?(by.to_s)
77
87
  raise "Unsupported by: #{by}"
78
88
  end
79
89
  unless minutes.blank? || minutes.to_i > 0
@@ -1,5 +1,5 @@
1
1
  module Neuron
2
2
  module Client
3
- VERSION = "0.4.5"
3
+ VERSION = "0.4.6"
4
4
  end
5
5
  end
@@ -99,18 +99,22 @@ module Neuron
99
99
  end
100
100
 
101
101
  describe "create" do
102
- it "should return nil when errors occur" do
102
+ it "should return object with errors when they occur" do
103
103
  @connection.should_receive(:post).with("test_models", {'test_model' => {}}) do
104
104
  throw :errors, {:error => "is_required"}
105
105
  end
106
-
107
- TestModel.create({}).should be_nil
106
+ created = TestModel.create({})
107
+ created.should be_a TestModel
108
+ created.errors.should_not be_empty
109
+ created.id.should be_nil
108
110
  end
109
111
 
110
112
  it "should return the created object when no errors occur" do
111
113
  @connection.should_receive(:post).with("test_models", {'test_model' => {}}).and_return({'test_model' => {:id => 1}})
112
114
 
113
- TestModel.create({}).should be_a TestModel
115
+ created = TestModel.create({})
116
+ created.should be_a TestModel
117
+ created.id.should == 1
114
118
  end
115
119
  end
116
120
 
@@ -113,9 +113,9 @@ module Neuron
113
113
  describe "recent(statistic, by=nil)" do
114
114
  it "should call the expected method and return the expected result" do
115
115
  zone = Zone.new(@minimal_attributes.merge('id' => 'z99'))
116
- @connection.should_receive(:get).with('zones/z99/recent/impressions', {'by' => 'zone'}).and_return('return_value')
116
+ @connection.should_receive(:get).with('zones/z99/recent/impressions', {'by' => 'ad'}).and_return('return_value')
117
117
 
118
- zone.recent('impressions', :by => 'zone').should == 'return_value'
118
+ zone.recent('impressions', :by => 'ad').should == 'return_value'
119
119
  end
120
120
  end
121
121
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neuron-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - RMM Online
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-12 00:00:00 -05:00
19
- default_executable:
18
+ date: 2012-03-12 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rest-client
@@ -451,7 +450,6 @@ files:
451
450
  - spec/lib/schema/s3_file_spec.rb
452
451
  - spec/lib/schema/zone_spec.rb
453
452
  - spec/spec_helper.rb
454
- has_rdoc: true
455
453
  homepage: http://github.com/rmm/neuron-client
456
454
  licenses: []
457
455
 
@@ -481,7 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
481
479
  requirements: []
482
480
 
483
481
  rubyforge_project: neuron-client
484
- rubygems_version: 1.6.2
482
+ rubygems_version: 1.8.10
485
483
  signing_key:
486
484
  specification_version: 3
487
485
  summary: Neuron Admin Client Gem