active_force 0.0.4.alfa → 0.0.5.alfa

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: f71ee97f96752c20cc626de2b6cecb58a84e29de
4
- data.tar.gz: b64e0707535e663f8e322cdeea503059aa2e3b74
3
+ metadata.gz: 2e52c7acefecccaede98efb34fa7974baaa9d81e
4
+ data.tar.gz: afb36c781c3c07e84c388c747eb17130e2211c02
5
5
  SHA512:
6
- metadata.gz: 255cc8d975730f3e71bf4cffe757cb4535d94f7b2e21338cfe1337127b1769881445ec0c15a62bc655d23efdd129269226a204c217998fe2a9ec08a6d69cbe73
7
- data.tar.gz: e9691d927fd8537590e28438ad71b2ac219c7e4e0e7d7bbab1dac3088c1b349bc4f34b518bf956cd70b55869ff6b0af341b2fa7b53b3cd4f0935ae9c03a87263
6
+ metadata.gz: c1effdd89a431566fa8c2975e3f5250e02f1fc215181ef0cf3945ff82c06a7b76d621d32d45eaf3b11b37a6d7d3eb08ed02e347aa6657c5e036dff9d82131679
7
+ data.tar.gz: 5c33f883da377c25392df905a79b3a798fb0459eb2eb9bcb1c992e6467b0384ebba3fb9d9a6f286b809f2045d4ba2b0f9f6135d6273e8adc2e7358b3caf27992
data/active_force.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'active_attr', '~> 0.8'
22
+ spec.add_dependency 'restforce', '~> 1.4'
22
23
  spec.add_development_dependency 'bundler', '~> 1.3'
23
24
  spec.add_development_dependency 'rake'
24
25
  spec.add_development_dependency 'rspec'
@@ -27,6 +27,23 @@ module ActiveForce
27
27
  SOQL
28
28
  end
29
29
 
30
+ def create
31
+ return false unless valid?
32
+ hash = {}
33
+ mappings.map do |field, name_in_sfdc|
34
+ value = attribute(field.to_s)
35
+ hash[name_in_sfdc] = value if value.present?
36
+ end
37
+ self.id = Client.create! table_name, hash
38
+ changed_attributes.clear
39
+ rescue Faraday::Error::ClientError => error
40
+ Rails.logger.warn do
41
+ "[SFDC] [#{self.class.model_name}] [#{self.class.table_name}] Error while creating, params: #{hash}, error: #{error.inspect}"
42
+ end
43
+ errors[:base] << "Error when creating the #{self.class.model_name}"
44
+ false
45
+ end
46
+
30
47
  def update_attributes attributes
31
48
  assign_attributes attributes
32
49
  if valid?
@@ -1,3 +1,3 @@
1
1
  module ActiveForce
2
- VERSION = "0.0.4.alfa"
2
+ VERSION = "0.0.5.alfa"
3
3
  end
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveForce::SObject do
4
+
5
+ before do
6
+ ::Client = double('Client')
7
+ end
8
+
9
+ after do
10
+ Object.send :remove_const, 'Client'
11
+ end
12
+
4
13
  describe ".new" do
5
14
  it "create with valid values" do
6
15
  @SObject = Whizbang.new
@@ -16,7 +25,7 @@ describe ActiveForce::SObject do
16
25
  end
17
26
  end
18
27
 
19
- describe "field" do
28
+ describe ".field" do
20
29
  it "add a mappings" do
21
30
  expect(Whizbang.mappings).to include(
22
31
  checkbox: 'Checkbox_Label',
@@ -33,4 +42,26 @@ describe ActiveForce::SObject do
33
42
  end
34
43
  end
35
44
  end
45
+
46
+ describe '#create' do
47
+
48
+ subject do
49
+ Whizbang.new
50
+ end
51
+
52
+ before do
53
+ Client.should_receive(:create!).and_return('id')
54
+ end
55
+
56
+ it 'delegates to the Client with create!' do
57
+ subject.create
58
+ end
59
+
60
+ it 'sets the id' do
61
+ subject.create
62
+ expect(subject.id).to eq('id')
63
+ end
64
+
65
+ end
66
+
36
67
  end
@@ -1,5 +1,6 @@
1
1
  class Whizbang < ActiveForce::SObject
2
2
 
3
+ field :id, from: 'Id'
3
4
  field :checkbox, from: 'Checkbox_Label'
4
5
  field :text, from: 'Text_Label'
5
6
  field :date, from: 'Date_Label'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_force
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.alfa
4
+ version: 0.0.5.alfa
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Espinaco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-05 00:00:00.000000000 Z
11
+ date: 2013-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: restforce
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement