roqua-core-api 0.2.0 → 0.2.1

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: aac3ceb72c90b7a84b630bff828aae009bcb05f8
4
- data.tar.gz: be357478b0c60d82552a9bd250dbf39a95655cc6
3
+ metadata.gz: afcb8f55c765892ee686c50b9b069af7a42242cc
4
+ data.tar.gz: 231798c7c1c9f410237f4d9f4d683be12d3c8188
5
5
  SHA512:
6
- metadata.gz: 607a42369fdcdd4d543b707a0c7f83ab34f412824333b6c7327e31c6703a3e93b778d421593da9daf2253e4bf6effa9ff9cc0a418cc3480b2adcc69a90d3d542
7
- data.tar.gz: 9d590a27852e4818192b1e05a6e5ba835c61fc55ac1a308cb5a93d62fd329d4cfcc9f83eabae7aea0fd363ae1c567a51187310b13d588e02ecf6f35f8756ae38
6
+ metadata.gz: 053913480e04a70b7e0521b65ebc4bfac5fcb1901efcd7864a34e98642f1570e8c186bf54fd65271b88ead86d982c6e9575dd677d340efc4cfe43102770d7764
7
+ data.tar.gz: 9eb9cd12a83f09c7a8e956098b42d305ea639020a085eb3240403b90599b743951f5b442d140199eca9f743224f0f2f27a63c036707d75bd0ae7f22708311a91
data/ChangeLog.md CHANGED
@@ -1,4 +1,6 @@
1
- * Added TokenSession model and CreateTokenSession, DestroyTokenSession usecases.
1
+ ### 0.2.1
2
+
3
+ * Allow SendInviteEmail to receive a person_id instead of a dossier_id
2
4
 
3
5
  ### 0.2.0
4
6
 
@@ -7,6 +9,7 @@ Active interaction to v2.
7
9
  ### 0.1.1
8
10
 
9
11
  * Add token session.
12
+ * Added TokenSession model and CreateTokenSession, DestroyTokenSession usecases.
10
13
 
11
14
  ### 0.1.0
12
15
 
@@ -22,13 +22,14 @@ nl:
22
22
  odd: moet oneven zijn
23
23
  record_invalid: ! 'Validatie mislukt: %{errors}'
24
24
  taken: is al in gebruik
25
- too_long: is te lang (maximaal %{count} tekens)
26
- too_short: is te kort (minimaal %{count} tekens)
25
+ too_long: is te lang
26
+ too_short: is te kort
27
27
  wrong_length: heeft onjuiste lengte (moet %{count} tekens lang zijn)
28
28
  invalid_key: mag enkel kleine letters, cijfers en underscores bevatten en moet beginnen met een letter.
29
29
  valid_ip_addresses: moeten geldige IP-adressen zijn
30
30
  invalid_email: Geen geldig email adres
31
31
  invalid_date: Niet een bestaande datum
32
+ already_exists: Bestaat al
32
33
  template:
33
34
  body: ! 'Controleer de volgende velden:'
34
35
  header:
@@ -6,13 +6,17 @@ module Roqua
6
6
  string :dossier_group_id
7
7
  object :dossier, class: Models::Dossier, default: nil
8
8
  object :person, class: Models::Person, default: nil
9
+ object :credential, class: Models::Credential, default: nil
9
10
 
10
11
  def execute
11
12
  response = session.post "/dossier_groups/#{dossier_group_id}/dossiers",
12
- person: person_attributes, dossier: dossier_attributes
13
+ person: attribute_hash(person),
14
+ dossier: dossier_attributes,
15
+ credential: attribute_hash(credential)
13
16
  if response.code == 422
14
17
  errors_to_object(response, person)
15
18
  errors_to_object(response, dossier)
19
+ errors_to_object(response, credential)
16
20
  end
17
21
  Models::Dossier.new(response)
18
22
  end
@@ -24,9 +28,9 @@ module Roqua
24
28
  dossier.serializable_hash(except: :people).keep_if { |_k, v| !v.nil? }
25
29
  end
26
30
 
27
- def person_attributes
28
- return {} unless person
29
- person.serializable_hash.keep_if { |_k, v| !v.nil? }
31
+ def attribute_hash(obj)
32
+ return {} unless obj
33
+ obj.serializable_hash.keep_if { |_k, v| !v.nil? }
30
34
  end
31
35
  end
32
36
  end
@@ -0,0 +1,10 @@
1
+ require 'virtus'
2
+
3
+ class Roqua::CoreApi::Models::Credential < Roqua::CoreApi::Models::ActiveVirtus
4
+ attribute :id, String
5
+ attribute :username
6
+ attribute :password
7
+ attribute :password_confirmation
8
+
9
+ validates :password, confirmation: true
10
+ end
@@ -3,4 +3,5 @@ require 'active_model'
3
3
  require 'roqua/core_api/models/active_virtus'
4
4
  require 'roqua/core_api/models/person'
5
5
  require 'roqua/core_api/models/dossier'
6
+ require 'roqua/core_api/models/credential'
6
7
  require 'roqua/core_api/models/export'
@@ -3,16 +3,27 @@ module Roqua
3
3
  # @api private
4
4
  class SendInviteEmail < ActiveInteraction::Base
5
5
  object :session, class: Sessions::AuthSession
6
- string :dossier_id
6
+ string :dossier_id, default: nil
7
+ string :person_id, default: nil
7
8
  string :email_subject, default: nil
8
9
  string :email_body, default: nil
9
10
 
11
+ validates :person_id, presence: true, unless: :dossier_id?
12
+
10
13
  def execute
11
- session.post "/dossiers/#{dossier_id}/send_invite_email", params
14
+ session.post url, params
12
15
  end
13
16
 
14
17
  private
15
18
 
19
+ def url
20
+ if person_id
21
+ "/people/#{person_id}/send_invite_email"
22
+ else
23
+ "/dossiers/#{dossier_id}/send_invite_email"
24
+ end
25
+ end
26
+
16
27
  def params
17
28
  {
18
29
  email_subject: email_subject, email_body: email_body
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module CoreApi
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -51,18 +51,23 @@ describe CreateDossier do
51
51
 
52
52
  describe 'with validation errors' do
53
53
  let(:response) { httparty_response({'errors' => {'person' => {'email' => ['invalid_email']},
54
- 'dossier' => {'external_identifier' => ['blank']}}},
54
+ 'dossier' => {'external_identifier' => ['blank']},
55
+ 'credential' => {'password' => ['too_short']}}},
55
56
  422) }
57
+ let(:credential) { Roqua::CoreApi::Models::Credential.new \
58
+ username: 'foobar', password: '123', password_confirmation: '123' }
56
59
 
57
- it 'Set the errors on the objects' do
60
+ it 'sets the errors on the objects' do
58
61
  allow(session).to receive(:post).and_return(response)
59
62
  new_dossier = CreateDossier.run!(session: session,
60
63
  person: person,
61
64
  dossier: dossier,
65
+ credential: credential,
62
66
  dossier_group_id: 'some_dossier_group_id')
63
67
  expect(new_dossier.persisted?).to be_falsy
64
68
  expect(person.errors[:email]).to eq ['Geen geldig email adres']
65
69
  expect(dossier.errors[:external_identifier]).to eq ['moet opgegeven zijn']
70
+ expect(credential.errors[:password]).to eq ['is te kort']
66
71
  end
67
72
  end
68
73
  end
@@ -3,12 +3,43 @@ require 'spec_helper'
3
3
  describe SendInviteEmail do
4
4
  let(:session) { Fabricate :roqua_core_api_oauth_session }
5
5
 
6
- it 'performs a post on the send_invite_email api path' do
7
- expect(session).to receive(:post).with '/dossiers/some_dossier_id/send_invite_email',
8
- email_subject: 'account created',
9
- email_body: 'visit %create_account_link% to set password'
10
- SendInviteEmail.run!(session: session, dossier_id: 'some_dossier_id',
11
- email_subject: 'account created',
12
- email_body: 'visit %create_account_link% to set password')
6
+ context 'Dossier' do
7
+ subject { SendInviteEmail.run! \
8
+ session: session,
9
+ dossier_id: 'some_dossier_id',
10
+ email_subject: 'account created',
11
+ email_body: 'visit %create_account_link% to set password' }
12
+ it 'performs a post on the send_invite_email api path' do
13
+ expect(session).to receive(:post).with '/dossiers/some_dossier_id/send_invite_email',
14
+ email_subject: 'account created',
15
+ email_body: 'visit %create_account_link% to set password'
16
+ subject
17
+ end
18
+ end
19
+
20
+ context "Person" do
21
+ subject { SendInviteEmail.run! \
22
+ session: session,
23
+ person_id: 'some_person_id',
24
+ email_subject: 'account created',
25
+ email_body: 'visit %create_account_link% to set password' }
26
+ it 'performs a post on the send_invite_email api path' do
27
+ expect(session).to receive(:post).with '/people/some_person_id/send_invite_email',
28
+ email_subject: 'account created',
29
+ email_body: 'visit %create_account_link% to set password'
30
+ subject
31
+ end
32
+ end
33
+
34
+ context "Neither Dossier nor Person" do
35
+ subject { SendInviteEmail.run \
36
+ session: session,
37
+ email_subject: 'account created',
38
+ email_body: 'visit %create_account_link% to set password' }
39
+
40
+ it 'performs a post on the send_invite_email api path' do
41
+ expect(subject).to be_invalid
42
+ expect(subject.errors).to include :person_id
43
+ end
13
44
  end
14
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -198,6 +198,7 @@ files:
198
198
  - lib/roqua/core_api/list_dossier_group_rights.rb
199
199
  - lib/roqua/core_api/models.rb
200
200
  - lib/roqua/core_api/models/active_virtus.rb
201
+ - lib/roqua/core_api/models/credential.rb
201
202
  - lib/roqua/core_api/models/dossier.rb
202
203
  - lib/roqua/core_api/models/dossier_group.rb
203
204
  - lib/roqua/core_api/models/export.rb