canmoia 0.1.0 → 0.2.0

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: 8064226b72d701941053f1159b2b0b910029969f
4
- data.tar.gz: 9e9a71b8298ae976ba3184af94a451d0a564d86f
3
+ metadata.gz: 3e4c453d322fe080628f605775108e772b2685c0
4
+ data.tar.gz: aaa2dd4499796ec14225df35b78ae1db526c46bb
5
5
  SHA512:
6
- metadata.gz: 3f4160fe7c5594438f3ba660208a04ee4845ffef535355ed7e3c4eea8d4f2a9c0fd780588afe77d36f212e78f754be0504a64d7906811bd7d1922f4cc7fb9603
7
- data.tar.gz: a6bf9701090a02d0c5e2c5c333646766a79dd104361a0604bf30ec56143bdec9513a3bab8a48093dc46be603a030ac38e676dd404aaa4846d3ceb6b95afdf880
6
+ metadata.gz: 1c3673e2a8e7030067105407e9cea4b1265d98f0d58cba99bae65d78d22d2c23bfa712304c879d451c616dc08a71b922e0590a2741b3ad5b5d0c7f1716b6a4a8
7
+ data.tar.gz: a6551ff43d60fa636f6fa923e3030095f093acd39e144a2c31db1e1cd122e2a4756152758bcdab12822451cea8b37c8b4fdf0bf71d0c2b139c57e9019f9ee2b9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- canmoia (0.1.0)
4
+ canmoia (0.2.0)
5
5
  mongoid
6
6
  rails (>= 3)
7
7
  workflow_on_mongoid
@@ -56,7 +56,7 @@ module Canmoia
56
56
 
57
57
  module CalculationMethods
58
58
  def calculate_total
59
- self.total = items.sum &:value
59
+ self.total = items.sum &:price
60
60
  end
61
61
  end
62
62
 
@@ -1,3 +1,3 @@
1
1
  module Canmoia
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,45 +1,5 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
3
  describe Canmoia::Order do
4
-
5
- it 'should include Camnoia::Order module ' do
6
- order = Fabricate :order
7
- order.class.included_modules.should include Canmoia::Order
8
- end
9
-
10
- it 'should define core domain states for a Order' do
11
- order = Fabricate :order # Order class must include Canmoia::Order
12
- order.should respond_to :opened?
13
- order.should respond_to :reviewing?
14
- order.should respond_to :accepted?
15
- order.should respond_to :rejected?
16
- order.should respond_to :canceled?
17
- order.should respond_to :completed?
18
- end
19
-
20
- it 'should compute total value in opened state ' do
21
- order = Fabricate :order
22
- first_item = order.items.first
23
-
24
- order.items.sum(&:value).should == order.total
25
-
26
- first_item.value += 1
27
-
28
- order.items.sum(&:value).should == order.total + 1
29
- end
30
-
31
- it 'should not compute total value after opened state' do
32
- order = Fabricate :order
33
- first_item = order.items.first
34
-
35
- order.close!
36
-
37
- closed_total = order.total
38
-
39
- first_item.value += 1
40
-
41
- order.total.should == closed_total
42
- end
43
-
44
- # it 'should ignore workflow_column call if workflow_column already called'
4
+ it_should_behave_like :canmoia_order
45
5
  end
@@ -1,5 +1,10 @@
1
1
  class Item
2
2
  include Mongoid::Document
3
- field :value, type: Float
3
+
4
+ attr_accessor :product_price
4
5
  field :quantity, type: Integer
6
+
7
+ def price
8
+ self.product_price * self.quantity
9
+ end
5
10
  end