pg_audit_log 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pg_audit_log/function.rb +8 -0
- data/lib/pg_audit_log/triggers.rb +1 -0
- data/lib/pg_audit_log/version.rb +1 -1
- data/spec/function_spec.rb +20 -0
- data/spec/pg_audit_log_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -1
- metadata +15 -13
@@ -107,6 +107,14 @@ module PgAuditLog
|
|
107
107
|
def uninstall
|
108
108
|
execute "DROP FUNCTION #{name}()"
|
109
109
|
end
|
110
|
+
|
111
|
+
def installed?
|
112
|
+
connection.select_values(<<-SQL).first.to_i == 1
|
113
|
+
SELECT COUNT(pg_proc.proname)
|
114
|
+
FROM pg_proc
|
115
|
+
WHERE pg_proc.proname = '#{name}'
|
116
|
+
SQL
|
117
|
+
end
|
110
118
|
end
|
111
119
|
end
|
112
120
|
end
|
data/lib/pg_audit_log/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe PgAuditLog::Function do
|
4
|
+
describe ".installed?" do
|
5
|
+
subject { PgAuditLog::Function.installed? }
|
6
|
+
context "when it is not" do
|
7
|
+
before do
|
8
|
+
PgAuditLog::Function.uninstall
|
9
|
+
end
|
10
|
+
it { should be_false }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when it is" do
|
14
|
+
before do
|
15
|
+
PgAuditLog::Function.install
|
16
|
+
end
|
17
|
+
it { should be_true }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/pg_audit_log_spec.rb
CHANGED
@@ -280,4 +280,18 @@ describe PgAuditLog do
|
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
+
describe "when the function does not yet exist" do
|
284
|
+
before do
|
285
|
+
PgAuditLog::Function.uninstall
|
286
|
+
end
|
287
|
+
|
288
|
+
context "when creating a table" do
|
289
|
+
it "should install the function then enable the trigger on the table" do
|
290
|
+
connection.create_table("some_more_new_table")
|
291
|
+
PgAuditLog::Triggers.tables_with_triggers.should include("some_more_new_table")
|
292
|
+
connection.drop_table("some_more_new_table")
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
283
297
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_audit_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &2172772880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2172772880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: pg
|
27
|
-
requirement: &
|
27
|
+
requirement: &2172772120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2172772120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &2172759460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2172759460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: with_model
|
49
|
-
requirement: &
|
49
|
+
requirement: &2172758220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.1.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2172758220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: autotest
|
60
|
-
requirement: &
|
60
|
+
requirement: &2172756540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2172756540
|
69
69
|
description: A completely transparent audit logging component for your application
|
70
70
|
using a stored procedure and triggers. Comes with specs for your project and a rake
|
71
71
|
task to generate the reverse SQL to undo changes logged
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- pg_audit_log.gemspec
|
101
101
|
- spec/configuration_spec.rb
|
102
102
|
- spec/connection_adapter_spec.rb
|
103
|
+
- spec/function_spec.rb
|
103
104
|
- spec/model_spec.rb
|
104
105
|
- spec/pg_audit_log_spec.rb
|
105
106
|
- spec/spec_helper.rb
|
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
segments:
|
120
121
|
- 0
|
121
|
-
hash:
|
122
|
+
hash: -969039138907551583
|
122
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
124
|
none: false
|
124
125
|
requirements:
|
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
version: '0'
|
128
129
|
segments:
|
129
130
|
- 0
|
130
|
-
hash:
|
131
|
+
hash: -969039138907551583
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
134
|
rubygems_version: 1.8.10
|
@@ -137,6 +138,7 @@ summary: postgresql only database-level audit logging of all databases changes
|
|
137
138
|
test_files:
|
138
139
|
- spec/configuration_spec.rb
|
139
140
|
- spec/connection_adapter_spec.rb
|
141
|
+
- spec/function_spec.rb
|
140
142
|
- spec/model_spec.rb
|
141
143
|
- spec/pg_audit_log_spec.rb
|
142
144
|
- spec/spec_helper.rb
|