spark_api 1.4.34 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/spark_api/authentication/api_auth.rb +1 -1
- data/lib/spark_api/authentication/oauth2.rb +1 -1
- data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +1 -1
- data/lib/spark_api/client.rb +2 -2
- data/lib/spark_api/request.rb +1 -1
- data/spec/spec_helper.rb +9 -4
- data/spec/unit/spark_api/authentication/api_auth_spec.rb +21 -22
- data/spec/unit/spark_api/authentication/base_auth_spec.rb +3 -3
- data/spec/unit/spark_api/authentication/oauth2_impl/faraday_middleware_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +1 -1
- data/spec/unit/spark_api/authentication/oauth2_impl/single_session_provider_spec.rb +2 -2
- data/spec/unit/spark_api/authentication/oauth2_spec.rb +40 -40
- data/spec/unit/spark_api/authentication_spec.rb +2 -2
- data/spec/unit/spark_api/configuration/yaml_spec.rb +44 -44
- data/spec/unit/spark_api/configuration_spec.rb +56 -57
- data/spec/unit/spark_api/faraday_middleware_spec.rb +12 -12
- data/spec/unit/spark_api/models/account_spec.rb +20 -20
- data/spec/unit/spark_api/models/activity_spec.rb +5 -5
- data/spec/unit/spark_api/models/base_spec.rb +32 -32
- data/spec/unit/spark_api/models/concerns/destroyable_spec.rb +2 -2
- data/spec/unit/spark_api/models/concerns/savable_spec.rb +19 -19
- data/spec/unit/spark_api/models/connect_prefs_spec.rb +1 -1
- data/spec/unit/spark_api/models/constraint_spec.rb +1 -1
- data/spec/unit/spark_api/models/contact_spec.rb +50 -50
- data/spec/unit/spark_api/models/dirty_spec.rb +12 -12
- data/spec/unit/spark_api/models/document_spec.rb +3 -3
- data/spec/unit/spark_api/models/fields_spec.rb +17 -17
- data/spec/unit/spark_api/models/finders_spec.rb +7 -7
- data/spec/unit/spark_api/models/floplan_spec.rb +4 -4
- data/spec/unit/spark_api/models/listing_cart_spec.rb +46 -46
- data/spec/unit/spark_api/models/listing_meta_translations_spec.rb +6 -6
- data/spec/unit/spark_api/models/listing_spec.rb +91 -91
- data/spec/unit/spark_api/models/message_spec.rb +10 -10
- data/spec/unit/spark_api/models/note_spec.rb +10 -10
- data/spec/unit/spark_api/models/notification_spec.rb +6 -6
- data/spec/unit/spark_api/models/open_house_spec.rb +4 -4
- data/spec/unit/spark_api/models/photo_spec.rb +8 -8
- data/spec/unit/spark_api/models/portal_spec.rb +4 -4
- data/spec/unit/spark_api/models/property_types_spec.rb +5 -5
- data/spec/unit/spark_api/models/rental_calendar_spec.rb +13 -11
- data/spec/unit/spark_api/models/rule_spec.rb +2 -2
- data/spec/unit/spark_api/models/saved_search_spec.rb +33 -33
- data/spec/unit/spark_api/models/search_template/quick_search_spec.rb +5 -5
- data/spec/unit/spark_api/models/shared_listing_spec.rb +12 -12
- data/spec/unit/spark_api/models/sort_spec.rb +3 -3
- data/spec/unit/spark_api/models/standard_fields_spec.rb +12 -12
- data/spec/unit/spark_api/models/subresource_spec.rb +18 -18
- data/spec/unit/spark_api/models/system_info_spec.rb +7 -7
- data/spec/unit/spark_api/models/tour_of_home_spec.rb +3 -3
- data/spec/unit/spark_api/models/video_spec.rb +9 -9
- data/spec/unit/spark_api/models/virtual_tour_spec.rb +7 -7
- data/spec/unit/spark_api/models/vow_account_spec.rb +8 -8
- data/spec/unit/spark_api/multi_client_spec.rb +14 -14
- data/spec/unit/spark_api/options_hash_spec.rb +4 -4
- data/spec/unit/spark_api/paginate_spec.rb +71 -71
- data/spec/unit/spark_api/primary_array_spec.rb +5 -5
- data/spec/unit/spark_api/request_spec.rb +60 -60
- data/spec/unit/spark_api_spec.rb +6 -6
- metadata +162 -233
@@ -15,15 +15,15 @@ describe Dirty do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "lets you know if you've changed any attributes" do
|
18
|
-
@model.changed
|
18
|
+
expect(@model.changed?).to be true
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return an array of the attributes that have been changed" do
|
22
|
-
@model.changed.
|
22
|
+
expect(@model.changed).to eq(["Name"])
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return a hash diff of current changes on a model" do
|
26
|
-
@model.changes.
|
26
|
+
expect(@model.changes).to eq({
|
27
27
|
"Name" => ["some old name", "a new name"]
|
28
28
|
})
|
29
29
|
end
|
@@ -31,34 +31,34 @@ describe Dirty do
|
|
31
31
|
it "should return previously changed attributes after save" do
|
32
32
|
stub_api_post('/test/example', { :MyExampleModels => [ @model.attributes ] }, 'base.json')
|
33
33
|
@model.save
|
34
|
-
@model.previous_changes.
|
34
|
+
expect(@model.previous_changes).to eq({
|
35
35
|
})
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should return changed attributes with old values" do
|
39
|
-
@model.changed_attributes.
|
39
|
+
expect(@model.changed_attributes).to eq({
|
40
40
|
"Name" => "some old name"
|
41
41
|
})
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should return changed attributes with new values" do
|
45
|
-
@model.dirty_attributes.
|
45
|
+
expect(@model.dirty_attributes).to eq({
|
46
46
|
"Name" => "a new name"
|
47
47
|
})
|
48
48
|
end
|
49
49
|
|
50
50
|
it "does not mark attributes dirty when initialized" do
|
51
51
|
@model = MyExampleModel.new(:Name => "some sort of name")
|
52
|
-
@model.attributes.size.
|
53
|
-
@model.changed_attributes.
|
54
|
-
@model.dirty_attributes.
|
52
|
+
expect(@model.attributes.size).to eq(1)
|
53
|
+
expect(@model.changed_attributes).to eq({})
|
54
|
+
expect(@model.dirty_attributes).to eq({})
|
55
55
|
end
|
56
56
|
|
57
57
|
it "marks attributes dirty that are loaded later" do
|
58
58
|
@model.load(:Name => "some sort of name")
|
59
|
-
@model.attributes.size.
|
60
|
-
@model.changed_attributes.
|
61
|
-
@model.dirty_attributes.
|
59
|
+
expect(@model.attributes.size).to eq(1)
|
60
|
+
expect(@model.changed_attributes).to eq({"Name"=>"some old name"})
|
61
|
+
expect(@model.dirty_attributes).to eq({"Name"=>"some sort of name"})
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -11,7 +11,7 @@ describe Document do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should respond to a few methods" do
|
14
|
-
Document.
|
14
|
+
expect(Document).to respond_to(:find_by_listing_key)
|
15
15
|
end
|
16
16
|
|
17
17
|
context "/listings/<listing_id>/documents" do
|
@@ -20,8 +20,8 @@ describe Document do
|
|
20
20
|
stub_api_get('/listings/1234/documents','listings/document_index.json')
|
21
21
|
|
22
22
|
v = Document.find_by_listing_key('1234')
|
23
|
-
v.
|
24
|
-
v.length.
|
23
|
+
expect(v).to be_an(Array)
|
24
|
+
expect(v.length).to eq(2)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -7,7 +7,7 @@ describe Fields do
|
|
7
7
|
|
8
8
|
context "/fields/order", :support do
|
9
9
|
on_get_it "should find field orders for all property types" do
|
10
|
-
Fields.
|
10
|
+
expect(Fields).to respond_to(:order)
|
11
11
|
|
12
12
|
# stub request
|
13
13
|
stub_api_get('/fields/order','fields/order.json')
|
@@ -16,20 +16,20 @@ describe Fields do
|
|
16
16
|
resources = subject.class.order
|
17
17
|
|
18
18
|
# a standard array of results
|
19
|
-
resources.
|
20
|
-
resources.length.
|
19
|
+
expect(resources).to be_an(Array)
|
20
|
+
expect(resources.length).to eq(1)
|
21
21
|
|
22
22
|
# make sure multiple property types are present
|
23
|
-
resources.first.
|
24
|
-
resources.first.
|
23
|
+
expect(resources.first).to have_key("A")
|
24
|
+
expect(resources.first).to have_key("B")
|
25
25
|
|
26
|
-
resources.first["A"].
|
26
|
+
expect(resources.first["A"]).to be_an(Array)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
context "/fields/order/<property_type>", :support do
|
31
31
|
on_get_it "should find field order for a single property type" do
|
32
|
-
Fields.
|
32
|
+
expect(Fields).to respond_to(:order)
|
33
33
|
|
34
34
|
# stub request
|
35
35
|
stub_api_get('/fields/order/A','fields/order_a.json')
|
@@ -38,15 +38,15 @@ describe Fields do
|
|
38
38
|
resources = subject.class.order("A")
|
39
39
|
|
40
40
|
# a standard array of results
|
41
|
-
resources.
|
42
|
-
resources.length.
|
41
|
+
expect(resources).to be_an(Array)
|
42
|
+
expect(resources.length).to eq(2)
|
43
43
|
|
44
44
|
# validate a single entity
|
45
45
|
group = resources.first[resources.first.keys.first]
|
46
|
-
group.
|
47
|
-
group.length.
|
46
|
+
expect(group).to be_an(Array)
|
47
|
+
expect(group.length).to eq(2)
|
48
48
|
group.each do |field|
|
49
|
-
field.
|
49
|
+
expect(field).to have_key("Field")
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -54,7 +54,7 @@ describe Fields do
|
|
54
54
|
|
55
55
|
context "/fields/order/settings", :support do
|
56
56
|
on_get_it "returns the field order settings" do
|
57
|
-
Fields.
|
57
|
+
expect(Fields).to respond_to(:settings)
|
58
58
|
|
59
59
|
# stub request
|
60
60
|
stub_api_get('/fields/order/settings','fields/settings.json')
|
@@ -63,12 +63,12 @@ describe Fields do
|
|
63
63
|
settings = subject.class.settings
|
64
64
|
|
65
65
|
# a standard array of results
|
66
|
-
settings.
|
67
|
-
settings.length.
|
66
|
+
expect(settings).to be_an(Array)
|
67
|
+
expect(settings.length).to eq(1)
|
68
68
|
|
69
69
|
# make sure ShowingInstructions is present
|
70
|
-
settings.first.
|
71
|
-
settings.first["ShowingInstructions"].
|
70
|
+
expect(settings.first).to have_key("ShowingInstructions")
|
71
|
+
expect(settings.first["ShowingInstructions"]).to be_an(Array)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -14,13 +14,13 @@ describe Finders, "Finders model" do
|
|
14
14
|
it "should get first result" do
|
15
15
|
stub_api_get("/my_resource", 'finders.json')
|
16
16
|
resource = MyResource.first
|
17
|
-
resource.Id.
|
17
|
+
expect(resource.Id).to eq(1)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should get last result" do
|
21
21
|
stub_api_get("/my_resource", 'finders.json')
|
22
22
|
resource = MyResource.last
|
23
|
-
resource.Id.
|
23
|
+
expect(resource.Id).to eq(2)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should find one result" do
|
@@ -29,23 +29,23 @@ describe Finders, "Finders model" do
|
|
29
29
|
:_filter => "Something Eq 'dude'"
|
30
30
|
})
|
31
31
|
resource = MyResource.find_one(:_filter => "Something Eq 'dude'")
|
32
|
-
resource.Id.
|
32
|
+
expect(resource.Id).to eq(1)
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "find" do
|
36
36
|
|
37
37
|
it "should throw an error if no argument is passed" do
|
38
38
|
stub_api_get("/my_resource/", 'finders.json')
|
39
|
-
|
39
|
+
expect {
|
40
40
|
MyResource.find()
|
41
|
-
}.
|
41
|
+
}.to raise_error(ArgumentError)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should throw an error when the first argument is nil" do
|
45
45
|
stub_api_get("/my_resource/", 'finders.json', {:_limit => 1})
|
46
|
-
|
46
|
+
expect {
|
47
47
|
MyResource.find(nil, {:_limit => 1})
|
48
|
-
}.
|
48
|
+
}.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -3,7 +3,7 @@ require './spec/spec_helper'
|
|
3
3
|
describe FloPlan do
|
4
4
|
|
5
5
|
it "responds to" do
|
6
|
-
FloPlan.
|
6
|
+
expect(FloPlan).to respond_to(:find_by_listing_key)
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "/listings/<listing_id>/videos", :support do
|
@@ -14,9 +14,9 @@ describe FloPlan do
|
|
14
14
|
|
15
15
|
on_get_it "should correctly split images and thumbnails" do
|
16
16
|
p = FloPlan.find_by_listing_key('1234').first
|
17
|
-
p.attributes['Images'].length.
|
18
|
-
p.images.length.
|
19
|
-
p.thumbnails.length.
|
17
|
+
expect(p.attributes['Images'].length).to eq(2)
|
18
|
+
expect(p.images.length).to eq(1)
|
19
|
+
expect(p.thumbnails.length).to eq(1)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -9,9 +9,9 @@ describe ListingCart do
|
|
9
9
|
on_get_it "should get all listing carts" do
|
10
10
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
11
11
|
resources = subject.class.get
|
12
|
-
resources.
|
13
|
-
resources.length.
|
14
|
-
resources.first.Id.
|
12
|
+
expect(resources).to be_an(Array)
|
13
|
+
expect(resources.length).to eq(2)
|
14
|
+
expect(resources.first.Id).to eq("20100912153422758914000000")
|
15
15
|
end
|
16
16
|
|
17
17
|
on_post_it "should save a new listing cart" do
|
@@ -20,8 +20,8 @@ describe ListingCart do
|
|
20
20
|
'20110302120238448431000000',
|
21
21
|
'20110510011212354751000000']
|
22
22
|
subject.Name = "My Cart's Name"
|
23
|
-
subject.save.
|
24
|
-
subject.ResourceUri.
|
23
|
+
expect(subject.save).to be(true)
|
24
|
+
expect(subject.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
|
25
25
|
end
|
26
26
|
|
27
27
|
on_post_it "should fail saving" do
|
@@ -29,8 +29,8 @@ describe ListingCart do
|
|
29
29
|
request.to_return(:status => 400, :body => fixture('errors/failure.json'))
|
30
30
|
end
|
31
31
|
subject
|
32
|
-
subject.save.
|
33
|
-
expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.
|
32
|
+
expect(subject.save).to be(false)
|
33
|
+
expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(400) }
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -38,9 +38,9 @@ describe ListingCart do
|
|
38
38
|
on_get_it "should get a listing cart" do
|
39
39
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
40
40
|
resource = subject.class.get.first
|
41
|
-
resource.Id.
|
42
|
-
resource.Name.
|
43
|
-
resource.ListingCount.
|
41
|
+
expect(resource.Id).to eq("20100912153422758914000000")
|
42
|
+
expect(resource.Name).to eq("My Listing Cart")
|
43
|
+
expect(resource.ListingCount).to eq(10)
|
44
44
|
end
|
45
45
|
|
46
46
|
on_put_it "should save a listing cart Name" do
|
@@ -48,9 +48,9 @@ describe ListingCart do
|
|
48
48
|
resource = subject.class.get.first
|
49
49
|
stub_api_put("/#{subject.class.element_name}/#{resource.Id}", 'listing_carts/put_name.json', 'success.json')
|
50
50
|
resource.Name = "My Cart's Name"
|
51
|
-
resource.changed
|
52
|
-
resource.save.
|
53
|
-
resource.ResourceUri.
|
51
|
+
expect(resource.changed?).to be(true)
|
52
|
+
expect(resource.save).to be(true)
|
53
|
+
expect(resource.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
|
54
54
|
end
|
55
55
|
|
56
56
|
on_put_it "should save a listing cart ListingIds" do
|
@@ -60,41 +60,41 @@ describe ListingCart do
|
|
60
60
|
resource.ListingIds = ['20110112234857732941000000',
|
61
61
|
'20110302120238448431000000',
|
62
62
|
'20110510011212354751000000']
|
63
|
-
resource.changed
|
64
|
-
resource.save.
|
65
|
-
resource.ResourceUri.
|
63
|
+
expect(resource.changed?).to be(true)
|
64
|
+
expect(resource.save).to be(true)
|
65
|
+
expect(resource.ResourceUri).to eq("/v1/listingcarts/20100912153422758914000000")
|
66
66
|
end
|
67
67
|
|
68
68
|
on_post_it "should add a listing to a cart" do
|
69
69
|
list_id = "20110621133454434543000000"
|
70
70
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
71
71
|
resource = subject.class.get.first
|
72
|
-
resource.Id.
|
72
|
+
expect(resource.Id).to eq("20100912153422758914000000")
|
73
73
|
stub_api_post("/#{subject.class.element_name}/#{resource.Id}",'listing_carts/add_listing_post.json', 'listing_carts/add_listing.json')
|
74
|
-
resource.ListingCount.
|
74
|
+
expect(resource.ListingCount).to eq(10)
|
75
75
|
resource.add_listing(list_id)
|
76
|
-
resource.ListingCount.
|
76
|
+
expect(resource.ListingCount).to eq(11)
|
77
77
|
end
|
78
78
|
|
79
79
|
on_post_it "should add multiple listings to a cart" do
|
80
80
|
listing_ids = ["20110621133454434543000000", "20110621133454434543000001"]
|
81
81
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
82
82
|
resource = subject.class.get.first
|
83
|
-
resource.Id.
|
83
|
+
expect(resource.Id).to eq("20100912153422758914000000")
|
84
84
|
stub_api_post("/#{subject.class.element_name}/#{resource.Id}",'listing_carts/add_listings_post.json', 'listing_carts/add_listings.json')
|
85
|
-
resource.ListingCount.
|
85
|
+
expect(resource.ListingCount).to eq(10)
|
86
86
|
resource.add_listings(listing_ids)
|
87
|
-
resource.ListingCount.
|
87
|
+
expect(resource.ListingCount).to eq(12)
|
88
88
|
end
|
89
89
|
|
90
90
|
on_delete_it "should delete a listing cart" do
|
91
91
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
92
92
|
resource = subject.class.get.first
|
93
|
-
resource.Id.
|
94
|
-
resource.Name.
|
95
|
-
resource.ListingCount.
|
93
|
+
expect(resource.Id).to eq("20100912153422758914000000")
|
94
|
+
expect(resource.Name).to eq("My Listing Cart")
|
95
|
+
expect(resource.ListingCount).to eq(10)
|
96
96
|
stub_api_delete("/#{subject.class.element_name}/#{resource.Id}", 'success.json')
|
97
|
-
resource.delete.
|
97
|
+
expect(resource.delete).to be(true)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -103,11 +103,11 @@ describe ListingCart do
|
|
103
103
|
list_id = "20110621133454434543000000"
|
104
104
|
stub_api_get("/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
105
105
|
resource = subject.class.get.first
|
106
|
-
resource.Id.
|
106
|
+
expect(resource.Id).to eq("20100912153422758914000000")
|
107
107
|
stub_api_delete("/#{subject.class.element_name}/#{resource.Id}/listings/#{list_id}", 'listing_carts/remove_listing.json')
|
108
|
-
resource.ListingCount.
|
108
|
+
expect(resource.ListingCount).to eq(10)
|
109
109
|
resource.remove_listing(list_id)
|
110
|
-
resource.ListingCount.
|
110
|
+
expect(resource.ListingCount).to eq(9)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -117,9 +117,9 @@ describe ListingCart do
|
|
117
117
|
stub_api_get("/#{subject.class.element_name}/for/#{listing.Id}", 'listing_carts/listing_cart.json')
|
118
118
|
[listing, listing.Id ].each do |l|
|
119
119
|
resources = subject.class.for(l)
|
120
|
-
resources.
|
121
|
-
resources.length.
|
122
|
-
resources.first.Id.
|
120
|
+
expect(resources).to be_an(Array)
|
121
|
+
expect(resources.length).to eq(2)
|
122
|
+
expect(resources.first.Id).to eq("20100912153422758914000000")
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -128,9 +128,9 @@ describe ListingCart do
|
|
128
128
|
on_get_it "should get the carts for a user" do
|
129
129
|
stub_api_get("/my/#{subject.class.element_name}", 'listing_carts/listing_cart.json')
|
130
130
|
resources = subject.class.my
|
131
|
-
resources.
|
132
|
-
resources.length.
|
133
|
-
resources.first.Id.
|
131
|
+
expect(resources).to be_an(Array)
|
132
|
+
expect(resources.length).to eq(2)
|
133
|
+
expect(resources.first.Id).to eq("20100912153422758914000000")
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -138,9 +138,9 @@ describe ListingCart do
|
|
138
138
|
on_get_it "should get the carts specific to a portal user" do
|
139
139
|
stub_api_get("/#{subject.class.element_name}/portal", 'listing_carts/listing_cart.json')
|
140
140
|
resources = subject.class.portal
|
141
|
-
resources.
|
142
|
-
resources.length.
|
143
|
-
resources.first.Id.
|
141
|
+
expect(resources).to be_an(Array)
|
142
|
+
expect(resources.length).to eq(2)
|
143
|
+
expect(resources.first.Id).to eq("20100912153422758914000000")
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -148,38 +148,38 @@ describe ListingCart do
|
|
148
148
|
it "should return the listings in the cart" do
|
149
149
|
resource = subject.class.new Id: 5, ListingIds: ["1234"]
|
150
150
|
stub_api_get("/#{subject.class.element_name}/#{resource.Id}/listings", 'listings/multiple.json')
|
151
|
-
resource.listings.
|
152
|
-
resource.listings.first.
|
151
|
+
expect(resource.listings).to be_a(Array)
|
152
|
+
expect(resource.listings.first).to be_a(Listing)
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should return an empty array if there aren't any listings" do
|
156
156
|
resource = subject.class.new Id: 5
|
157
|
-
resource.listings.
|
158
|
-
resource.listings.count.
|
157
|
+
expect(resource.listings).to be_a(Array)
|
158
|
+
expect(resource.listings.count).to be === 0
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe "filter" do
|
163
163
|
it "should return a filter string for the cart" do
|
164
164
|
resource = subject.class.new Id: 5
|
165
|
-
resource.filter.
|
165
|
+
expect(resource.filter).to eq("ListingCart Eq '5'")
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
169
|
describe "#deletable?" do
|
170
170
|
it "should return true for private custom carts" do
|
171
171
|
resource = subject.class.new
|
172
|
-
expect(resource.deletable?).to
|
172
|
+
expect(resource.deletable?).to be true
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should return true for custom vow carts" do
|
176
176
|
resource = subject.class.new PortalCartType: "Custom"
|
177
|
-
expect(resource.deletable?).to
|
177
|
+
expect(resource.deletable?).to be true
|
178
178
|
end
|
179
179
|
|
180
180
|
it "should return false for vow carts" do
|
181
181
|
resource = subject.class.new PortalCartType: "Favorites"
|
182
|
-
expect(resource.deletable?).to
|
182
|
+
expect(resource.deletable?).to be false
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -12,18 +12,18 @@ describe ListingMetaTranslations do
|
|
12
12
|
stub_api_get("/flexmls/propertytypes/A/translations", 'listing_meta_translations/get.json')
|
13
13
|
|
14
14
|
translations = ListingMetaTranslations.for_property_type('A')
|
15
|
-
translations.
|
16
|
-
translations.StandardFields.
|
17
|
-
translations.CustomFields.
|
15
|
+
expect(translations).to be_an(ListingMetaTranslations)
|
16
|
+
expect(translations.StandardFields).to be_an(Hash)
|
17
|
+
expect(translations.CustomFields).to be_an(Hash)
|
18
18
|
end
|
19
19
|
|
20
20
|
on_get_it "doesn't explode if there are no results" do
|
21
21
|
stub_api_get("/flexmls/propertytypes/A/translations", 'no_results.json')
|
22
22
|
|
23
23
|
translations = ListingMetaTranslations.for_property_type('A')
|
24
|
-
translations.
|
25
|
-
translations.StandardFields.
|
26
|
-
translations.CustomFields.
|
24
|
+
expect(translations).to be_an(ListingMetaTranslations)
|
25
|
+
expect(translations.StandardFields).to be_an(Hash)
|
26
|
+
expect(translations.CustomFields).to be_an(Hash)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|