capsule_crm 0.7.0 → 0.7.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: 3713b0ec80a9c807b2843e00a454a59e62f3985f
4
- data.tar.gz: eba5f910134b574dea3d23d762c6b3d06f6effa3
3
+ metadata.gz: 86fd2febb988f9947d64a54b0c4c2761deb154a2
4
+ data.tar.gz: 3fe7d754695c00bd95d8ea2269df49559d1dc31d
5
5
  SHA512:
6
- metadata.gz: 0b59c35c19bfaa14d82bcb254bcad3bc11ddeb62beb17b399873e2517a8896321c44df4e58e4c0cb9ba6b3802019acfcea9ded653772bc73d5ee35765de5a5ce
7
- data.tar.gz: 5d8dcbae2705a720e4177e4bc2ec124eb239e817eb5fd8e795574b25d29ef8a2649a2eed3f285aa66ef2555ced39945febb45788116c2670d83a23182a12e4ec
6
+ metadata.gz: 1949c44a677c59a1e9d8a06ded0fce90e23c1ac76dc15479198965c528e75edf10ce88cafc23e7f251e88c48c90d323277937646b9d2eac2812e36c11ded33e0
7
+ data.tar.gz: eb8654fa8b5d168b6024d0f069de9587bdd2d770fe72154a0e562f52204b03e70942abad5d7418effc0acab5166af45366c0209505d80d33ae4b846259ed1bf9
data/Guardfile CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  notification :tmux
5
5
 
6
- guard 'rspec' do
6
+ guard 'rspec', all_after_pass: true do
7
7
  watch(%r{^spec/.+_spec\.rb$})
8
8
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
9
9
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -1,15 +1,11 @@
1
1
  [![Build
2
2
  Status](https://travis-ci.org/mattbeedle/capsule_crm.png)](https://travis-ci.org/mattbeedle/capsule_crm)
3
-
4
3
  [![Code
5
4
  Climate](https://codeclimate.com/github/mattbeedle/capsule_crm.png)](https://codeclimate.com/github/mattbeedle/capsule_crm)
6
-
7
5
  [![Gem
8
6
  Version](https://badge.fury.io/rb/capsule_crm.png)](http://badge.fury.io/rb/capsule_crm)
9
-
10
7
  [![Coverage
11
8
  Status](https://coveralls.io/repos/mattbeedle/capsule_crm/badge.png?branch=master)](https://coveralls.io/r/mattbeedle/capsule_crm)
12
-
13
9
  [![Dependency
14
10
  Status](https://gemnasium.com/mattbeedle/capsule_crm.png)](https://gemnasium.com/mattbeedle/capsule_crm)
15
11
 
@@ -3,9 +3,13 @@ module CapsuleCRM
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
+ delegate :phones, to: :contacts, allow_nil: true
6
7
  delegate :phones=, to: :contacts
8
+ delegate :websites, to: :contacts, allow_nil: true
7
9
  delegate :websites=, to: :contacts
10
+ delegate :emails, to: :contacts, allow_nil: true
8
11
  delegate :emails=, to: :contacts
12
+ delegate :addresses, to: :contacts, allow_nil: true
9
13
  delegate :addresses=, to: :contacts
10
14
  end
11
15
 
@@ -72,7 +72,7 @@ module CapsuleCRM
72
72
  #
73
73
  # Returns an Array of CapsuleCRM::Email objects
74
74
  def emails
75
- @emails || []
75
+ Array(@emails)
76
76
  end
77
77
 
78
78
  # Public: Sets the phones for this contacts controller
@@ -98,7 +98,7 @@ module CapsuleCRM
98
98
  #
99
99
  # Returns a Hash
100
100
  def phones
101
- @phones || []
101
+ Array(@phones)
102
102
  end
103
103
 
104
104
  # Public: Sets the websites for this contacts container
@@ -126,7 +126,7 @@ module CapsuleCRM
126
126
  #
127
127
  # Returns a Hash
128
128
  def websites
129
- @websites || []
129
+ Array(@websites)
130
130
  end
131
131
 
132
132
  # Public: Builds a hash of all contact information
@@ -12,6 +12,7 @@ module CapsuleCRM
12
12
 
13
13
  include CapsuleCRM::Associations::HasMany
14
14
  include CapsuleCRM::Taggable
15
+ include CapsuleCRM::Contactable
15
16
 
16
17
  attribute :id, Integer
17
18
  attribute :name, String
@@ -1,3 +1,3 @@
1
1
  module CapsuleCrm
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -1,8 +1,11 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CapsuleCRM::Organization do
4
5
  before { configure }
5
6
 
7
+ it_should_behave_like 'contactable'
8
+
6
9
  before do
7
10
  stub_request(:get, /\/api\/users$/).
8
11
  to_return(body: File.read('spec/support/all_users.json'))
@@ -39,4 +42,53 @@ describe CapsuleCRM::Organization do
39
42
 
40
43
  it { should be_a(Array) }
41
44
  end
45
+
46
+
47
+ describe '#to_capsule_json' do
48
+ let(:address) do
49
+ CapsuleCRM::Address.new(
50
+ street: 'Oranienburgerstraße', city: 'Berlin', state: 'Berlin',
51
+ zip: '10117', country: 'de'
52
+ )
53
+ end
54
+
55
+ let(:email) do
56
+ CapsuleCRM::Email.new(type: 'Work', email_address: 'mattscompany@gmail.com')
57
+ end
58
+
59
+ let(:contacts) do
60
+ CapsuleCRM::Contacts.new(addresses: [address], emails: [email])
61
+ end
62
+
63
+ let(:organization) do
64
+ CapsuleCRM::Organization.new(
65
+ name: "Matt's Company",
66
+ contacts: contacts
67
+ )
68
+ end
69
+
70
+ let(:email_json) { subject['contacts']['email'].first }
71
+
72
+ let(:address_json) { subject['contacts']['address'].first }
73
+
74
+ subject { organization.to_capsule_json['organisation'] }
75
+
76
+ it { should have_key('name') }
77
+
78
+ it { should have_key('contacts') }
79
+
80
+ it { address_json.should have_key('street') }
81
+
82
+ it { address_json.should have_key('city') }
83
+
84
+ it { address_json.should have_key('state') }
85
+
86
+ it { address_json.should have_key('zip') }
87
+
88
+ it { address_json.should have_key('country') }
89
+
90
+ it { email_json.should have_key('type') }
91
+
92
+ it { email_json.should have_key('emailAddress') }
93
+ end
42
94
  end
@@ -3,6 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe CapsuleCRM::Person do
6
+
7
+ it_should_behave_like 'contactable'
8
+
6
9
  before do
7
10
  stub_request(:get, /\/api\/users$/).
8
11
  to_return(body: File.read('spec/support/all_users.json'))
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,8 @@ require 'shoulda-matchers'
9
9
  require 'support/helpers'
10
10
  require 'webmock/rspec'
11
11
 
12
+ Dir["./spec/support/**/*.rb"].each { |f| require f }
13
+
12
14
  Coveralls.wear!
13
15
 
14
16
  # This file was generated by the `rspec --init` command. Conventionally, all
@@ -0,0 +1,21 @@
1
+ shared_examples 'contactable' do
2
+ it { expect(described_class.new).to respond_to(:contacts) }
3
+
4
+ it { expect(described_class.new).to respond_to(:contacts=) }
5
+
6
+ it { expect(described_class.new).to respond_to(:phones) }
7
+
8
+ it { expect(described_class.new).to respond_to(:phones=) }
9
+
10
+ it { expect(described_class.new).to respond_to(:websites) }
11
+
12
+ it { expect(described_class.new).to respond_to(:websites=) }
13
+
14
+ it { expect(described_class.new).to respond_to(:emails) }
15
+
16
+ it { expect(described_class.new).to respond_to(:emails=) }
17
+
18
+ it { expect(described_class.new).to respond_to(:addresses) }
19
+
20
+ it { expect(described_class.new).to respond_to(:addresses=) }
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capsule_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Beedle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-30 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -315,6 +315,7 @@ files:
315
315
  - spec/support/opportunity.json
316
316
  - spec/support/organisation.json
317
317
  - spec/support/person.json
318
+ - spec/support/shared_examples/contactable.rb
318
319
  - spec/support/task.json
319
320
  - spec/support/task_categories.json
320
321
  homepage: ''
@@ -386,5 +387,6 @@ test_files:
386
387
  - spec/support/opportunity.json
387
388
  - spec/support/organisation.json
388
389
  - spec/support/person.json
390
+ - spec/support/shared_examples/contactable.rb
389
391
  - spec/support/task.json
390
392
  - spec/support/task_categories.json