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: 0f975026a540f11a37ec566c7ec81859e870f1e3
4
- data.tar.gz: 7403f5aa50c0cdc469aa274e6b420da0b2b90e48
3
+ metadata.gz: fbe77259e987982ab8b5b7f2f8696656e1caaee2
4
+ data.tar.gz: c85ea6c747e0654629fe582de5e684b3accdb7da
5
5
  SHA512:
6
- metadata.gz: 8c232bab60b97895f1bfb56dfe99a73d096e0d0ea90d85b29944a7aee033ab0c94c51366471bc88b4a5e2f42b02f0c9c0d33601988dff0936d97d7c811e7ab62
7
- data.tar.gz: 350238ac0d444187c249025a858d3e831371e0e9f7aedb47dc2e65d9c5e75c6d39c4c68293c08d6400a488a4e0ab1e3a92de2ffd2bde6fa846818914f2bfafb9
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
- string :epd_ids
5
+ array :epd_ids, default: []
6
6
 
7
7
  def execute
8
8
  validate_response_for do
9
- basic_auth_session.get "/dossiers/#{epd_ids}/stats"
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,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -1,49 +1,59 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ListDossierStats do
4
- context 'Single Dossier' do
5
- let(:options) { {epd_ids: '1'} }
6
- let(:api_path) { "/dossiers/#{options[:epd_ids]}/stats" }
7
- let(:response) do
8
- httparty_response("1" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}})
9
- end
10
- let(:session) { Fabricate :basic_auth_session }
11
- before { allow(BasicAuthSession).to receive(:new).and_return session }
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
- it 'performs a GET on the stats API' do
14
- allow(session).to receive(:get).with(api_path).and_return response
15
- stats = ListDossierStats.run(options).result
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
- # binding.pry
23
+ subject { ListDossierStats.run! epd_ids: ['foo', 'bar'] }
18
24
 
19
- expect(stats.dossiers).to be_a(Hash)
20
- expect(stats.dossiers).to have_key("1")
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
- context 'Multiple Dossiers' do
27
- let(:options) { {epd_ids: '1,2,3'} }
28
- let(:api_path) { "/dossiers/#{options[:epd_ids]}/stats" }
29
- let(:response) do
30
- httparty_response(
31
- "1" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}},
32
- "2" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}},
33
- "3" => {"responses" => {"total" => 10}, "invitations" => {"total" => 3}}
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
- it 'performs a GET on the stats API' do
40
- allow(session).to receive(:get).with(api_path).and_return response
41
- stats = ListDossierStats.run(options).result
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
- expect(stats.dossiers).to be_a(Hash)
44
- expect(stats.dossiers).to have_key("3")
45
- expect(stats.dossiers["3"]).to be_a(DossierStats)
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
@@ -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.0.0
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: 2015-12-08 00:00:00.000000000 Z
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.2.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