spark_api 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjFjYTgyZjBhYTRiMjM1MTIzYzkxODEwYjlmNjg5ZTQ3ZmUwZmY2OA==
4
+ Y2U5OGIwYmZhZWFlZWQ2Njc1NzA4YmMxNzhjN2NiYTZlNjEzZTA5Yg==
5
5
  data.tar.gz: !binary |-
6
- ZDUxMGNkNzVkMTQzNmJjOTgxY2JhMjBjMjA5ZDNkYjkzZDk2Zjc1ZA==
6
+ MzM2NGZjNmMxMWU1MWY4OTMwZDczN2VhZmVmM2EzMjUyM2ZmNTM2MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2IwNzI3MmRjOTJmOGYxOWMyYzBmZjA4ZjViNmY3YTQ5ZjM2ZWMwZTE4ZTBl
10
- ZjgwY2JjN2IzZGEzYWY1NmRjZmY1Y2UwMWNhMjcwMzNhMGVjY2ZhNmNkMzgx
11
- ZjY5ODY3ZjE3NDQzMGZiOGRmNzYzZTJjZDg5ZjEwNTRlNGU2ZTM=
9
+ ODY1Mjk3OTZhYTc3YmQ4ZTgwMzc1NGM5YjMxNjg2NjM3ZDFhYmRiOGVkYWFm
10
+ MTVhYWUxZmViNzI1NTY4NTI5MjBhMTEyM2IzMDI4Y2Q1NTBkOTM3YzRiYmI2
11
+ ZjUyYWVmYTk0NzFhY2IyMGY1NmVjMGRlNGJjYTYxYWNkODZjY2I=
12
12
  data.tar.gz: !binary |-
13
- ZjgwNDE2NThkY2IxMjFiYjE3NGFjOWI4NzU1MjZlMTgxYTY0ZmZlN2Y2ZmIy
14
- NmQ2Yzg5NzZjZTViMWYyNjNkMjE4MGUxNDE3MjE2OTExMzZjNGYwOGE2NGVk
15
- ZDhkMjJmMTVhZmQ1NjllNGYyZWM4MTc2ZTc5ZmIyMDk2M2JiMDE=
13
+ MTJmZTBiMDdhM2ZmY2U0Y2JmNGI0OTNlMWI2M2RmMGU2NmU5YTk0NGZmNjJl
14
+ ODMwY2EyODBjZTAwNWVhOWIzYmY4ODllNWMzMTNkOGQzNDkwNDJiNmRiNTVh
15
+ NTA5ZmYzYjg1ZWEyNWEyZjZiNzI0ZDkzYjE1NGVkMWY0Y2M1YTI=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -2,6 +2,7 @@ require 'spark_api/models/dirty'
2
2
  require 'spark_api/models/base'
3
3
  require 'spark_api/models/constraint'
4
4
  require 'spark_api/models/finders'
5
+ require 'spark_api/models/defaultable'
5
6
  require 'spark_api/models/subresource'
6
7
  require 'spark_api/models/concerns'
7
8
 
@@ -0,0 +1,37 @@
1
+ module SparkApi
2
+ module Models
3
+ module Defaultable
4
+
5
+ DEFAULT_ID = "default"
6
+
7
+ extend Finders
8
+
9
+ def self.included(base)
10
+
11
+ class << base
12
+ alias original_find find
13
+ end
14
+
15
+ base.extend(ClassMethods)
16
+
17
+ end
18
+
19
+ module ClassMethods
20
+
21
+ def default(options = {})
22
+ find(DEFAULT_ID, options)
23
+ end
24
+
25
+ def find(*arguments)
26
+ result = original_find(*arguments)
27
+ if arguments.first == DEFAULT_ID
28
+ result.Id = DEFAULT_ID if result.Id.nil?
29
+ end
30
+ result
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -3,16 +3,12 @@ module SparkApi
3
3
  class IdxLink < Base
4
4
 
5
5
  extend Finders
6
+ include Defaultable
6
7
 
7
8
  self.element_name = "idxlinks"
8
9
 
9
10
  LINK_TYPES = ["QuickSearch", "SavedSearch", "MyListings", "Roster"]
10
11
 
11
- def self.default(options = {})
12
- response = connection.get("/#{self.element_name}/default", options).first
13
- response.nil? ? nil : new(response)
14
- end
15
-
16
12
  end
17
13
  end
18
14
  end
@@ -2,6 +2,7 @@ module SparkApi
2
2
  module Models
3
3
  class QuickSearch < Base
4
4
  extend Finders
5
+ include Defaultable
5
6
  include Concerns::Savable,
6
7
  Concerns::Destroyable
7
8
 
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Defaultable do
4
+
5
+ module SparkApi
6
+ module Models
7
+ class TestClass < Base
8
+ extend Finders
9
+ include Defaultable
10
+ self.element_name = 'testclass'
11
+ end
12
+ end
13
+ end
14
+
15
+ describe 'default' do
16
+
17
+ it 'calls find' do
18
+ expect(TestClass).to receive(:find).with('default', {})
19
+ TestClass.default
20
+ end
21
+
22
+ end
23
+
24
+ describe 'find' do
25
+
26
+ it "adds the id 'default'" do
27
+ allow(TestClass).to receive(:connection).and_return(double(get: [{Id: nil, Name: 'foo'}]))
28
+ default = TestClass.find(TestClass::DEFAULT_ID)
29
+ expect(default.Id).to eq 'default'
30
+ end
31
+
32
+ it "doesn't override the id if one is present" do
33
+ allow(TestClass).to receive(:connection).and_return(double(get: [{Id: '5', Name: 'foo'}]))
34
+ expect(TestClass.find(TestClass::DEFAULT_ID).Id).to eq '5'
35
+ end
36
+
37
+ it "calls Finders.find when given a normal id" do
38
+ connection = double
39
+ expect(connection).to receive(:get).with("/testclass/5", {foo: true}).and_return([{}])
40
+ allow(TestClass).to receive(:connection).and_return(connection)
41
+ TestClass.find('5', foo: true)
42
+ end
43
+
44
+ end
45
+
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hornseth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-18 00:00:00.000000000 Z
12
+ date: 2016-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -285,6 +285,7 @@ files:
285
285
  - lib/spark_api/models/constraint.rb
286
286
  - lib/spark_api/models/contact.rb
287
287
  - lib/spark_api/models/custom_fields.rb
288
+ - lib/spark_api/models/defaultable.rb
288
289
  - lib/spark_api/models/dirty.rb
289
290
  - lib/spark_api/models/document.rb
290
291
  - lib/spark_api/models/fields.rb
@@ -480,11 +481,11 @@ files:
480
481
  - spec/unit/spark_api/models/connect_prefs_spec.rb
481
482
  - spec/unit/spark_api/models/constraint_spec.rb
482
483
  - spec/unit/spark_api/models/contact_spec.rb
484
+ - spec/unit/spark_api/models/defaultable_spec.rb
483
485
  - spec/unit/spark_api/models/dirty_spec.rb
484
486
  - spec/unit/spark_api/models/document_spec.rb
485
487
  - spec/unit/spark_api/models/fields_spec.rb
486
488
  - spec/unit/spark_api/models/finders_spec.rb
487
- - spec/unit/spark_api/models/idx_link_spec.rb
488
489
  - spec/unit/spark_api/models/listing_cart_spec.rb
489
490
  - spec/unit/spark_api/models/listing_spec.rb
490
491
  - spec/unit/spark_api/models/message_spec.rb
@@ -686,6 +687,7 @@ test_files:
686
687
  - spec/unit/spark_api/authentication/base_auth_spec.rb
687
688
  - spec/unit/spark_api/configuration_spec.rb
688
689
  - spec/unit/spark_api/request_spec.rb
690
+ - spec/unit/spark_api/models/defaultable_spec.rb
689
691
  - spec/unit/spark_api/models/news_feed_meta_spec.rb
690
692
  - spec/unit/spark_api/models/open_house_spec.rb
691
693
  - spec/unit/spark_api/models/document_spec.rb
@@ -719,7 +721,6 @@ test_files:
719
721
  - spec/unit/spark_api/models/property_types_spec.rb
720
722
  - spec/unit/spark_api/models/base_spec.rb
721
723
  - spec/unit/spark_api/models/subresource_spec.rb
722
- - spec/unit/spark_api/models/idx_link_spec.rb
723
724
  - spec/unit/spark_api/models/vow_account_spec.rb
724
725
  - spec/unit/spark_api/models/activity_spec.rb
725
726
  - spec/unit/spark_api_spec.rb
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe IdxLink do
4
-
5
- before :each do
6
- stub_auth_request
7
- end
8
-
9
- describe "/idxlinks/default" do
10
-
11
- on_get_it "returns an agent's default idx link" do
12
- s = stub_api_get("/idxlinks/default", "idx_links/get.json")
13
- @idx_link = subject.class.default
14
- @idx_link.should be_an(IdxLink)
15
- @idx_link.Uri.should eq("http://link.dev.fbsdata.com/zq1fkiw4d3f,1")
16
- s.should have_been_requested
17
- end
18
-
19
- on_get_it "returns nil if the user doesn't have one" do
20
- s = stub_api_get("/idxlinks/default", "no_results.json")
21
- @idx_link = subject.class.default
22
- @idx_link.should be_nil
23
- s.should have_been_requested
24
- end
25
-
26
- end
27
-
28
- end