yoon-view_trail 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/VERSION +1 -1
- data/features/view_trail.feature +4 -4
- data/generators/view_trail/templates/create_activities_and_items.rb +1 -1
- data/lib/view_trail.rb +10 -10
- data/view_trail.gemspec +2 -2
- metadata +4 -3
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Works with Rails 2.3.
|
|
27
27
|
|
28
28
|
For example: when you visit /foo/search?query=pie
|
29
29
|
|
30
|
-
>> Activities.last.
|
30
|
+
>> Activities.last.whodiddit #=> (@controller.current_user)
|
31
31
|
>> Activities.last.created_at #=> (date/time of activity)
|
32
32
|
>> Activities.last.controller #=> FooController
|
33
33
|
>> Activities.last.action #=> "search"
|
@@ -54,6 +54,19 @@ Works with Rails 2.3.
|
|
54
54
|
|
55
55
|
Please submit issues via GitHub's [Issue Tracker](http://github.com/yoon/view_trail/issues)
|
56
56
|
|
57
|
+
## History
|
58
|
+
|
59
|
+
0.3.1
|
60
|
+
|
61
|
+
Fixed conflict with paper trail whodunnit. To upgrade:
|
62
|
+
|
63
|
+
`rake db:migrate:down`
|
64
|
+
|
65
|
+
remove old migration and re-run
|
66
|
+
|
67
|
+
`script/generate view_trail`
|
68
|
+
`rake db:migrate`
|
69
|
+
|
57
70
|
## Inspiration
|
58
71
|
|
59
72
|
* [PaperTrail](http://github.com/airblade/paper_trail/)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/features/view_trail.feature
CHANGED
@@ -9,7 +9,7 @@ Feature: ViewTrail
|
|
9
9
|
Given I have 0 activities
|
10
10
|
When I get the foo page
|
11
11
|
Then I should have 1 activities
|
12
|
-
And the last activity should have "312"
|
12
|
+
And the last activity should have "312" whodiddit
|
13
13
|
And the last activity should have "foo" action
|
14
14
|
And the last activity should have "foo" controller
|
15
15
|
And the last activity should have "" params
|
@@ -17,19 +17,19 @@ Feature: ViewTrail
|
|
17
17
|
Scenario: POST request
|
18
18
|
When I post the foo page
|
19
19
|
Then I should have 2 activities
|
20
|
-
And the last activity should have "312"
|
20
|
+
And the last activity should have "312" whodiddit
|
21
21
|
And the last activity should have "foo" action
|
22
22
|
|
23
23
|
Scenario: PUT request
|
24
24
|
Given I put the foo page
|
25
25
|
Then I should have 3 activities
|
26
|
-
And the last activity should have "312"
|
26
|
+
And the last activity should have "312" whodiddit
|
27
27
|
And the last activity should have "foo" action
|
28
28
|
|
29
29
|
Scenario: DELETE request
|
30
30
|
Given I delete the foo page
|
31
31
|
Then I should have 4 activities
|
32
|
-
And the last activity should have "312"
|
32
|
+
And the last activity should have "312" whodiddit
|
33
33
|
And the last activity should have "foo" action
|
34
34
|
|
35
35
|
Scenario: GET request with params
|
data/lib/view_trail.rb
CHANGED
@@ -2,32 +2,32 @@ require 'view_trail/activity'
|
|
2
2
|
require 'view_trail/activity_item'
|
3
3
|
|
4
4
|
module ViewTrail
|
5
|
-
@@
|
5
|
+
@@whodiddit = nil
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
base.send :extend, ClassMethods
|
9
|
-
base.before_filter :
|
9
|
+
base.before_filter :set_whodiddit
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
@@
|
12
|
+
def self.whodiddit
|
13
|
+
@@whodiddit.respond_to?(:call) ? @@whodiddit.call : @@whodiddit
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.
|
17
|
-
@@
|
16
|
+
def self.whodiddit=(value)
|
17
|
+
@@whodiddit = value
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def
|
23
|
-
@@
|
22
|
+
def set_whodiddit
|
23
|
+
@@whodiddit = lambda {
|
24
24
|
self.respond_to?(:current_user) ? self.current_user : nil
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
28
|
module ClassMethods
|
29
29
|
def has_view_trail(*conditions)
|
30
|
-
before_filter :
|
30
|
+
before_filter :set_whodiddit
|
31
31
|
after_filter(:record_activity, conditions)
|
32
32
|
cattr_accessor :view_trail_active
|
33
33
|
self.view_trail_active = true
|
@@ -48,7 +48,7 @@ module ViewTrail
|
|
48
48
|
end
|
49
49
|
def record_activity
|
50
50
|
if self.class.view_trail_active
|
51
|
-
a = Activity.create(:
|
51
|
+
a = Activity.create(:whodiddit => ViewTrail.whodiddit, :controller => params.delete(:controller), :action => params.delete(:action), :params => params)
|
52
52
|
(@activity_items || {}).each do |k,v|
|
53
53
|
a.activity_items.create(:key => k.to_s, :value => v)
|
54
54
|
end
|
data/view_trail.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{view_trail}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Mark Yoon"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-08-14}
|
10
10
|
s.description = %q{View trail tracks controller actions in Rails.}
|
11
11
|
s.email = %q{yoon@northwestern.edu}
|
12
12
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yoon-view_trail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Yoon
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- view_trail.gemspec
|
45
45
|
has_rdoc: false
|
46
46
|
homepage: http://github.com/yoon/view_trail
|
47
|
+
licenses:
|
47
48
|
post_install_message:
|
48
49
|
rdoc_options:
|
49
50
|
- --charset=UTF-8
|
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
65
|
requirements: []
|
65
66
|
|
66
67
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.3.5
|
68
69
|
signing_key:
|
69
70
|
specification_version: 3
|
70
71
|
summary: View trail tracks controller actions in Rails.
|