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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f452894d844ea9b848fe51385e38abc029521c1d
4
- data.tar.gz: 20ad8d6c35bbbc4e74d80c9db4cfe7b53047bbea
3
+ metadata.gz: 55ceae02934c61630d9e23181c359da1ce075633
4
+ data.tar.gz: 26d8d07be91e95768f9db4625404f7c3da206026
5
5
  SHA512:
6
- metadata.gz: 734f9091d1f30d9ab081e5758b4b1e33366f9b4f7ae8063c11063dd92dfd658577eda29048fb6420feec0dad5b64c435873ff835be2c934a91071d9e4e920075
7
- data.tar.gz: a400d106a49f5e56a494f54619d113ebaf660c52d141ea3cc89306568660a224c692188217748a7df9d7d04464adcf3ab56fb5d1be37d1a4487937be4ac0ddf8
6
+ metadata.gz: d597e470445d8695113a62ff6003c2550077368b362a152bf3ef05c46d12c40436ce12dbd16ae72199d3030142c6e021004a2fc3f25fa987aa016ee2bfc87906
7
+ data.tar.gz: fd3d6f772d3a27a6b06ee4b061f4264794db487a7a50ee7da7cf0c16242e0fc195339b5055671eb70fbf88fcc097988d441ad3b4cd9f0ccbacd74cfafbf1cd6e
@@ -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) * @size
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.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mls"
6
- s.version = '0.9.2'
6
+ s.version = '0.9.3'
7
7
  s.authors = ["James R. Bracy", "Jon Bracy"]
8
8
  s.email = ["james@42floors.com"]
9
9
  s.homepage = "http://mls.42floors.com"
@@ -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.2
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-28 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake