roqua-rom-api 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe77259e987982ab8b5b7f2f8696656e1caaee2
|
4
|
+
data.tar.gz: c85ea6c747e0654629fe582de5e684b3accdb7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1781d9bb6910b3227e5957c57695a4843a92d4e4b65ebd9275685655e1b380991792079d75e2e8455a2bde9afbb510588c0d64b9f13df27a4b962e14a0cb0154
|
7
|
+
data.tar.gz: 7aed03a968bdc9b74e3d42ff190a67ada21d65bc9456bd744bb8c17d86499f6c313265cfe1b6f84609a75b2cbd445b1d6cfeddb47c9e71c886d4563ff5663226
|
@@ -2,14 +2,18 @@ module Roqua
|
|
2
2
|
module RomApi
|
3
3
|
# @api private
|
4
4
|
class ListDossierStats < Endpoint
|
5
|
-
|
5
|
+
array :epd_ids, default: []
|
6
6
|
|
7
7
|
def execute
|
8
8
|
validate_response_for do
|
9
|
-
basic_auth_session.get
|
9
|
+
basic_auth_session.get '/stats', params
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def params
|
14
|
+
{epd_ids: epd_ids} if epd_ids.any?
|
15
|
+
end
|
16
|
+
|
13
17
|
def response_to_result(response)
|
14
18
|
Models::Stats.new(dossiers: response)
|
15
19
|
end
|
@@ -1,49 +1,59 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ListDossierStats do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
let(:session) { Fabricate :basic_auth_session }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(BasicAuthSession).to receive(:new).and_return session
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_result(options)
|
11
|
+
expect(subject.dossiers).to be_a(Hash)
|
12
|
+
expect(subject.dossiers).to have_key(options[:key])
|
13
|
+
expect(subject.dossiers['1']).to be_a(DossierStats)
|
14
|
+
expect(subject.dossiers.size).to be options[:size]
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
describe 'with epd_ids provided' do
|
18
|
+
let(:response) { {'foo' => {}, 'bar' => {}} }
|
19
|
+
before do
|
20
|
+
allow(session).to receive(:get).with('/stats', epd_ids: ['foo', 'bar']).and_return httparty_response(response)
|
21
|
+
end
|
16
22
|
|
17
|
-
|
23
|
+
subject { ListDossierStats.run! epd_ids: ['foo', 'bar'] }
|
18
24
|
|
19
|
-
|
20
|
-
expect(
|
21
|
-
expect(stats.dossiers["1"]).to be_a(DossierStats)
|
22
|
-
expect(stats.dossiers.size).to be 1
|
25
|
+
it 'performs a GET on the stats API with epd_ids' do
|
26
|
+
expect(subject.dossiers.keys).to include('foo', 'bar')
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
)
|
30
|
+
describe 'without epd_ids provided' do
|
31
|
+
before do
|
32
|
+
allow(session).to receive(:get).with('/stats', nil).and_return httparty_response(response)
|
33
|
+
end
|
34
|
+
|
35
|
+
subject { ListDossierStats.run! }
|
36
|
+
|
37
|
+
context 'Single Dossier' do
|
38
|
+
let(:response) { {"1" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}}} }
|
39
|
+
|
40
|
+
it 'performs a GET on the stats API' do
|
41
|
+
assert_result key: '1', size: 1
|
42
|
+
end
|
35
43
|
end
|
36
|
-
let(:session) { Fabricate :basic_auth_session }
|
37
|
-
before { allow(BasicAuthSession).to receive(:new).and_return session }
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
context 'Multiple Dossiers' do
|
46
|
+
let(:response) do
|
47
|
+
{
|
48
|
+
"1" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}},
|
49
|
+
"2" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}},
|
50
|
+
"3" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}}
|
51
|
+
}
|
52
|
+
end
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
expect(stats.dossiers.size).to be 3
|
54
|
+
it 'performs a GET on the stats API' do
|
55
|
+
assert_result key: '3', size: 3
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
49
59
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,3 +9,8 @@ include Roqua::RomApi::Models
|
|
9
9
|
Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'support', '*.rb')].each {|f| require f}
|
10
10
|
|
11
11
|
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'support', '*.yml')]
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_run focus: true
|
15
|
+
config.run_all_when_everything_filtered = true
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-rom-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Esposito
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: httparty
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.4.5.1
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: API wrapper gem around RoQua's ROM API
|