unidom-geo 1.5.7 → 1.5.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a750ec1b28e5cac87c65d2cdfe1ded36c1c0633
|
4
|
+
data.tar.gz: 351f9f1d011f848067b3e30a9357b07393c8992a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78cc09e09aacd1cca9b4fb72cfa62dbfe726f74c6d3e7ca79db4a6b7c5800bafe626d25694d5b8ba672c60daace239b316dc7fe1e58765892e027123e732266
|
7
|
+
data.tar.gz: 8f496593c2749f6bb27b9b79caa1286163eb44cd177761667e1aa44377f588bb9012f93c6a4c69a729dd39f3f2d4e4172721066013180231e880ae8fc2dfd63b
|
data/README.md
CHANGED
@@ -121,6 +121,10 @@ require 'unidom/geo/validators_rspec'
|
|
121
121
|
# lib/unidom.rb
|
122
122
|
def initialize_unidom
|
123
123
|
|
124
|
+
Unidom::Party::Person.class_eval do
|
125
|
+
include Unidom::Geo::Concerns::AsLocator
|
126
|
+
end
|
127
|
+
|
124
128
|
Unidom::Party::Shop.class_eval do
|
125
129
|
include Unidom::Geo::Concerns::AsLocated
|
126
130
|
end
|
@@ -138,6 +142,26 @@ initialize_unidom
|
|
138
142
|
# spec/support/unidom_rspec_shared_examples.rb
|
139
143
|
require 'unidom/geo/rspec_shared_examples'
|
140
144
|
|
145
|
+
# spec/models/unidom/party/person_spec.rb
|
146
|
+
describe Unidom::Party::Person, type: :model do
|
147
|
+
|
148
|
+
context do
|
149
|
+
|
150
|
+
model_attributes = {
|
151
|
+
name: 'Tim'
|
152
|
+
}
|
153
|
+
|
154
|
+
located_attributes = {
|
155
|
+
name: 'Walmart'
|
156
|
+
}
|
157
|
+
located = Unidom::Party::Shop.create! located_attributes
|
158
|
+
|
159
|
+
it_behaves_like 'Unidom::Geo::Concerns::AsLocator', model_attributes, located
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
141
165
|
# spec/models/unidom/party/shop_spec.rb
|
142
166
|
describe Unidom::Party::Shop, type: :model do
|
143
167
|
|
@@ -11,7 +11,13 @@ module Unidom::Geo::Concerns::AsLocator
|
|
11
11
|
has_many :locations, through: :locatings, source: :location
|
12
12
|
|
13
13
|
def locate!(it, to: nil, at: Time.now)
|
14
|
+
|
15
|
+
assert_present! :it, it
|
16
|
+
assert_present! :to, to
|
17
|
+
assert_present! :at, at
|
18
|
+
|
14
19
|
locatings.location_is(to).located_is(it).valid_at(now: at).alive.first_or_create! opened_at: at
|
20
|
+
|
15
21
|
end
|
16
22
|
|
17
23
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
shared_examples 'Unidom::Geo::Concerns::AsLocator' do |model_attributes, located|
|
2
|
+
|
3
|
+
context do
|
4
|
+
|
5
|
+
locating_1_attribtues = {
|
6
|
+
location_id: SecureRandom.uuid,
|
7
|
+
located_id: SecureRandom.uuid,
|
8
|
+
located_type: 'Unidom::Geo::Located::Mock'
|
9
|
+
}
|
10
|
+
|
11
|
+
locating_2_attribtues = {
|
12
|
+
location_id: SecureRandom.uuid,
|
13
|
+
located_id: SecureRandom.uuid,
|
14
|
+
located_type: 'Unidom::Geo::Located::Mock'
|
15
|
+
}
|
16
|
+
|
17
|
+
it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
|
18
|
+
|
19
|
+
model = described_class.create! model_attributes
|
20
|
+
|
21
|
+
location_attributes = {
|
22
|
+
region_id: SecureRandom.uuid,
|
23
|
+
region_type: 'Unidom::Geo::Region::Mock',
|
24
|
+
longitude: 21.000000,
|
25
|
+
latitude: 31.000000,
|
26
|
+
postal_address: 'Some Address',
|
27
|
+
postal_code: '100000',
|
28
|
+
minimum_longitude: 19.900000,
|
29
|
+
minimum_latitude: 30.900000,
|
30
|
+
maximum_longitude: 21.100000,
|
31
|
+
maximum_latitude: 31.100000,
|
32
|
+
}
|
33
|
+
location = Unidom::Geo::Location.first_or_create! location_attributes
|
34
|
+
|
35
|
+
it_behaves_like 'assert_present!', model, :locate!, [ located, { to: location, at: Time.now } ], [ { 0 => :it }, :to, :at ]
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/unidom/geo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- db/migrate/20010401000000_create_unidom_locations.rb
|
54
54
|
- db/migrate/20010402000000_create_unidom_locatings.rb
|
55
55
|
- lib/rspec/models/unidom/geo/concerns/as_located_shared_examples.rb
|
56
|
+
- lib/rspec/models/unidom/geo/concerns/as_locator_shared_examples.rb
|
56
57
|
- lib/rspec/models/unidom/geo/concerns/as_region_shared_examples.rb
|
57
58
|
- lib/rspec/models/unidom/geo/locating_spec.rb
|
58
59
|
- lib/rspec/models/unidom/geo/location_spec.rb
|