mls 0.9.9 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mls.rb +4 -0
- data/lib/mls/factories/account.rb +34 -0
- data/{test → lib/mls}/factories/address.rb +2 -1
- data/{test → lib/mls}/factories/listing.rb +3 -3
- data/lib/mls/factories_helper.rb +7 -0
- data/lib/mls/models/brokerage.rb +27 -0
- data/lib/mls/models/listing.rb +0 -5
- data/lib/mls/parser.rb +17 -17
- data/mls.gemspec +1 -1
- data/test/test_helper.rb +5 -5
- data/test/units/models/test_address.rb +5 -14
- data/test/units/models/test_listing.rb +50 -78
- metadata +7 -10
- data/test/factories/account.rb +0 -18
- data/test/factories/contact.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15fa6c7e0f58d2766b4edf9e9bdee9c08761dfe6
|
4
|
+
data.tar.gz: 0e136cf20c3a0484019cb02c1abb66a3dc32a19c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8836988a9d517f26f7dbc2e40f8778e00272214da7b5d91d45976872557df2c4d5fe7c80ee8e1d62743479d7792d42488fa9eeaae6de2014ceaab6a1815751e5
|
7
|
+
data.tar.gz: ccc3d4e6f6a218d4a0eebb1d3628546574004c6d8130e3f9c3ba38e6b82e44c457763470eb9e9651453afd7e8898aa972daf715bd609f57e648d5817e6dca426
|
data/lib/mls.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :account, :class => MLS::Account do
|
3
|
+
name { Faker::Name.name }
|
4
|
+
email { Faker::Internet.email }
|
5
|
+
password { 'test' }
|
6
|
+
password_confirmation 'test'
|
7
|
+
end
|
8
|
+
|
9
|
+
factory :agent, :class => MLS::Account do
|
10
|
+
phone { Faker::PhoneNumber.phone_number }
|
11
|
+
company { Faker::Company.name }
|
12
|
+
license '12123123123'
|
13
|
+
name { Faker::Name.name }
|
14
|
+
email { Faker::Internet.email }
|
15
|
+
password 'test'
|
16
|
+
password_confirmation 'test'
|
17
|
+
type 'Agent'
|
18
|
+
end
|
19
|
+
|
20
|
+
factory :admin, :class => MLS::Account do
|
21
|
+
name { Faker::Name.name }
|
22
|
+
email { Faker::Internet.email }
|
23
|
+
type {'Admin'}
|
24
|
+
password { 'admin_test' }
|
25
|
+
password_confirmation 'admin_test'
|
26
|
+
end
|
27
|
+
|
28
|
+
factory :ghost_account, :class => MLS::Account do
|
29
|
+
name { Faker::Name.name }
|
30
|
+
email { Faker::Internet.email }
|
31
|
+
password_required { false }
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :listing, :class => MLS::Listing do
|
3
3
|
before(:create) { |l|
|
4
|
-
|
4
|
+
MLS_GEM_CACHE['auth_key'] = MLS.auth_key
|
5
5
|
MLS.auth_key = l.account.auth_key
|
6
6
|
}
|
7
7
|
after(:create) { |l|
|
8
|
-
MLS.auth_key =
|
8
|
+
MLS.auth_key = MLS_GEM_CACHE['auth_key']
|
9
9
|
}
|
10
10
|
|
11
11
|
association :account
|
12
12
|
association :address, :strategy => :build
|
13
13
|
|
14
|
-
|
14
|
+
agents { [FactoryGirl.attributes_for(:agent)] }
|
15
15
|
|
16
16
|
use 'Office'
|
17
17
|
size { Kernel.rand(3000..900000) }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class MLS::Brokerage < MLS::Resource
|
2
|
+
|
3
|
+
property :id, Fixnum, :serialize => :if_present
|
4
|
+
property :name, String, :serialize => :if_present
|
5
|
+
property :admin_id, Fixnum, :serialize => :if_present
|
6
|
+
property :slug, String, :serialize => false
|
7
|
+
property :palette, Hash, :serialize => :if_present
|
8
|
+
property :avatar_digest, String, :serialize => false
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def find(id)
|
13
|
+
response = MLS.get("/brokerages/#{id}")
|
14
|
+
MLS::Brokerage::Parser.parse(response.body)
|
15
|
+
end
|
16
|
+
|
17
|
+
def all(options={})
|
18
|
+
response = MLS.get('/brokerages', options)
|
19
|
+
MLS::Brokerage::Parser.parse_collection(response.body)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class MLS::Brokerage::Parser < MLS::Parser
|
27
|
+
end
|
data/lib/mls/models/listing.rb
CHANGED
@@ -343,11 +343,6 @@ class MLS::Listing < MLS::Resource
|
|
343
343
|
{:status => model.import, :model => model}
|
344
344
|
end
|
345
345
|
|
346
|
-
def calculate(filters = {}, operation = nil, column = nil, group = nil)
|
347
|
-
response = MLS.get("/listings/calculate", :filters => filters, :operation => operation, :column => column, :group => group)
|
348
|
-
MLS::Parser.extract_attributes(response.body)[:listings]
|
349
|
-
end
|
350
|
-
|
351
346
|
def amenities
|
352
347
|
@amenities ||= Yajl::Parser.new.parse(MLS.get('/listings/amenities').body).map(&:to_sym)
|
353
348
|
end
|
data/lib/mls/parser.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
class MLS::Parser
|
2
|
-
|
2
|
+
|
3
3
|
attr_reader :object
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(object=nil, persisted=true)
|
6
6
|
@object = object || self.class.object_class.new({}, persisted)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def parse(data)
|
10
10
|
attributes = extract_attributes(data)[self.class.root_element]
|
11
11
|
update_attributes(attributes)
|
12
12
|
object
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def build(attributes)
|
16
16
|
update_attributes(attributes)
|
17
17
|
object
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def update_attributes(attributes)
|
21
21
|
attributes.each {|k,v| self.send("#{k}=".to_sym, v) } if attributes
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def self.parse(data)
|
25
25
|
self.new.parse(data)
|
26
26
|
end
|
@@ -34,27 +34,27 @@ class MLS::Parser
|
|
34
34
|
end
|
35
35
|
collection
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def self.parse_collection(data, options={})
|
39
39
|
build_collection(extract_attributes(data), options)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def self.build(attributes)
|
43
43
|
self.new.build(attributes)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def self.update(object, data)
|
47
|
-
self.new(object).parse(data)
|
47
|
+
self.new(object).parse(data)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def method_missing(method, *args, &block)
|
51
51
|
object.__send__(method, *args, &block) if object.methods.include?(method)
|
52
|
-
end
|
53
|
-
|
52
|
+
end
|
53
|
+
|
54
54
|
def extract_attributes(data)
|
55
55
|
Yajl::Parser.new(:symbolize_keys => true).parse(data)
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def self.extract_attributes(data)
|
59
59
|
Yajl::Parser.new(:symbolize_keys => true).parse(data)
|
60
60
|
end
|
@@ -62,13 +62,13 @@ class MLS::Parser
|
|
62
62
|
def self.object_class
|
63
63
|
@object_class ||= ActiveSupport::Inflector.constantize(self.to_s.sub('::Parser',''))
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def self.root_element
|
67
67
|
object_class.root_element
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def self.collection_root_element
|
71
71
|
object_class.collection_root_element
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
end
|
data/mls.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
@@ -8,14 +8,14 @@ require 'mls'
|
|
8
8
|
require 'turn'
|
9
9
|
require 'faker'
|
10
10
|
require 'test/unit'
|
11
|
-
require 'factory_girl'
|
12
11
|
require 'fakeweb'
|
13
12
|
|
14
|
-
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'../'))
|
14
|
+
require 'lib/mls/factories_helper'
|
15
|
+
|
15
16
|
MLS_HOST = ENV['MLS_URL'] || 'http://localhost:4000/api'
|
16
|
-
FactoryGirl.find_definitions
|
17
17
|
|
18
|
-
MLS.url = ENV["MLS_TEST_URL"] || 'http://LBJXFC%2BhDiRRCYj6kXtXREfgNXRCJa8ALvPn%2FIeyjSe2QsQyHZ%2F%2BWwN2VZM2cw%3D%3D@localhost:
|
18
|
+
MLS.url = ENV["MLS_TEST_URL"] || 'http://LBJXFC%2BhDiRRCYj6kXtXREfgNXRCJa8ALvPn%2FIeyjSe2QsQyHZ%2F%2BWwN2VZM2cw%3D%3D@localhost:5000'#
|
19
19
|
# MLS.auth_key = MLS::Account.authenticate('jonbracy@gmail.com', 'test').auth_key
|
20
20
|
|
21
21
|
# File 'lib/active_support/testing/declarative.rb', somewhere in rails....
|
@@ -43,4 +43,4 @@ def mock_response(method=:get, code='200', body='')
|
|
43
43
|
when :post
|
44
44
|
Net::HTTP.post_form(uri)
|
45
45
|
end
|
46
|
-
end
|
46
|
+
end
|
@@ -5,20 +5,11 @@ class TestAddress < ::Test::Unit::TestCase
|
|
5
5
|
def test_properties
|
6
6
|
address = MLS::Address.new
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert address.respond_to?(:formatted_address)
|
14
|
-
assert address.respond_to?(:street_number)
|
15
|
-
assert address.respond_to?(:street)
|
16
|
-
assert address.respond_to?(:neighborhood)
|
17
|
-
assert address.respond_to?(:city)
|
18
|
-
assert address.respond_to?(:county)
|
19
|
-
assert address.respond_to?(:state)
|
20
|
-
assert address.respond_to?(:country)
|
21
|
-
assert address.respond_to?(:postal_code)
|
8
|
+
properties = [:id, :name, :slug, :latitude, :longitude, :formated_address, :streetnumber, :street, :neighbrhood, :city, :county, :state, :countr, :postalcode]
|
9
|
+
|
10
|
+
properties.each do |property|
|
11
|
+
assert address.respond_to?(property), "address should respond to #{property}"
|
12
|
+
end
|
22
13
|
end
|
23
14
|
|
24
15
|
def test_class_methods
|
@@ -1,134 +1,106 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class ListingTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def test_properties
|
6
6
|
listing = MLS::Listing.new
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
assert listing.respond_to?(:name)
|
14
|
-
assert listing.respond_to?(:type)
|
15
|
-
assert listing.respond_to?(:space_type)
|
16
|
-
assert listing.respond_to?(:unit)
|
17
|
-
assert listing.respond_to?(:floor)
|
18
|
-
assert listing.respond_to?(:description)
|
19
|
-
assert listing.respond_to?(:size)
|
20
|
-
assert listing.respond_to?(:maximum_contiguous_size)
|
21
|
-
assert listing.respond_to?(:minimum_divisible_size)
|
22
|
-
assert listing.respond_to?(:lease_terms)
|
23
|
-
assert listing.respond_to?(:rate)
|
24
|
-
assert listing.respond_to?(:rate_units)
|
25
|
-
assert listing.respond_to?(:sublease_expiration)
|
26
|
-
assert listing.respond_to?(:available_on)
|
27
|
-
assert listing.respond_to?(:term)
|
28
|
-
assert listing.respond_to?(:offices)
|
29
|
-
assert listing.respond_to?(:conference_rooms)
|
30
|
-
assert listing.respond_to?(:bathrooms)
|
31
|
-
assert listing.respond_to?(:kitchen)
|
32
|
-
assert listing.respond_to?(:showers)
|
33
|
-
assert listing.respond_to?(:bikes_allowed)
|
34
|
-
assert listing.respond_to?(:reception_area)
|
35
|
-
assert listing.respond_to?(:patio)
|
36
|
-
assert listing.respond_to?(:dog_friendly)
|
37
|
-
assert listing.respond_to?(:ready_to_move_in)
|
38
|
-
assert listing.respond_to?(:furniture_available)
|
39
|
-
assert listing.respond_to?(:created_at)
|
40
|
-
assert listing.respond_to?(:updated_at)
|
7
|
+
|
8
|
+
properties = [:id, :address_id, :use, :account_id, :name, :type, :space_type, :unit, :floor, :description, :size, :maximum_contiguous_size, :minimum_divisible_size, :lease_terms, :rate, :rate_units, :sublease_expiration, :available_on, :term, :offices, :conference_rooms, :bathrooms, :kitchen, :showers, :ready_to_move_in, :furniture_available, :created_at, :updated_at]
|
9
|
+
|
10
|
+
properties.each do |property|
|
11
|
+
assert listing.respond_to?(property), "listing should respond to #{property}"
|
12
|
+
end
|
41
13
|
end
|
42
|
-
|
14
|
+
|
43
15
|
def test_attr_accessors
|
44
16
|
listing = MLS::Listing.new
|
45
|
-
|
17
|
+
|
46
18
|
assert listing.respond_to?(:address)
|
47
19
|
assert listing.respond_to?(:agents)
|
48
20
|
end
|
49
|
-
|
21
|
+
|
50
22
|
def test_instance_methods
|
51
23
|
listing = MLS::Listing.new
|
52
|
-
|
24
|
+
|
53
25
|
assert listing.respond_to?(:photos)
|
54
26
|
end
|
55
|
-
|
27
|
+
|
56
28
|
def test_class_methods
|
57
29
|
assert MLS::Listing.respond_to?(:find)
|
58
30
|
end
|
59
|
-
|
31
|
+
|
60
32
|
test '#request_tour for email without an account' do
|
61
33
|
@listing = FactoryGirl.create(:listing)
|
62
34
|
@name = Faker::Name.name
|
63
35
|
@email = Faker::Internet.email
|
64
36
|
tr = @listing.request_tour(@name, @email)
|
65
|
-
|
66
|
-
|
37
|
+
|
38
|
+
|
67
39
|
assert_equal({}, tr.errors)
|
68
40
|
assert_equal({}, tr.account.errors)
|
69
41
|
# TODO assert_equal({}, tr.listing.errors)
|
70
42
|
assert tr.id
|
71
43
|
end
|
72
|
-
|
44
|
+
|
73
45
|
test '#request_tour for email on a ghost account' do
|
74
46
|
@account = FactoryGirl.create(:ghost_account)
|
75
47
|
@listing = FactoryGirl.create(:listing)
|
76
|
-
|
48
|
+
|
77
49
|
tr = @listing.request_tour(@account.name, @account.email)
|
78
50
|
assert_equal({}, tr.errors)
|
79
51
|
assert_equal({}, tr.account.errors)
|
80
52
|
# TODO assert_equal({}, tr.listing.errors)
|
81
53
|
assert tr.id
|
82
54
|
end
|
83
|
-
|
55
|
+
|
84
56
|
test '#request_tour for email on an account' do
|
85
57
|
@account = FactoryGirl.create(:account)
|
86
58
|
@listing = FactoryGirl.create(:listing)
|
87
|
-
|
59
|
+
|
88
60
|
tr = @listing.request_tour(@account.name, @account.email)
|
89
61
|
assert_equal({}, tr.errors)
|
90
62
|
assert_equal({}, tr.account.errors)
|
91
63
|
# TODO assert_equal({}, tr.listing.errors)
|
92
64
|
assert tr.id
|
93
65
|
end
|
94
|
-
|
66
|
+
|
95
67
|
test '#request_tour for an non-existant listing' do
|
96
68
|
@listing = FactoryGirl.build(:listing, :id => 94332)
|
97
|
-
|
69
|
+
|
98
70
|
assert_raises(MLS::Exception::NotFound) do
|
99
71
|
@listing.request_tour(Faker::Name.name, Faker::Internet.email)
|
100
72
|
end
|
101
73
|
end
|
102
|
-
|
74
|
+
|
103
75
|
test '#request_tour without and account name' do
|
104
76
|
@listing = FactoryGirl.create(:listing)
|
105
|
-
|
77
|
+
|
106
78
|
tr = @listing.request_tour('', Faker::Internet.email)
|
107
79
|
assert !tr.id
|
108
80
|
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
|
109
|
-
|
81
|
+
|
110
82
|
tr = @listing.request_tour(nil, Faker::Internet.email)
|
111
83
|
assert !tr.id
|
112
84
|
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
|
113
85
|
end
|
114
|
-
|
86
|
+
|
115
87
|
test '#request_tour without an account email' do
|
116
88
|
@listing = FactoryGirl.create(:listing)
|
117
|
-
|
89
|
+
|
118
90
|
tr = @listing.request_tour(Faker::Name.name, '')
|
119
91
|
assert !tr.id
|
120
92
|
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
|
121
|
-
|
93
|
+
|
122
94
|
tr = @listing.request_tour(Faker::Name.name, nil)
|
123
95
|
assert !tr.id
|
124
96
|
# assert !tr.persisted? #TODO move to persisted being based of id?
|
125
97
|
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
|
126
98
|
end
|
127
|
-
|
99
|
+
|
128
100
|
test '#request_tour with an account email' do
|
129
101
|
@account = FactoryGirl.create(:account)
|
130
102
|
@listing = FactoryGirl.create(:listing)
|
131
|
-
|
103
|
+
|
132
104
|
tr = @listing.request_tour('', @account.email) # TODO should this try to set the name of the account?
|
133
105
|
assert_equal({}, tr.errors)
|
134
106
|
assert_equal({}, tr.account.errors)
|
@@ -136,38 +108,38 @@ class TestListing < ::Test::Unit::TestCase
|
|
136
108
|
assert tr.id
|
137
109
|
assert tr.persisted?
|
138
110
|
end
|
139
|
-
|
111
|
+
|
140
112
|
test '#request_tour multiple times for a listing' do
|
141
113
|
@account = FactoryGirl.create(:account)
|
142
114
|
@listing = FactoryGirl.create(:listing)
|
143
|
-
|
115
|
+
|
144
116
|
tr1 = @listing.request_tour(@account.name, @account.email)
|
145
117
|
assert_equal({}, tr1.errors) # TODO should errors be here for account?
|
146
118
|
assert_equal({}, tr1.account.errors)
|
147
119
|
# TODO assert_equal({}, tr.listing.errors)
|
148
120
|
assert tr1.persisted?
|
149
|
-
|
121
|
+
|
150
122
|
tr2 = @listing.request_tour(@account.name, @account.email)
|
151
123
|
assert_equal({}, tr2.errors)
|
152
124
|
assert_equal({}, tr2.account.errors)
|
153
125
|
# TODO assert_equal({}, tr.listing.errors)
|
154
126
|
assert tr2.persisted?
|
155
|
-
|
127
|
+
|
156
128
|
assert_not_equal tr1.id, tr2.id
|
157
129
|
end
|
158
|
-
|
130
|
+
|
159
131
|
test '#request_tour with optional info' do
|
160
132
|
@listing = FactoryGirl.create(:listing)
|
161
|
-
|
133
|
+
|
162
134
|
info = {:company => '42Floors', :population => 10, :funding => 'string thing', :move_in_date => '2012-09-12'}
|
163
135
|
tr = @listing.request_tour(Faker::Name.name, Faker::Internet.email, info)
|
164
|
-
|
136
|
+
|
165
137
|
assert tr.id
|
166
138
|
assert_equal '42Floors', info[:company]
|
167
139
|
assert_equal 10, info[:population]
|
168
140
|
assert_equal 'string thing', info[:funding]
|
169
141
|
assert_equal '2012-09-12', info[:move_in_date]
|
170
|
-
|
142
|
+
|
171
143
|
tr = @listing.request_tour('', nil, info)
|
172
144
|
assert !tr.id
|
173
145
|
assert_equal '42Floors', info[:company]
|
@@ -175,10 +147,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
175
147
|
assert_equal 'string thing', info[:funding]
|
176
148
|
assert_equal '2012-09-12', info[:move_in_date]
|
177
149
|
end
|
178
|
-
|
150
|
+
|
179
151
|
def test_rate_per_sqft_per_month
|
180
152
|
listing = MLS::Listing.new(:rate => 10.5, :rate_units => '/sqft/mo', :size => 5)
|
181
|
-
|
153
|
+
|
182
154
|
assert_equal 10.5, listing.rate
|
183
155
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
184
156
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -189,10 +161,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
189
161
|
listing.rate('/random')
|
190
162
|
end
|
191
163
|
end
|
192
|
-
|
164
|
+
|
193
165
|
def test_rate_per_sqft_per_year
|
194
166
|
listing = MLS::Listing.new(:rate => 126, :rate_units => '/sqft/yr', :size => 5)
|
195
|
-
|
167
|
+
|
196
168
|
assert_equal 126, listing.rate
|
197
169
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
198
170
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -203,10 +175,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
203
175
|
listing.rate('/random')
|
204
176
|
end
|
205
177
|
end
|
206
|
-
|
178
|
+
|
207
179
|
def test_rate_per_month
|
208
180
|
listing = MLS::Listing.new(:rate => 52.5, :rate_units => '/mo', :size => 5)
|
209
|
-
|
181
|
+
|
210
182
|
assert_equal 52.5, listing.rate
|
211
183
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
212
184
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -217,10 +189,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
217
189
|
listing.rate('/random')
|
218
190
|
end
|
219
191
|
end
|
220
|
-
|
192
|
+
|
221
193
|
def test_rate_per_year
|
222
194
|
listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
|
223
|
-
|
195
|
+
|
224
196
|
assert_equal 630, listing.rate
|
225
197
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
226
198
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -231,10 +203,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
231
203
|
listing.rate('/random')
|
232
204
|
end
|
233
205
|
end
|
234
|
-
|
206
|
+
|
235
207
|
def test_rate_per_desk_per_month
|
236
208
|
listing = MLS::Listing.new(:rate => 2100, :rate_units => '/desk/mo', :size => 5)
|
237
|
-
|
209
|
+
|
238
210
|
assert_equal 2100, listing.rate
|
239
211
|
assert_equal 10.5, listing.rate('/sqft/mo')
|
240
212
|
assert_equal 126, listing.rate('/sqft/yr')
|
@@ -245,7 +217,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
245
217
|
listing.rate('/random')
|
246
218
|
end
|
247
219
|
end
|
248
|
-
|
220
|
+
|
249
221
|
def test_rate_percision
|
250
222
|
listing = MLS::Listing.new(:rate => 47, :rate_units => '/sqft/yr', :size => 5)
|
251
223
|
|
@@ -255,10 +227,10 @@ class TestListing < ::Test::Unit::TestCase
|
|
255
227
|
assert_equal 235, listing.rate('/yr')
|
256
228
|
assert_equal 783.33, listing.rate('/desk/mo')
|
257
229
|
end
|
258
|
-
|
230
|
+
|
259
231
|
def test_null_rate
|
260
232
|
listing = MLS::Listing.new(:rate => nil, :rate_units => '/yr', :size => 5)
|
261
|
-
|
233
|
+
|
262
234
|
assert_equal nil, listing.rate
|
263
235
|
assert_equal nil, listing.rate('/sqft/mo')
|
264
236
|
assert_equal nil, listing.rate('/sqft/yr')
|
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.
|
4
|
+
version: 0.11.0
|
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-
|
12
|
+
date: 2013-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -192,9 +192,14 @@ files:
|
|
192
192
|
- Rakefile
|
193
193
|
- lib/mls.rb
|
194
194
|
- lib/mls/errors.rb
|
195
|
+
- lib/mls/factories/account.rb
|
196
|
+
- lib/mls/factories/address.rb
|
197
|
+
- lib/mls/factories/listing.rb
|
198
|
+
- lib/mls/factories_helper.rb
|
195
199
|
- lib/mls/model.rb
|
196
200
|
- lib/mls/models/account.rb
|
197
201
|
- lib/mls/models/address.rb
|
202
|
+
- lib/mls/models/brokerage.rb
|
198
203
|
- lib/mls/models/floorplan.rb
|
199
204
|
- lib/mls/models/flyer.rb
|
200
205
|
- lib/mls/models/listing.rb
|
@@ -235,10 +240,6 @@ files:
|
|
235
240
|
- lib/rdoc/generator/template/42floors/resources/panel/index.html
|
236
241
|
- lib/rdoc/generator/template/42floors/se_index.rhtml
|
237
242
|
- mls.gemspec
|
238
|
-
- test/factories/account.rb
|
239
|
-
- test/factories/address.rb
|
240
|
-
- test/factories/contact.rb
|
241
|
-
- test/factories/listing.rb
|
242
243
|
- test/fixtures/flyer.pdf
|
243
244
|
- test/test_helper.rb
|
244
245
|
- test/units/models/test_account.rb
|
@@ -278,10 +279,6 @@ signing_key:
|
|
278
279
|
specification_version: 4
|
279
280
|
summary: 42Floors MLS Client
|
280
281
|
test_files:
|
281
|
-
- test/factories/account.rb
|
282
|
-
- test/factories/address.rb
|
283
|
-
- test/factories/contact.rb
|
284
|
-
- test/factories/listing.rb
|
285
282
|
- test/fixtures/flyer.pdf
|
286
283
|
- test/test_helper.rb
|
287
284
|
- test/units/models/test_account.rb
|
data/test/factories/account.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
factory :account, :class => MLS::Account do
|
3
|
-
name { Faker::Name.name }
|
4
|
-
email { Faker::Internet.email }
|
5
|
-
password { 'test' }
|
6
|
-
password_confirmation 'test'
|
7
|
-
end
|
8
|
-
|
9
|
-
factory :broker, :class => MLS::Account, :parent => :account do
|
10
|
-
type 'Account'
|
11
|
-
end
|
12
|
-
|
13
|
-
factory :ghost_account, :class => MLS::Account do
|
14
|
-
name { Faker::Name.name }
|
15
|
-
email { Faker::Internet.email }
|
16
|
-
password_required { false }
|
17
|
-
end
|
18
|
-
end
|
data/test/factories/contact.rb
DELETED