traka 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 1
1
+ 0
@@ -4,7 +4,7 @@ class IsTrakableTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  Traka::Change.destroy_all
7
- Traka::Change.set_version!(1)
7
+ Traka::Change.set_version!(0)
8
8
  end
9
9
 
10
10
  def test_a_products_traka_uuid_should_be_uuid
@@ -4,64 +4,73 @@ class TrakaChangeTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
6
  Traka::Change.destroy_all
7
- Traka::Change.set_version!(1)
7
+ Traka::Change.set_version!(0)
8
8
  end
9
9
 
10
10
  test "TrakaChange has latest version" do
11
- assert_equal Traka::Change.latest_version, 1
11
+ assert_equal Traka::Change.latest_version, 0
12
12
  end
13
13
 
14
14
  test "TrakaChange can publish new version" do
15
- assert_equal Traka::Change.latest_version, 1
15
+ assert_equal Traka::Change.latest_version, 0
16
16
 
17
17
  Traka::Change.publish_new_version!
18
18
 
19
- assert_equal Traka::Change.latest_version, 2
19
+ assert_equal Traka::Change.latest_version, 1
20
20
  end
21
21
 
22
22
  test "TrakaChange can list staged changes" do
23
23
  p = Product.create(:name => "Product A")
24
24
  c = Cheese.create(:name => "Cheese A")
25
25
 
26
- assert_equal Traka::Change.staged_changes.count, 2
27
- assert_equal Traka::Change.staged_changes.first.klass, "Product"
28
- assert_equal Traka::Change.staged_changes.last.klass, "Cheese"
26
+ Traka::Change.publish_new_version!
27
+
28
+ p2 = Product.create(:name => "Product B")
29
+ c2 = Cheese.create(:name => "Cheese B")
30
+
31
+ assert_equal Traka::Change.changes.count, 2
32
+ assert_equal Traka::Change.changes.first.klass, "Product"
33
+ assert_equal Traka::Change.changes.last.klass, "Cheese"
29
34
  end
30
35
 
31
36
  test "TrakaChange can list changes from a particular version" do
32
37
  p = Product.create(:name => "Product A")
33
38
  c = Cheese.create(:name => "Cheese A")
34
39
 
35
- assert_equal Traka::Change.staged_changes.count, 2
40
+ assert_equal Traka::Change.changes.count, 2
36
41
 
37
42
  Traka::Change.publish_new_version!
38
43
 
39
44
  p2 = Product.create(:name => "Product B")
40
45
 
41
- assert_equal Traka::Change.staged_changes.count, 1
42
- assert_equal Traka::Change.staged_changes.first.klass, "Product"
46
+ Traka::Change.publish_new_version!
47
+
48
+ p3 = Product.create(:name => "Product C")
49
+
50
+ assert_equal Traka::Change.changes.count, 1
51
+ assert_equal Traka::Change.changes.first.klass, "Product"
43
52
 
44
- assert_equal Traka::Change.staged_changes(:version => 1).count, 3
45
- assert_equal Traka::Change.staged_changes(:version => 1).map(&:klass), ["Product", "Cheese", "Product"]
46
- assert_equal Traka::Change.staged_changes(:version => 1).map(&:action_type), ["create", "create", "create"]
53
+ assert_equal Traka::Change.changes(:version => 1).count, 3 ## Product C is not returned because it hasn't been published.
54
+ assert_equal Traka::Change.changes(:version => 1).map(&:klass), ["Product", "Cheese", "Product"]
55
+ assert_equal Traka::Change.changes(:version => 1).map(&:action_type), ["create", "create", "create"]
47
56
  end
48
57
 
49
58
  test "TrakaChange can list changes for a particular version" do
50
59
  p = Product.create(:name => "Product A")
51
60
  c = Cheese.create(:name => "Cheese A")
52
61
 
53
- assert_equal Traka::Change.staged_changes.count, 2
62
+ assert_equal Traka::Change.changes.count, 2
54
63
 
55
64
  Traka::Change.publish_new_version!
56
65
 
57
66
  p2 = Product.create(:name => "Product B")
58
67
 
59
- assert_equal Traka::Change.staged_changes.count, 1
60
- assert_equal Traka::Change.staged_changes.first.klass, "Product"
68
+ assert_equal Traka::Change.changes.count, 1
69
+ assert_equal Traka::Change.changes.first.klass, "Product"
61
70
 
62
- assert_equal Traka::Change.staged_changes(:version => (2..2)).count, 2
63
- assert_equal Traka::Change.staged_changes(:version => (2..2)).map(&:klass), ["Product", "Cheese"]
64
- assert_equal Traka::Change.staged_changes(:version => (2..2)).map(&:action_type), ["create", "create"]
71
+ assert_equal Traka::Change.changes(:version => (1..1)).count, 2
72
+ assert_equal Traka::Change.changes(:version => (1..1)).map(&:klass), ["Product", "Cheese"]
73
+ assert_equal Traka::Change.changes(:version => (1..1)).map(&:action_type), ["create", "create"]
65
74
  end
66
75
 
67
76
  test "TrakaChange can list differing changes" do
@@ -74,9 +83,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
74
83
  p.save
75
84
  c.destroy
76
85
 
77
- assert_equal Traka::Change.staged_changes.count, 2
78
- assert_equal Traka::Change.staged_changes.map(&:klass), ["Product", "Cheese"]
79
- assert_equal Traka::Change.staged_changes.map(&:action_type), ["update", "destroy"]
86
+ assert_equal Traka::Change.changes.count, 2
87
+ assert_equal Traka::Change.changes.map(&:klass), ["Product", "Cheese"]
88
+ assert_equal Traka::Change.changes.map(&:action_type), ["update", "destroy"]
80
89
  end
81
90
 
82
91
  test "TrakaChange can filter out obsolete create->destroy actions" do
@@ -85,9 +94,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
85
94
 
86
95
  p.destroy
87
96
 
88
- assert_equal Traka::Change.staged_changes.count, 1
89
- assert_equal Traka::Change.staged_changes.map(&:klass), ["Cheese"]
90
- assert_equal Traka::Change.staged_changes.map(&:action_type), ["create"]
97
+ assert_equal Traka::Change.changes.count, 1
98
+ assert_equal Traka::Change.changes.map(&:klass), ["Cheese"]
99
+ assert_equal Traka::Change.changes.map(&:action_type), ["create"]
91
100
  end
92
101
 
93
102
  test "TrakaChange can filter out obsolete update->destroy actions" do
@@ -103,9 +112,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
103
112
 
104
113
  p.destroy
105
114
 
106
- assert_equal Traka::Change.staged_changes.count, 1
107
- assert_equal Traka::Change.staged_changes.map(&:klass), ["Cheese"]
108
- assert_equal Traka::Change.staged_changes.map(&:action_type), ["update"]
115
+ assert_equal Traka::Change.changes.count, 1
116
+ assert_equal Traka::Change.changes.map(&:klass), ["Cheese"]
117
+ assert_equal Traka::Change.changes.map(&:action_type), ["update"]
109
118
  end
110
119
 
111
120
  test "TrakaChange can filter out obsolete create->update actions" do
@@ -118,9 +127,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
118
127
  p.name = "Another name"
119
128
  p.save
120
129
 
121
- assert_equal Traka::Change.staged_changes.count, 2
122
- assert_equal Traka::Change.staged_changes.map(&:klass), ["Product", "Cheese"]
123
- assert_equal Traka::Change.staged_changes.map(&:action_type), ["create", "create"]
130
+ assert_equal Traka::Change.changes.count, 2
131
+ assert_equal Traka::Change.changes.map(&:klass), ["Product", "Cheese"]
132
+ assert_equal Traka::Change.changes.map(&:action_type), ["create", "create"]
124
133
  end
125
134
 
126
135
  test "TrakaChange can filter out obsolete update->update actions" do
@@ -141,9 +150,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
141
150
  c.name = "New name"
142
151
  c.save
143
152
 
144
- assert_equal Traka::Change.staged_changes.count, 2
145
- assert_equal Traka::Change.staged_changes.map(&:klass), ["Product", "Cheese"]
146
- assert_equal Traka::Change.staged_changes.map(&:action_type), ["update", "update"]
153
+ assert_equal Traka::Change.changes.count, 2
154
+ assert_equal Traka::Change.changes.map(&:klass), ["Product", "Cheese"]
155
+ assert_equal Traka::Change.changes.map(&:action_type), ["update", "update"]
147
156
  end
148
157
 
149
158
  test "TrakaChange can give unabridged list of changes" do
@@ -160,9 +169,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
160
169
  c.destroy
161
170
 
162
171
  # Abridged version would be empty because destroys would cancel out creates and updates.
163
- assert_equal Traka::Change.staged_changes(:filter => false).count, 6
164
- assert_equal Traka::Change.staged_changes(:filter => false).map(&:klass), ["Product", "Cheese", "Product", "Product", "Product", "Cheese"]
165
- assert_equal Traka::Change.staged_changes(:filter => false).map(&:action_type), ["create", "create", "update", "update", "destroy", "destroy"]
172
+ assert_equal Traka::Change.changes(:filter => false).count, 6
173
+ assert_equal Traka::Change.changes(:filter => false).map(&:klass), ["Product", "Cheese", "Product", "Product", "Product", "Cheese"]
174
+ assert_equal Traka::Change.changes(:filter => false).map(&:action_type), ["create", "create", "update", "update", "destroy", "destroy"]
166
175
  end
167
176
 
168
177
  test "TrakaChange can give changes for sub-set of resources" do
@@ -175,9 +184,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
175
184
  c.name = "Another name"
176
185
  c.save
177
186
 
178
- assert_equal Traka::Change.staged_changes(:only => [Product], :filter => false).count, 2
179
- assert_equal Traka::Change.staged_changes(:only => [Product], :filter => false).map(&:klass), ["Product", "Product"]
180
- assert_equal Traka::Change.staged_changes(:only => [Product], :filter => false).map(&:action_type), ["create", "update"]
187
+ assert_equal Traka::Change.changes(:only => [Product], :filter => false).count, 2
188
+ assert_equal Traka::Change.changes(:only => [Product], :filter => false).map(&:klass), ["Product", "Product"]
189
+ assert_equal Traka::Change.changes(:only => [Product], :filter => false).map(&:action_type), ["create", "update"]
181
190
  end
182
191
 
183
192
  test "TrakaChange can give changes for sub-set of actions" do
@@ -190,9 +199,9 @@ class TrakaChangeTest < ActiveSupport::TestCase
190
199
  p.name = "Another name"
191
200
  p.save
192
201
 
193
- assert_equal Traka::Change.staged_changes(:actions => [:create]).count, 2
194
- assert_equal Traka::Change.staged_changes(:actions => [:create]).map(&:klass), ["Product", "Cheese"]
195
- assert_equal Traka::Change.staged_changes(:actions => [:create]).map(&:action_type), ["create", "create"]
202
+ assert_equal Traka::Change.changes(:actions => [:create]).count, 2
203
+ assert_equal Traka::Change.changes(:actions => [:create]).map(&:klass), ["Product", "Cheese"]
204
+ assert_equal Traka::Change.changes(:actions => [:create]).map(&:action_type), ["create", "create"]
196
205
  end
197
206
 
198
207
  test "TrakaChange can accept multiple options" do
@@ -208,21 +217,21 @@ class TrakaChangeTest < ActiveSupport::TestCase
208
217
  p.destroy
209
218
  c.destroy
210
219
 
211
- assert_equal Traka::Change.staged_changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).count, 2
212
- assert_equal Traka::Change.staged_changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).map(&:klass), ["Product", "Cheese"]
213
- assert_equal Traka::Change.staged_changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).map(&:action_type), ["create", "create"]
220
+ assert_equal Traka::Change.changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).count, 2
221
+ assert_equal Traka::Change.changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).map(&:klass), ["Product", "Cheese"]
222
+ assert_equal Traka::Change.changes(:actions => [:create], :filter => false, :only => [Product, Cheese]).map(&:action_type), ["create", "create"]
214
223
 
215
- assert_equal Traka::Change.staged_changes(:actions => [:create, :update], :filter => false).count, 4
216
- assert_equal Traka::Change.staged_changes(:actions => [:create, :update], :filter => false, :only => [Product, Cheese]).map(&:klass), ["Product", "Cheese", "Product", "Product"]
217
- assert_equal Traka::Change.staged_changes(:actions => [:create, :update], :filter => false, :only => [Product, Cheese]).map(&:action_type), ["create", "create", "update", "update"]
224
+ assert_equal Traka::Change.changes(:actions => [:create, :update], :filter => false).count, 4
225
+ assert_equal Traka::Change.changes(:actions => [:create, :update], :filter => false, :only => [Product, Cheese]).map(&:klass), ["Product", "Cheese", "Product", "Product"]
226
+ assert_equal Traka::Change.changes(:actions => [:create, :update], :filter => false, :only => [Product, Cheese]).map(&:action_type), ["create", "create", "update", "update"]
218
227
  end
219
228
 
220
229
  test "TrakaChange can resolve AR objects" do
221
230
  p = Product.create(:name => "Product A")
222
231
  c = Cheese.create(:name => "Cheese A")
223
232
 
224
- assert_equal Traka::Change.staged_changes.first.get_record, p
225
- assert_equal Traka::Change.staged_changes.last.get_record, c
233
+ assert_equal Traka::Change.changes.first.get_record, p
234
+ assert_equal Traka::Change.changes.last.get_record, c
226
235
  end
227
236
 
228
237
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-05 00:00:00.000000000 Z
12
+ date: 2014-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails