trackable 0.4.0 → 0.4.1
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.
- data/VERSION +1 -1
- data/lib/trackable/acts_as_trackable.rb +1 -1
- data/test/trackable_test.rb +20 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
@@ -14,7 +14,7 @@ module ActsAsTrackable
|
|
14
14
|
}
|
15
15
|
send :include, InstanceMethods
|
16
16
|
has_many :events, :as => :eventable, :dependent => :destroy, :order => "created_at desc"
|
17
|
-
after_save :record_events
|
17
|
+
send options[:on] ? :"after_#{options[:on]}" : :after_save, :record_events
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/test/trackable_test.rb
CHANGED
@@ -147,5 +147,25 @@ class TrackableTest < Test::Unit::TestCase
|
|
147
147
|
bar.update_attribute(:name, "Megatron")
|
148
148
|
assert_equal "Name changed to Megatron", bar.events.first.message
|
149
149
|
end
|
150
|
+
|
151
|
+
def test_trackable_can_be_set_to_only_record_on_create
|
152
|
+
Bar.instance_variable_set :@after_save_callbacks, ActiveSupport::Callbacks::CallbackChain.new
|
153
|
+
Bar.trackable :on => :create
|
154
|
+
bar = Bar.create(:name => 'bar')
|
155
|
+
assert_equal "Name changed to bar", bar.events.first.message
|
156
|
+
assert_equal 1, bar.events.count
|
157
|
+
bar.update_attributes(:name => 'baz')
|
158
|
+
assert_equal 1, bar.events.count
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_trackable_can_be_set_to_only_record_on_update
|
162
|
+
Bar.instance_variable_set :@after_create_callbacks, ActiveSupport::Callbacks::CallbackChain.new
|
163
|
+
Bar.trackable :on => :update
|
164
|
+
bar = Bar.create(:name => 'bar')
|
165
|
+
assert_equal 0, bar.events.count
|
166
|
+
bar.update_attributes(:name => 'baz')
|
167
|
+
assert_equal "Name changed to baz", bar.events.first.message
|
168
|
+
assert_equal 1, bar.events.count
|
169
|
+
end
|
150
170
|
|
151
171
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- bigfleet
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-11 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|