mls 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mls/models/listing.rb +4 -2
- data/mls.gemspec +1 -1
- data/test/units/models/test_listing.rb +31 -20
- 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: 55ceae02934c61630d9e23181c359da1ce075633
|
4
|
+
data.tar.gz: 26d8d07be91e95768f9db4625404f7c3da206026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d597e470445d8695113a62ff6003c2550077368b362a152bf3ef05c46d12c40436ce12dbd16ae72199d3030142c6e021004a2fc3f25fa987aa016ee2bfc87906
|
7
|
+
data.tar.gz: fd3d6f772d3a27a6b06ee4b061f4264794db487a7a50ee7da7cf0c16242e0fc195339b5055671eb70fbf88fcc097988d441ad3b4cd9f0ccbacd74cfafbf1cd6e
|
data/lib/mls/models/listing.rb
CHANGED
@@ -155,7 +155,7 @@ class MLS::Listing < MLS::Resource
|
|
155
155
|
# TODO: remove /desk/mo conversions
|
156
156
|
def rate(units='/sqft/mo')
|
157
157
|
|
158
|
-
if rate_units == '/sqft/mo'
|
158
|
+
price = if rate_units == '/sqft/mo'
|
159
159
|
if units == '/sqft/mo'
|
160
160
|
@rate
|
161
161
|
elsif units == '/sqft/yr'
|
@@ -176,7 +176,7 @@ class MLS::Listing < MLS::Resource
|
|
176
176
|
elsif units == '/sqft/yr'
|
177
177
|
@rate
|
178
178
|
elsif units == '/mo'
|
179
|
-
(@rate / 12.0
|
179
|
+
(@rate * @size) / 12.0
|
180
180
|
elsif units == '/yr'
|
181
181
|
@rate * @size
|
182
182
|
elsif units == '/desk/mo'
|
@@ -231,6 +231,8 @@ class MLS::Listing < MLS::Resource
|
|
231
231
|
end
|
232
232
|
|
233
233
|
end
|
234
|
+
|
235
|
+
price.round(2)
|
234
236
|
end
|
235
237
|
|
236
238
|
# Creates a tour request for the listing.
|
data/mls.gemspec
CHANGED
@@ -4,7 +4,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def test_properties
|
6
6
|
listing = MLS::Listing.new
|
7
|
-
|
7
|
+
|
8
8
|
assert listing.respond_to?(:id)
|
9
9
|
assert listing.respond_to?(:address_id)
|
10
10
|
assert listing.respond_to?(:use)
|
@@ -40,20 +40,20 @@ class TestListing < ::Test::Unit::TestCase
|
|
40
40
|
assert listing.respond_to?(:created_at)
|
41
41
|
assert listing.respond_to?(:updated_at)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def test_attr_accessors
|
45
45
|
listing = MLS::Listing.new
|
46
|
-
|
46
|
+
|
47
47
|
assert listing.respond_to?(:address)
|
48
48
|
assert listing.respond_to?(:agents)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def test_instance_methods
|
52
52
|
listing = MLS::Listing.new
|
53
|
-
|
53
|
+
|
54
54
|
assert listing.respond_to?(:photos)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def test_class_methods
|
58
58
|
assert MLS::Listing.respond_to?(:find)
|
59
59
|
end
|
@@ -63,8 +63,8 @@ class TestListing < ::Test::Unit::TestCase
|
|
63
63
|
@name = Faker::Name.name
|
64
64
|
@email = Faker::Internet.email
|
65
65
|
tr = @listing.request_tour(@name, @email)
|
66
|
-
|
67
|
-
|
66
|
+
|
67
|
+
|
68
68
|
assert_equal({}, tr.errors)
|
69
69
|
assert_equal({}, tr.account.errors)
|
70
70
|
# TODO assert_equal({}, tr.listing.errors)
|
@@ -85,7 +85,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
85
85
|
test '#request_tour for email on an account' do
|
86
86
|
@account = FactoryGirl.create(:account)
|
87
87
|
@listing = FactoryGirl.create(:listing)
|
88
|
-
|
88
|
+
|
89
89
|
tr = @listing.request_tour(@account.name, @account.email)
|
90
90
|
assert_equal({}, tr.errors)
|
91
91
|
assert_equal({}, tr.account.errors)
|
@@ -162,7 +162,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
162
162
|
|
163
163
|
info = {:company => '42Floors', :population => 10, :funding => 'string thing', :move_in_date => '2012-09-12'}
|
164
164
|
tr = @listing.request_tour(Faker::Name.name, Faker::Internet.email, info)
|
165
|
-
|
165
|
+
|
166
166
|
assert tr.id
|
167
167
|
assert_equal '42Floors', info[:company]
|
168
168
|
assert_equal 10, info[:population]
|
@@ -176,10 +176,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
176
176
|
assert_equal 'string thing', info[:funding]
|
177
177
|
assert_equal '2012-09-12', info[:move_in_date]
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
def test_rate_per_sqft_per_month
|
181
181
|
listing = MLS::Listing.new(:rate => 10.5, :rate_units => '/sqft/mo', :size => 5)
|
182
|
-
|
182
|
+
|
183
183
|
assert_equal 10.5, listing.rate
|
184
184
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
185
185
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -190,10 +190,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
190
190
|
listing.rate('/random')
|
191
191
|
end
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
def test_rate_per_sqft_per_year
|
195
195
|
listing = MLS::Listing.new(:rate => 126, :rate_units => '/sqft/yr', :size => 5)
|
196
|
-
|
196
|
+
|
197
197
|
assert_equal 10.5, listing.rate
|
198
198
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
199
199
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -204,10 +204,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
204
204
|
listing.rate('/random')
|
205
205
|
end
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
def test_rate_per_month
|
209
209
|
listing = MLS::Listing.new(:rate => 52.5, :rate_units => '/mo', :size => 5)
|
210
|
-
|
210
|
+
|
211
211
|
assert_equal 10.5, listing.rate
|
212
212
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
213
213
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -218,10 +218,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
218
218
|
listing.rate('/random')
|
219
219
|
end
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
def test_rate_per_year
|
223
223
|
listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
|
224
|
-
|
224
|
+
|
225
225
|
assert_equal 10.5, listing.rate
|
226
226
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
227
227
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -232,10 +232,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
232
232
|
listing.rate('/random')
|
233
233
|
end
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
def test_rate_per_desk_per_month
|
237
237
|
listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
|
238
|
-
|
238
|
+
|
239
239
|
assert_equal 10.5, listing.rate
|
240
240
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
241
241
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -246,5 +246,16 @@ class TestListing < ::Test::Unit::TestCase
|
|
246
246
|
listing.rate('/random')
|
247
247
|
end
|
248
248
|
end
|
249
|
+
|
250
|
+
def test_rate_percision
|
251
|
+
listing = MLS::Listing.new(:rate => 47, :rate_units => '/sqft/yr', :size => 5)
|
252
|
+
|
253
|
+
assert_equal 3.92, listing.rate
|
254
|
+
assert_equal 3.92, listing.rate('/sqft/mo')
|
255
|
+
assert_equal 47, listing.rate('/sqft/yr')
|
256
|
+
assert_equal 19.58, listing.rate('/mo')
|
257
|
+
assert_equal 235, listing.rate('/yr')
|
258
|
+
assert_equal 783.33, listing.rate('/desk/mo')
|
259
|
+
end
|
249
260
|
|
250
261
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James R. Bracy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|