basecrm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +0 -3
- data/lib/base_crm.rb +1 -1
- data/lib/base_crm/contact.rb +1 -1
- data/lib/base_crm/custom_fieldable.rb +24 -27
- data/lib/base_crm/lead.rb +1 -1
- data/lib/base_crm/version.rb +1 -1
- data/spec/base_crm/deal_spec.rb +2 -8
- data/spec/base_crm/lead_spec.rb +1 -1
- data/spec/support/noteable_shared_examples.rb +6 -6
- data/spec/support/taskable_shared_examples.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2f77ee02273e60432ee07afc45df2546472675
|
4
|
+
data.tar.gz: 23887aee3f8184ec91663fdf95eb0ab67ede5487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d2ab3ddf64bad4837691302b17768c268c3aeee11d143cb5801eec61bfcd0f9d9dc5660570af6a4256f5a03f97f18dd5374d5909a0f32f70ce7d13ae2bed869
|
7
|
+
data.tar.gz: bac89ab72524eb5d5cd81a0d92af9eafd0c911c882d77583a83e80f9f534a6b3305ea2cdb3fc3dfbc7a2ad1c4c8162641546ca7a3a2fc33924920a85c9b5d48f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/lib/base_crm.rb
CHANGED
@@ -2,6 +2,7 @@ require "api_client"
|
|
2
2
|
require "base_crm/version"
|
3
3
|
require "base_crm/config"
|
4
4
|
require "base_crm/api_client_ext"
|
5
|
+
require "base_crm/custom_fieldable"
|
5
6
|
|
6
7
|
module BaseCrm
|
7
8
|
|
@@ -18,7 +19,6 @@ module BaseCrm
|
|
18
19
|
autoload :Task, "base_crm/task"
|
19
20
|
autoload :Taskable, "base_crm/taskable"
|
20
21
|
autoload :Lead, "base_crm/lead"
|
21
|
-
autoload :CustomFieldable, "base_crm/custom_fieldable"
|
22
22
|
|
23
23
|
end
|
24
24
|
|
data/lib/base_crm/contact.rb
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
module BaseCrm
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
simplify_custom_fields
|
8
|
-
end
|
9
|
-
|
10
|
-
def simplify_custom_fields
|
11
|
-
fields = self['custom_fields'] || {}
|
12
|
-
self['custom_fields'] = fields.inject(Hashie::Mash.new) do |memo, field|
|
13
|
-
name, value = field
|
14
|
-
memo[name] = value['value']
|
15
|
-
memo
|
2
|
+
def self.CustomFieldable(custom_fields_field_name)
|
3
|
+
Module.new do
|
4
|
+
def initialize(attributes, original_scope = nil)
|
5
|
+
super
|
6
|
+
simplify_custom_fields
|
16
7
|
end
|
17
|
-
end
|
18
8
|
|
19
|
-
|
9
|
+
define_method :simplify_custom_fields do
|
10
|
+
fields = self[custom_fields_field_name] || {}
|
11
|
+
self[custom_fields_field_name] = fields.inject(Hashie::Mash.new) do |memo, field|
|
12
|
+
name, value = field
|
13
|
+
memo[name] = value['value']
|
14
|
+
memo
|
15
|
+
end
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
private
|
19
|
+
|
20
|
+
# Because custom fields are hashes, and hashes result in
|
21
|
+
# new instances of BaseCrm::Contact, we end up with a stack level too deep
|
22
|
+
# because simplify_custom_fields gets fired all the time
|
23
|
+
def convert_value(val, duping=false) #:nodoc:
|
24
|
+
if val.is_a?(Hash) or val.is_a?(::Hash)
|
25
|
+
val
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
|
-
|
data/lib/base_crm/lead.rb
CHANGED
data/lib/base_crm/version.rb
CHANGED
data/spec/base_crm/deal_spec.rb
CHANGED
@@ -65,10 +65,7 @@ describe BaseCrm::Deal do
|
|
65
65
|
context "when it is not found" do
|
66
66
|
before do
|
67
67
|
subject.stub(:pass_headers).with(BaseCrm::Source).and_return(scope)
|
68
|
-
scope.
|
69
|
-
stub(:find).
|
70
|
-
with(source_id).
|
71
|
-
and_raise(ApiClient::Errors::NotFound)
|
68
|
+
scope.stub(:find).with(source_id)
|
72
69
|
end
|
73
70
|
it { subject.source.should == nil }
|
74
71
|
end
|
@@ -109,10 +106,7 @@ describe BaseCrm::Deal do
|
|
109
106
|
context "when it is not found" do
|
110
107
|
before do
|
111
108
|
subject.stub(:pass_headers).with(BaseCrm::Contact).and_return(scope)
|
112
|
-
scope.
|
113
|
-
stub(:find).
|
114
|
-
with(entity_id).
|
115
|
-
and_raise(ApiClient::Errors::NotFound)
|
109
|
+
scope.stub(:find).with(entity_id)
|
116
110
|
end
|
117
111
|
it { subject.contact.should == nil }
|
118
112
|
end
|
data/spec/base_crm/lead_spec.rb
CHANGED
@@ -21,9 +21,9 @@ shared_examples "noteable" do |noteable_type|
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#notes.create" do
|
24
|
-
let(:message) {
|
25
|
-
let(:note) {
|
26
|
-
let(:fetch_scope) {
|
24
|
+
let(:message) { double }
|
25
|
+
let(:note) { double }
|
26
|
+
let(:fetch_scope) { double }
|
27
27
|
|
28
28
|
it "passes the token and applies the params" do
|
29
29
|
subject.
|
@@ -46,9 +46,9 @@ shared_examples "noteable" do |noteable_type|
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#create_note" do
|
49
|
-
let(:message) {
|
50
|
-
let(:notes) {
|
51
|
-
let(:note) {
|
49
|
+
let(:message) { double }
|
50
|
+
let(:notes) { double }
|
51
|
+
let(:note) { double }
|
52
52
|
|
53
53
|
it "creates a new note" do
|
54
54
|
subject.should_receive(:notes).and_return(notes)
|
@@ -50,9 +50,9 @@ shared_examples "taskable" do |taskable_type|
|
|
50
50
|
let(:params) do
|
51
51
|
{ :content => task_content }
|
52
52
|
end
|
53
|
-
let(:task_content) {
|
54
|
-
let(:tasks) {
|
55
|
-
let(:task) {
|
53
|
+
let(:task_content) { double }
|
54
|
+
let(:tasks) { double }
|
55
|
+
let(:task) { double }
|
56
56
|
|
57
57
|
it "creates a new task" do
|
58
58
|
subject.should_receive(:tasks).and_return(tasks)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basecrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Bunsch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api_client
|