unidom-price 1.7.6 → 1.7.7

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: 5ecb6d6375efd70fbe8cd2303937b2a3c52f2a07
4
- data.tar.gz: 592b4395a34337239111735e96ec33eb69223067
3
+ metadata.gz: aeab6cd86ed792d5475a58e4469f828fd30ff5fd
4
+ data.tar.gz: bd240520ac7e134f98a260be212630c42c330c05
5
5
  SHA512:
6
- metadata.gz: e2e6f359f6eec0cc267459e2f61f85eba04dd9b770179d535cfa3fee06ff04252f9239c43bf821bf7923150e946d4bf8fb58219b5852796d86e1fcafb53fec98
7
- data.tar.gz: 0b2ad63cacb6b151c68b592d96690df561a65fc2201c59cb500236ca67f2a31ba3351c0452e03fcf31fc69f6d70411a12d0ef0db90e0e10a8bbb2e0d4448e39c
6
+ metadata.gz: 5a7bbe450c789a001650bb623356f02fcf6be99c4fa9610f35ad958c9f6b86b7dafff9dc80bad93b043d291c6443e67805aa74d9a53cb896fea5f3dd067e6ecf
7
+ data.tar.gz: de953d928ea9f696389b136ef0845f105a25262886d2d5d6ad3d3a2b337aab55d9a635ff835e85ba1c429aaf0abd0538f0cad2260ae1f154d31cc97b1b0e20d0
data/README.md CHANGED
@@ -183,29 +183,45 @@ initialize_unidom
183
183
  require 'unidom/price/rspec_shared_examples'
184
184
 
185
185
  # spec/models/unidom/party/person_spec.rb
186
- describe Unidom::Party::Person do
186
+ describe Unidom::Party::Person, type: :model do
187
187
 
188
- model_attribtues = {
189
- name: 'Tim'
190
- }
188
+ context do
189
+
190
+ model_attribtues = {
191
+ name: 'Tim'
192
+ }
193
+
194
+ priced_attributes = {
195
+ name: 'Model X',
196
+ abbreviation: 'MX',
197
+ measurement_unit: 'set',
198
+ packing_norm: '1 per 1'
199
+ }
200
+ priced = Unidom::Product::Product.create! priced_attributes
191
201
 
192
- it_behaves_like 'Unidom::Price::Concerns::AsPricer', model_attribtues
202
+ it_behaves_like 'Unidom::Price::Concerns::AsPricer', model_attribtues, priced
203
+
204
+ end
193
205
 
194
206
  end
195
207
 
196
208
  # spec/models/unidom/position/post_spec.rb
197
- describe Unidom::Product::Product do
209
+ describe Unidom::Product::Product, type: :model do
198
210
 
199
- model_attribtues = {
200
- name: 'Model X',
201
- abbreviation: 'MX',
202
- measurement_unit: 'set',
203
- packing_norm: '1 per 1'
204
- }
211
+ context do
212
+
213
+ model_attribtues = {
214
+ name: 'Model X',
215
+ abbreviation: 'MX',
216
+ measurement_unit: 'set',
217
+ packing_norm: '1 per 1'
218
+ }
205
219
 
206
- pricer = Unidom::Party::Person.create! name: 'Tim'
220
+ pricer = Unidom::Party::Person.create! name: 'Tim'
207
221
 
208
- it_behaves_like 'Unidom::Price::Concerns::AsPriced', model_attribtues, pricer
222
+ it_behaves_like 'Unidom::Price::Concerns::AsPriced', model_attribtues, pricer
223
+
224
+ end
209
225
 
210
226
  end
211
227
  ```
@@ -10,13 +10,24 @@ module Unidom::Price::Concerns::AsPricer
10
10
  has_many :pricings, class_name: 'Unidom::Price::Price', as: :pricer
11
11
 
12
12
  def price!(it, amount, at: Time.now)
13
+
14
+ assert_present! :it, it
15
+ assert_present! :amount, amount
16
+ assert_present! :at, at
17
+
13
18
  pricing = pricings.priced_is(it).valid_at(now: at).alive.first
14
19
  pricing.soft_destroy if pricing.present?
15
20
  pricings.create! priced: it, amount: amount, opened_at: at
21
+
16
22
  end
17
23
 
18
24
  def price?(it, at: Time.now)
25
+
26
+ assert_present! :it, it
27
+ assert_present! :at, at
28
+
19
29
  pricings.priced_is(it).valid_at(now: at).alive.exists?
30
+
20
31
  end
21
32
 
22
33
  end
@@ -10,10 +10,6 @@ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes, pricer
10
10
 
11
11
  context '#is_priced!' do
12
12
 
13
- #it 'should reject the amount argument = nil' do expect { @priced.is_priced! nil, by: pricer, at: Time.now }.to raise_error(ArgumentError, 'The amount argument is required.') end
14
- #it 'should reject the by argument = nil' do expect { @priced.is_priced! @amount, by: nil, at: Time.now }.to raise_error(ArgumentError, 'The by argument is required.') end
15
- #it 'should reject the at argument = nil' do expect { @priced.is_priced! @amount, by: pricer, at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
16
-
17
13
  it "should be able to be priced by #{pricer.inspect}" do
18
14
  price = @priced.is_priced! @amount, by: pricer
19
15
  expect(price).to be_present
@@ -32,8 +28,6 @@ shared_examples 'Unidom::Price::Concerns::AsPriced' do |model_attributes, pricer
32
28
 
33
29
  context '#is_priced?' do
34
30
 
35
- #it 'should reject the at argument = nil' do expect { @priced.is_priced? at: nil }.to raise_error(ArgumentError, 'The at argument is required.') end
36
-
37
31
  it "should be able to be priced by #{pricer.inspect}" do
38
32
  expect(@priced.is_priced?).to be_falsey
39
33
  @priced.is_priced! @amount, by: pricer
@@ -1,4 +1,4 @@
1
- shared_examples 'Unidom::Price::Concerns::AsPricer' do |model_attributes|
1
+ shared_examples 'Unidom::Price::Concerns::AsPricer' do |model_attributes, priced|
2
2
 
3
3
  context do
4
4
 
@@ -16,6 +16,11 @@ shared_examples 'Unidom::Price::Concerns::AsPricer' do |model_attributes|
16
16
 
17
17
  it_behaves_like 'has_many', model_attributes, :pricings, Unidom::Price::Price, [ price_1_attribtues, price_2_attribtues ]
18
18
 
19
+ model = described_class.create! model_attributes
20
+ amount = 10.00
21
+ it_behaves_like 'assert_present!', model, :price!, [ priced, amount, { at: Time.now } ], [ { 0 => :it }, { 1 => :amount }, :at ]
22
+ it_behaves_like 'assert_present!', model, :price?, [ priced, { at: Time.now } ], [ { 0 => :it }, :at ]
23
+
19
24
  end
20
25
 
21
26
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Price
3
- VERSION = '1.7.6'.freeze
3
+ VERSION = '1.7.7'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-price
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.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-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common