unidom-geo 1.5.6 → 1.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b07c69b43b6c4003e4188e19cc8761aaa3fc37c4
4
- data.tar.gz: a99da5d86e8d086ea2ff4236ffa106547e2d2753
3
+ metadata.gz: '04091f3b47716f81dabccd033d78edfb71c9e2ea'
4
+ data.tar.gz: 30d6f758f78fbcddc14fb9bd0e656d6e58fcd27f
5
5
  SHA512:
6
- metadata.gz: 91769c5cfae2ed16f1166c1e3eb67da2d037938bc2e82234a9d004637e0cc6e4c2f06e9d3f40fc419eb24e2ebd4c85aa12bf2da219eccea59c12c2b844c049d3
7
- data.tar.gz: 99586e668b69e43456adba80618b34fbb8b8777e69ef051f2dd0f66c81eaf59992f88e7109609095002be52def426be693115417a55e8a373d07ca9f01d57044
6
+ metadata.gz: 61f026168f11f4f82cdb65c5e1c2a3c9312773ccab006ed2dd26499bc5c798fedd439dcb027f4725b47bfa88a6ceb406bf33870d7e79a938ee93586af139801f
7
+ data.tar.gz: 63ce8db98d6fdfcec255eeeacfb8e533f0a511f95cb349eb5b545eec6cf248d42d1a8e27c8789a1231467cf85dc3c5d23a4af73a3762dfb5d973a785d57d373c
data/README.md CHANGED
@@ -147,7 +147,20 @@ describe Unidom::Party::Shop, type: :model do
147
147
  name: 'Some Shop'
148
148
  }
149
149
 
150
- it_behaves_like 'Unidom::Geo::Concerns::AsLocated', model_attributes
150
+ location_attributes = {
151
+ postal_address: '#1 Some Street',
152
+ postal_code: '610000',
153
+ region_id: SecureRandom.uuid,
154
+ region_type: 'Unidom::Geo::Region::Mock'
155
+ }
156
+ location = Unidom::Geo::Location.create! location_attributes
157
+
158
+ locator_attributes = {
159
+ name: 'Tim'
160
+ }
161
+ locator = Unidom::Party::Person.create! locator_attributes
162
+
163
+ it_behaves_like 'Unidom::Geo::Concerns::AsLocated', model_attributes, location, locator
151
164
 
152
165
  end
153
166
 
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Geo::Concerns::AsLocated
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -15,7 +16,13 @@ module Unidom::Geo::Concerns::AsLocated
15
16
  # location = Unidom::Geo::Location.first
16
17
  # shop.is_located! to: location, by: current_person
17
18
  def is_located!(to: nil, by: nil, at: Time.now)
19
+
20
+ assert_present! :to, to
21
+ assert_present! :by, by
22
+ assert_present! :at, at
23
+
18
24
  locatings.location_is(to).valid_at(now: at).alive.first_or_create! locator: by, opened_at: at
25
+
19
26
  end
20
27
 
21
28
  ##
@@ -23,7 +30,12 @@ module Unidom::Geo::Concerns::AsLocated
23
30
  # location = Unidom::Geo::Location.first
24
31
  # 如: shop.is_located? to: location, at: Time.now
25
32
  def is_located?(to: nil, at: Time.now)
33
+
34
+ assert_present! :to, to
35
+ assert_present! :at, at
36
+
26
37
  locatings.location_is(to).valid_at(now: at).alive.exists?
38
+
27
39
  end
28
40
 
29
41
  end
@@ -1,17 +1,26 @@
1
- shared_examples 'Unidom::Geo::Concerns::AsLocated' do |model_attributes|
1
+ shared_examples 'Unidom::Geo::Concerns::AsLocated' do |model_attributes, location, locator|
2
2
 
3
- locating_1_attribtues = {
4
- location_id: SecureRandom.uuid,
5
- locator_id: SecureRandom.uuid,
6
- locator_type: 'Unidom::Geo::Locator::Mock'
7
- }
3
+ context do
8
4
 
9
- locating_2_attribtues = {
10
- location_id: SecureRandom.uuid,
11
- locator_id: SecureRandom.uuid,
12
- locator_type: 'Unidom::Geo::Locator::Mock'
13
- }
5
+ locating_1_attribtues = {
6
+ location_id: SecureRandom.uuid,
7
+ locator_id: SecureRandom.uuid,
8
+ locator_type: 'Unidom::Geo::Locator::Mock'
9
+ }
14
10
 
15
- it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
11
+ locating_2_attribtues = {
12
+ location_id: SecureRandom.uuid,
13
+ locator_id: SecureRandom.uuid,
14
+ locator_type: 'Unidom::Geo::Locator::Mock'
15
+ }
16
+
17
+ it_behaves_like 'has_many', model_attributes, :locatings, Unidom::Geo::Locating, [ locating_1_attribtues, locating_2_attribtues ]
18
+
19
+ located = described_class.create! model_attributes
20
+
21
+ it_behaves_like 'assert_present!', located, :is_located!, [ { to: location, by: locator, at: Time.now } ], [ :to, :by, :at ]
22
+ it_behaves_like 'assert_present!', located, :is_located?, [ { to: location, at: Time.now } ], [ :to, :at ]
23
+
24
+ end
16
25
 
17
26
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Geo
3
- VERSION = '1.5.6'.freeze
3
+ VERSION = '1.5.7'.freeze
4
4
  end
5
5
  end
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.6
4
+ version: 1.5.7
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-03-23 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common