comptroller 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ module Comptroller
7
7
 
8
8
  attributes :error_message, :created_at, :external_id
9
9
 
10
- def self.count
11
- get_raw(:count) do |parsed_data, response|
10
+ def self.count(opts={})
11
+ get_raw(:count, opts) do |parsed_data, response|
12
12
  parsed_data[:data][:count]
13
13
  end
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module Comptroller
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -99,11 +99,26 @@ Mimic.mimic(:port => Comptroller::Configuration::PORT) do
99
99
  end
100
100
 
101
101
  get '/duxware_errors/count' do
102
- [ 200, {}, { :count => 1 }.to_json ]
102
+ claim_error_count = if params[:external_id]
103
+ DataManager.claim_errors.values.count do |claim_error|
104
+ claim_error[:external_id] == params[:external_id].to_i
105
+ end
106
+ else
107
+ DataManager.claim_errors.keys.size
108
+ end
109
+
110
+ [ 200, {}, { :count => claim_error_count }.to_json ]
103
111
  end
104
112
 
105
113
  get '/duxware_errors' do
106
- [ 200, {}, DataManager.claim_errors.values.to_json ]
114
+ claim_errors = if params[:external_id]
115
+ DataManager.claim_errors.values.select do |claim_error|
116
+ claim_error[:external_id] == params[:external_id].to_i
117
+ end
118
+ else
119
+ DataManager.claim_errors.values
120
+ end
121
+ [ 200, {}, claim_errors.to_json ]
107
122
  end
108
123
 
109
124
  get '/duxware_errors/:id' do
@@ -6,6 +6,11 @@ module Comptroller
6
6
  expect(ClaimError.all.first).to eql(ClaimError.new(:id => 1))
7
7
  end
8
8
 
9
+ it 'retrieves claim errors by external_id' do
10
+ expect(ClaimError.where(:external_id => 3).size).to eql(1)
11
+ expect(ClaimError.where(:external_id => 3).first).to eql(ClaimError.new(:id => 1))
12
+ end
13
+
9
14
  it 'allows deleting of claim errors' do
10
15
  error = ClaimError.all.first
11
16
  ClaimError.destroy_existing(error.id)
@@ -17,8 +22,14 @@ module Comptroller
17
22
  expect(ClaimError.find(1).message_body).to eql('foo bar')
18
23
  end
19
24
 
20
- it 'defines count' do
21
- expect(ClaimError.count).to eql(1)
25
+ describe '.count' do
26
+ it 'returns total number of claim errors' do
27
+ expect(ClaimError.count).to eql(2)
28
+ end
29
+
30
+ it 'returns total number of claim errors for given external id' do
31
+ expect(ClaimError.count(:external_id => 3)).to eql(1)
32
+ end
22
33
  end
23
34
  end
24
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comptroller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-06 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: her