pipejump 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,7 +93,7 @@ module Pipejump
|
|
93
93
|
|
94
94
|
end
|
95
95
|
|
96
|
-
attr_accessor :attributes
|
96
|
+
attr_accessor :attributes, :errors
|
97
97
|
# Constructor for the Resource
|
98
98
|
def initialize(attrs)
|
99
99
|
@session = attrs.delete(:session)
|
@@ -132,7 +132,7 @@ module Pipejump
|
|
132
132
|
|
133
133
|
def save
|
134
134
|
before_save if respond_to?(:before_save)
|
135
|
-
|
135
|
+
return false unless valid?
|
136
136
|
code, data = id ? update : create # @session.post('/' + self.class.collection_path.to_s + '.json', to_query)
|
137
137
|
if data['errors']
|
138
138
|
@errors = data['errors']
|
@@ -143,6 +143,16 @@ module Pipejump
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
def validate
|
147
|
+
true
|
148
|
+
end
|
149
|
+
|
150
|
+
def valid?
|
151
|
+
@errors = {}
|
152
|
+
validate
|
153
|
+
@errors.none?
|
154
|
+
end
|
155
|
+
|
146
156
|
def inspect
|
147
157
|
"#<#{self.class} #{@attributes.collect { |pair| pair[1] = pair[1].inspect; pair.join(': ') }.join(', ')}>"
|
148
158
|
end
|
data/lib/pipejump/version.rb
CHANGED
@@ -17,6 +17,7 @@ describe Pipejump::Contact do
|
|
17
17
|
@contact2.destroy
|
18
18
|
end
|
19
19
|
|
20
|
+
|
20
21
|
describe '@session.contacts' do
|
21
22
|
|
22
23
|
it ".all should return all contacts" do
|
@@ -98,17 +99,4 @@ describe Pipejump::Contact do
|
|
98
99
|
|
99
100
|
end
|
100
101
|
|
101
|
-
describe "#custom_fields" do
|
102
|
-
|
103
|
-
it "returns a hash of custom fields" do
|
104
|
-
@contact1.name = 'AAA TESTING ONE'
|
105
|
-
@contact1.custom_fields['test_field'] = 'yaaay'
|
106
|
-
@contact1.save
|
107
|
-
|
108
|
-
puts @contact1.inspect
|
109
|
-
|
110
|
-
@session.contacts.find(@contact1.id).custom_fields['test_field']['value'].should =='yaaay'
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
102
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pipejump::Contact do
|
4
|
+
|
5
|
+
describe "validation" do
|
6
|
+
|
7
|
+
it "does not save when not valid" do
|
8
|
+
@contact = Pipejump::Contact.new(:name => '')
|
9
|
+
@contact.save.should be_false
|
10
|
+
end
|
11
|
+
|
12
|
+
it "is not valid when name is not set" do
|
13
|
+
@contact = Pipejump::Contact.new(:name => 'foo')
|
14
|
+
@contact.valid?.should be_true
|
15
|
+
@contact.name = ''
|
16
|
+
@contact.valid?.should be_false
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is not valid when last_name is not set" do
|
20
|
+
@contact = Pipejump::Contact.new(:last_name => 'foo')
|
21
|
+
@contact.valid?.should be_true
|
22
|
+
@contact.last_name = ''
|
23
|
+
@contact.valid?.should be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipejump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- spec/pipejump/resources/contact/reminder_spec.rb
|
49
49
|
- spec/pipejump/resources/contact_custom_fields_spec.rb
|
50
50
|
- spec/pipejump/resources/contact_spec.rb
|
51
|
+
- spec/pipejump/resources/contact_validation_spec.rb
|
51
52
|
- spec/pipejump/resources/deal/note_spec.rb
|
52
53
|
- spec/pipejump/resources/deal/reminder_spec.rb
|
53
54
|
- spec/pipejump/resources/deal_spec.rb
|
@@ -85,6 +86,7 @@ test_files:
|
|
85
86
|
- spec/pipejump/resources/contact/reminder_spec.rb
|
86
87
|
- spec/pipejump/resources/contact_custom_fields_spec.rb
|
87
88
|
- spec/pipejump/resources/contact_spec.rb
|
89
|
+
- spec/pipejump/resources/contact_validation_spec.rb
|
88
90
|
- spec/pipejump/resources/deal/note_spec.rb
|
89
91
|
- spec/pipejump/resources/deal/reminder_spec.rb
|
90
92
|
- spec/pipejump/resources/deal_spec.rb
|