ku_fu 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ spec/reports/*
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ namespace :ku_fu do
4
+ task :rspec do
5
+ sh "bundle exec rspec spec --format RspecJunitFormatter --out spec/reports/rspec.xml"
6
+ end
7
+ end
8
+
9
+ task "ku_fu:ci" => ["ku_fu:rspec"]
data/ku_fu.gemspec CHANGED
@@ -18,7 +18,10 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.add_runtime_dependency "activerecord"
22
+
21
23
  # specify any dependencies here; for example:
22
24
  s.add_development_dependency "rspec"
23
- s.add_runtime_dependency "activerecord"
25
+ s.add_development_dependency "sqlite3"
26
+ s.add_development_dependency "rspec_junit_formatter"
24
27
  end
data/lib/ku_fu/base.rb CHANGED
@@ -10,10 +10,12 @@ module KuFu
10
10
  module ClassMethods
11
11
  def register_ku_fu
12
12
  before_save :ku_fu_register
13
+ before_destroy :ku_fu_register_deleter
13
14
  end
14
15
  end
15
16
 
16
17
  module InstanceMethods
18
+
17
19
  def ku_fu_register
18
20
  if new_record?
19
21
  write_attribute(:creator_id, User.current.id) if self.respond_to?(:creator_id)
@@ -21,6 +23,11 @@ module KuFu
21
23
  write_attribute(:updater_id, User.current.id) if self.respond_to?(:updater_id)
22
24
  end
23
25
  end
26
+
27
+ def ku_fu_register_deleter
28
+ write_attribute(:deleter_id, User.current.id) if self.respond_to?(:deleter_id)
29
+ end
30
+
24
31
  end
25
32
 
26
33
  end
data/lib/ku_fu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KuFu
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/ku_fu_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe "ku_fu" do
8
8
 
9
9
  context "given a class that register_ku_fu" do
10
10
 
11
- before do
11
+ before do
12
12
  @subject = Document
13
13
  end
14
14
 
@@ -35,6 +35,18 @@ describe "ku_fu" do
35
35
 
36
36
  end
37
37
 
38
- end
38
+ context "on destroy" do
39
+
40
+ it "should save the User.current id as deleter_id" do
41
+ model = @subject.create!
42
+ new_user = User.create!
43
+ User.current = new_user
44
+ model.send(:run_callbacks, :destroy)
45
+ model.deleter_id.should eq User.current.id
46
+ model.creator_id.should_not eq model.deleter_id
47
+ model.updater_id.should be_nil
48
+ end
39
49
 
40
- end
50
+ end
51
+ end
52
+ end
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ RSpec.configure do |config|
22
22
  t.string :title
23
23
  t.integer :creator_id
24
24
  t.integer :updater_id
25
+ t.integer :deleter_id
25
26
  t.timestamps
26
27
  end
27
28
  User.current = User.create!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ku_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &70152357664280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70152357664280
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rspec
16
- requirement: &70275885299360 !ruby/object:Gem::Requirement
27
+ requirement: &70152357663860 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ! '>='
@@ -21,18 +32,29 @@ dependencies:
21
32
  version: '0'
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *70275885299360
35
+ version_requirements: *70152357663860
25
36
  - !ruby/object:Gem::Dependency
26
- name: activerecord
27
- requirement: &70275885298800 !ruby/object:Gem::Requirement
37
+ name: sqlite3
38
+ requirement: &70152357655900 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
31
42
  - !ruby/object:Gem::Version
32
43
  version: '0'
33
- type: :runtime
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70152357655900
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec_junit_formatter
49
+ requirement: &70152357655220 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
34
56
  prerelease: false
35
- version_requirements: *70275885298800
57
+ version_requirements: *70152357655220
36
58
  description: register who created, updated or deleted an active record object
37
59
  email:
38
60
  - acampolonghi@gmail.com