active_record-comments 0.0.1 → 0.1.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/lib/active_record/comments.rb +6 -26
- metadata +11 -37
- data/.travis.yml +0 -8
- data/Appraisals +0 -5
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -51
- data/Rakefile +0 -11
- data/Readme.md +0 -27
- data/active_record-comments.gemspec +0 -11
- data/gemfiles/activerecord_2.3.gemfile +0 -12
- data/gemfiles/activerecord_2.3.gemfile.lock +0 -39
- data/gemfiles/activerecord_3.0.gemfile +0 -12
- data/gemfiles/activerecord_3.0.gemfile.lock +0 -50
- data/gemfiles/activerecord_3.1.gemfile +0 -12
- data/gemfiles/activerecord_3.1.gemfile.lock +0 -52
- data/gemfiles/activerecord_3.2.gemfile +0 -12
- data/gemfiles/activerecord_3.2.gemfile.lock +0 -52
- data/spec/active_record/comments_spec.rb +0 -96
- data/spec/spec_helper.rb +0 -16
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 3479f24b30ad73efbf9937f33c94c3f722e8dac7
|
|
4
|
+
data.tar.gz: 4f399eabfb49d657ffb82dcd702eb66ee20a54bb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 19a92d96e8c9faebeb5b9a0d34287e9abd150f3fd98f9296fd01e286178f8c4f95687cca52db24976a33b8dde38dd291c10c980f8fae7b71d7eec46c574a492e
|
|
7
|
+
data.tar.gz: bd39c3c075ec5a66b1a2db8566abd48675fd3a64af43c6bd12d1e1b62a088c70f04da3f64fdac96f5104b40c83f951cab192f1e14c25bd7cf4e599027bc0f96b
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (C) 2013 AUTHOR_NAME <AUTHOR_EMAIL>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -25,31 +25,11 @@ module ActiveRecord
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
alias_method_chain(:construct_finder_sql, :comments)
|
|
35
|
-
|
|
36
|
-
def construct_calculation_sql_with_comments(operation, column_name, options)
|
|
37
|
-
sql = construct_calculation_sql_without_comments(operation, column_name, options)
|
|
38
|
-
ActiveRecord::Comments.with_comment_sql(sql)
|
|
39
|
-
end
|
|
40
|
-
alias_method_chain(:construct_calculation_sql, :comments)
|
|
41
|
-
end
|
|
42
|
-
else
|
|
43
|
-
klass = if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
|
|
44
|
-
Arel::SelectManager
|
|
45
|
-
else
|
|
46
|
-
ActiveRecord::Relation
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
klass.class_eval do
|
|
50
|
-
alias to_sql_with_comments to_sql
|
|
51
|
-
def to_sql
|
|
52
|
-
ActiveRecord::Comments.with_comment_sql(to_sql_with_comments)
|
|
53
|
-
end
|
|
28
|
+
# log is called by execute in all db adapters
|
|
29
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
|
|
30
|
+
def log_with_comment_injection(query, *args, &block)
|
|
31
|
+
query = ActiveRecord::Comments.with_comment_sql(query)
|
|
32
|
+
log_without_comment_injection(query, *args, &block)
|
|
54
33
|
end
|
|
34
|
+
alias_method_chain :log, :comment_injection
|
|
55
35
|
end
|
metadata
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_record-comments
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.1.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Michael Grosser
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: activerecord
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - '>='
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '0'
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - '>='
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: '0'
|
|
30
27
|
description:
|
|
@@ -33,53 +30,30 @@ executables: []
|
|
|
33
30
|
extensions: []
|
|
34
31
|
extra_rdoc_files: []
|
|
35
32
|
files:
|
|
36
|
-
-
|
|
37
|
-
- Appraisals
|
|
38
|
-
- Gemfile
|
|
39
|
-
- Gemfile.lock
|
|
40
|
-
- Rakefile
|
|
41
|
-
- Readme.md
|
|
42
|
-
- active_record-comments.gemspec
|
|
43
|
-
- gemfiles/activerecord_2.3.gemfile
|
|
44
|
-
- gemfiles/activerecord_2.3.gemfile.lock
|
|
45
|
-
- gemfiles/activerecord_3.0.gemfile
|
|
46
|
-
- gemfiles/activerecord_3.0.gemfile.lock
|
|
47
|
-
- gemfiles/activerecord_3.1.gemfile
|
|
48
|
-
- gemfiles/activerecord_3.1.gemfile.lock
|
|
49
|
-
- gemfiles/activerecord_3.2.gemfile
|
|
50
|
-
- gemfiles/activerecord_3.2.gemfile.lock
|
|
33
|
+
- MIT-LICENSE
|
|
51
34
|
- lib/active_record/comments.rb
|
|
52
|
-
|
|
53
|
-
- spec/spec_helper.rb
|
|
54
|
-
homepage: http://github.com/grosser/active_record-comments
|
|
35
|
+
homepage: https://github.com/grosser/active_record-comments
|
|
55
36
|
licenses:
|
|
56
37
|
- MIT
|
|
38
|
+
metadata: {}
|
|
57
39
|
post_install_message:
|
|
58
40
|
rdoc_options: []
|
|
59
41
|
require_paths:
|
|
60
42
|
- lib
|
|
61
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
-
none: false
|
|
63
44
|
requirements:
|
|
64
|
-
- -
|
|
45
|
+
- - '>='
|
|
65
46
|
- !ruby/object:Gem::Version
|
|
66
47
|
version: '0'
|
|
67
|
-
segments:
|
|
68
|
-
- 0
|
|
69
|
-
hash: -2889031802467512839
|
|
70
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
-
none: false
|
|
72
49
|
requirements:
|
|
73
|
-
- -
|
|
50
|
+
- - '>='
|
|
74
51
|
- !ruby/object:Gem::Version
|
|
75
52
|
version: '0'
|
|
76
|
-
segments:
|
|
77
|
-
- 0
|
|
78
|
-
hash: -2889031802467512839
|
|
79
53
|
requirements: []
|
|
80
54
|
rubyforge_project:
|
|
81
|
-
rubygems_version:
|
|
55
|
+
rubygems_version: 2.0.3
|
|
82
56
|
signing_key:
|
|
83
|
-
specification_version:
|
|
57
|
+
specification_version: 4
|
|
84
58
|
summary: Comments for activerecord
|
|
85
59
|
test_files: []
|
data/.travis.yml
DELETED
data/Appraisals
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
active_record-comments (0.0.1)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: http://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (3.2.11)
|
|
11
|
-
activesupport (= 3.2.11)
|
|
12
|
-
builder (~> 3.0.0)
|
|
13
|
-
activerecord (3.2.11)
|
|
14
|
-
activemodel (= 3.2.11)
|
|
15
|
-
activesupport (= 3.2.11)
|
|
16
|
-
arel (~> 3.0.2)
|
|
17
|
-
tzinfo (~> 0.3.29)
|
|
18
|
-
activesupport (3.2.11)
|
|
19
|
-
i18n (~> 0.6)
|
|
20
|
-
multi_json (~> 1.0)
|
|
21
|
-
appraisal (0.5.1)
|
|
22
|
-
bundler
|
|
23
|
-
rake
|
|
24
|
-
arel (3.0.2)
|
|
25
|
-
builder (3.0.4)
|
|
26
|
-
bump (0.3.8)
|
|
27
|
-
diff-lcs (1.1.3)
|
|
28
|
-
i18n (0.6.1)
|
|
29
|
-
multi_json (1.5.0)
|
|
30
|
-
rake (0.9.2)
|
|
31
|
-
rspec (2.6.0)
|
|
32
|
-
rspec-core (~> 2.6.0)
|
|
33
|
-
rspec-expectations (~> 2.6.0)
|
|
34
|
-
rspec-mocks (~> 2.6.0)
|
|
35
|
-
rspec-core (2.6.4)
|
|
36
|
-
rspec-expectations (2.6.0)
|
|
37
|
-
diff-lcs (~> 1.1.2)
|
|
38
|
-
rspec-mocks (2.6.0)
|
|
39
|
-
sqlite3 (1.3.6)
|
|
40
|
-
tzinfo (0.3.35)
|
|
41
|
-
|
|
42
|
-
PLATFORMS
|
|
43
|
-
ruby
|
|
44
|
-
|
|
45
|
-
DEPENDENCIES
|
|
46
|
-
active_record-comments!
|
|
47
|
-
appraisal
|
|
48
|
-
bump
|
|
49
|
-
rake
|
|
50
|
-
rspec (~> 2)
|
|
51
|
-
sqlite3
|
data/Rakefile
DELETED
data/Readme.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Adds comments to your activerecord queries so you can seem where they came from or what user caused them.<br/>
|
|
2
|
-
for on Rails 2 + 3 + 4
|
|
3
|
-
|
|
4
|
-
Install
|
|
5
|
-
=======
|
|
6
|
-
|
|
7
|
-
gem install active_record-comments
|
|
8
|
-
|
|
9
|
-
Usage
|
|
10
|
-
=====
|
|
11
|
-
|
|
12
|
-
require "active_record/comments"
|
|
13
|
-
|
|
14
|
-
# => SELECT ... /* user.rb:123 */
|
|
15
|
-
result = ActiveRecord::Comments.comment("user.rb:123"){ User.where("x like y").count }
|
|
16
|
-
|
|
17
|
-
# => SELECT ... /* account cleanup initial */
|
|
18
|
-
result = ActiveRecord::Comments.comment("account cleanup") do
|
|
19
|
-
ActiveRecord::Comments.comment("initial"){ User.where("x like y").count }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
Author
|
|
23
|
-
======
|
|
24
|
-
[Michael Grosser](http://grosser.it)<br/>
|
|
25
|
-
michael@grosser.it<br/>
|
|
26
|
-
License: MIT<br/>
|
|
27
|
-
[](https://travis-ci.org/grosser/active_record-comments)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
name = "active_record-comments"
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new name, "0.0.1" do |s|
|
|
4
|
-
s.summary = "Comments for activerecord"
|
|
5
|
-
s.authors = ["Michael Grosser"]
|
|
6
|
-
s.email = "michael@grosser.it"
|
|
7
|
-
s.homepage = "http://github.com/grosser/#{name}"
|
|
8
|
-
s.files = `git ls-files`.split("\n")
|
|
9
|
-
s.license = "MIT"
|
|
10
|
-
s.add_runtime_dependency "activerecord"
|
|
11
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: /Users/mgrosser/code/tools/active_record-comments
|
|
3
|
-
specs:
|
|
4
|
-
active_record-comments (0.0.0)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: http://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activerecord (2.3.15)
|
|
11
|
-
activesupport (= 2.3.15)
|
|
12
|
-
activesupport (2.3.15)
|
|
13
|
-
appraisal (0.5.1)
|
|
14
|
-
bundler
|
|
15
|
-
rake
|
|
16
|
-
bump (0.3.9)
|
|
17
|
-
diff-lcs (1.1.3)
|
|
18
|
-
rake (10.0.3)
|
|
19
|
-
rspec (2.12.0)
|
|
20
|
-
rspec-core (~> 2.12.0)
|
|
21
|
-
rspec-expectations (~> 2.12.0)
|
|
22
|
-
rspec-mocks (~> 2.12.0)
|
|
23
|
-
rspec-core (2.12.2)
|
|
24
|
-
rspec-expectations (2.12.1)
|
|
25
|
-
diff-lcs (~> 1.1.3)
|
|
26
|
-
rspec-mocks (2.12.1)
|
|
27
|
-
sqlite3 (1.3.7)
|
|
28
|
-
|
|
29
|
-
PLATFORMS
|
|
30
|
-
ruby
|
|
31
|
-
|
|
32
|
-
DEPENDENCIES
|
|
33
|
-
active_record-comments!
|
|
34
|
-
activerecord (~> 2.3.0)
|
|
35
|
-
appraisal
|
|
36
|
-
bump
|
|
37
|
-
rake
|
|
38
|
-
rspec (~> 2)
|
|
39
|
-
sqlite3
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: /Users/mgrosser/code/tools/active_record-comments
|
|
3
|
-
specs:
|
|
4
|
-
active_record-comments (0.0.0)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: http://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (3.0.19)
|
|
11
|
-
activesupport (= 3.0.19)
|
|
12
|
-
builder (~> 2.1.2)
|
|
13
|
-
i18n (~> 0.5.0)
|
|
14
|
-
activerecord (3.0.19)
|
|
15
|
-
activemodel (= 3.0.19)
|
|
16
|
-
activesupport (= 3.0.19)
|
|
17
|
-
arel (~> 2.0.10)
|
|
18
|
-
tzinfo (~> 0.3.23)
|
|
19
|
-
activesupport (3.0.19)
|
|
20
|
-
appraisal (0.5.1)
|
|
21
|
-
bundler
|
|
22
|
-
rake
|
|
23
|
-
arel (2.0.10)
|
|
24
|
-
builder (2.1.2)
|
|
25
|
-
bump (0.3.9)
|
|
26
|
-
diff-lcs (1.1.3)
|
|
27
|
-
i18n (0.5.0)
|
|
28
|
-
rake (10.0.3)
|
|
29
|
-
rspec (2.12.0)
|
|
30
|
-
rspec-core (~> 2.12.0)
|
|
31
|
-
rspec-expectations (~> 2.12.0)
|
|
32
|
-
rspec-mocks (~> 2.12.0)
|
|
33
|
-
rspec-core (2.12.2)
|
|
34
|
-
rspec-expectations (2.12.1)
|
|
35
|
-
diff-lcs (~> 1.1.3)
|
|
36
|
-
rspec-mocks (2.12.1)
|
|
37
|
-
sqlite3 (1.3.7)
|
|
38
|
-
tzinfo (0.3.35)
|
|
39
|
-
|
|
40
|
-
PLATFORMS
|
|
41
|
-
ruby
|
|
42
|
-
|
|
43
|
-
DEPENDENCIES
|
|
44
|
-
active_record-comments!
|
|
45
|
-
activerecord (~> 3.0.0)
|
|
46
|
-
appraisal
|
|
47
|
-
bump
|
|
48
|
-
rake
|
|
49
|
-
rspec (~> 2)
|
|
50
|
-
sqlite3
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: /Users/mgrosser/code/tools/active_record-comments
|
|
3
|
-
specs:
|
|
4
|
-
active_record-comments (0.0.0)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: http://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (3.1.10)
|
|
11
|
-
activesupport (= 3.1.10)
|
|
12
|
-
builder (~> 3.0.0)
|
|
13
|
-
i18n (~> 0.6)
|
|
14
|
-
activerecord (3.1.10)
|
|
15
|
-
activemodel (= 3.1.10)
|
|
16
|
-
activesupport (= 3.1.10)
|
|
17
|
-
arel (~> 2.2.3)
|
|
18
|
-
tzinfo (~> 0.3.29)
|
|
19
|
-
activesupport (3.1.10)
|
|
20
|
-
multi_json (>= 1.0, < 1.3)
|
|
21
|
-
appraisal (0.5.1)
|
|
22
|
-
bundler
|
|
23
|
-
rake
|
|
24
|
-
arel (2.2.3)
|
|
25
|
-
builder (3.0.4)
|
|
26
|
-
bump (0.3.9)
|
|
27
|
-
diff-lcs (1.1.3)
|
|
28
|
-
i18n (0.6.1)
|
|
29
|
-
multi_json (1.2.0)
|
|
30
|
-
rake (10.0.3)
|
|
31
|
-
rspec (2.12.0)
|
|
32
|
-
rspec-core (~> 2.12.0)
|
|
33
|
-
rspec-expectations (~> 2.12.0)
|
|
34
|
-
rspec-mocks (~> 2.12.0)
|
|
35
|
-
rspec-core (2.12.2)
|
|
36
|
-
rspec-expectations (2.12.1)
|
|
37
|
-
diff-lcs (~> 1.1.3)
|
|
38
|
-
rspec-mocks (2.12.1)
|
|
39
|
-
sqlite3 (1.3.7)
|
|
40
|
-
tzinfo (0.3.35)
|
|
41
|
-
|
|
42
|
-
PLATFORMS
|
|
43
|
-
ruby
|
|
44
|
-
|
|
45
|
-
DEPENDENCIES
|
|
46
|
-
active_record-comments!
|
|
47
|
-
activerecord (~> 3.1.0)
|
|
48
|
-
appraisal
|
|
49
|
-
bump
|
|
50
|
-
rake
|
|
51
|
-
rspec (~> 2)
|
|
52
|
-
sqlite3
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: /Users/mgrosser/code/tools/active_record-comments
|
|
3
|
-
specs:
|
|
4
|
-
active_record-comments (0.0.0)
|
|
5
|
-
activerecord
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: http://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
activemodel (3.2.11)
|
|
11
|
-
activesupport (= 3.2.11)
|
|
12
|
-
builder (~> 3.0.0)
|
|
13
|
-
activerecord (3.2.11)
|
|
14
|
-
activemodel (= 3.2.11)
|
|
15
|
-
activesupport (= 3.2.11)
|
|
16
|
-
arel (~> 3.0.2)
|
|
17
|
-
tzinfo (~> 0.3.29)
|
|
18
|
-
activesupport (3.2.11)
|
|
19
|
-
i18n (~> 0.6)
|
|
20
|
-
multi_json (~> 1.0)
|
|
21
|
-
appraisal (0.5.1)
|
|
22
|
-
bundler
|
|
23
|
-
rake
|
|
24
|
-
arel (3.0.2)
|
|
25
|
-
builder (3.0.4)
|
|
26
|
-
bump (0.3.9)
|
|
27
|
-
diff-lcs (1.1.3)
|
|
28
|
-
i18n (0.6.1)
|
|
29
|
-
multi_json (1.5.0)
|
|
30
|
-
rake (10.0.3)
|
|
31
|
-
rspec (2.12.0)
|
|
32
|
-
rspec-core (~> 2.12.0)
|
|
33
|
-
rspec-expectations (~> 2.12.0)
|
|
34
|
-
rspec-mocks (~> 2.12.0)
|
|
35
|
-
rspec-core (2.12.2)
|
|
36
|
-
rspec-expectations (2.12.1)
|
|
37
|
-
diff-lcs (~> 1.1.3)
|
|
38
|
-
rspec-mocks (2.12.1)
|
|
39
|
-
sqlite3 (1.3.7)
|
|
40
|
-
tzinfo (0.3.35)
|
|
41
|
-
|
|
42
|
-
PLATFORMS
|
|
43
|
-
ruby
|
|
44
|
-
|
|
45
|
-
DEPENDENCIES
|
|
46
|
-
active_record-comments!
|
|
47
|
-
activerecord (~> 3.2.0)
|
|
48
|
-
appraisal
|
|
49
|
-
bump
|
|
50
|
-
rake
|
|
51
|
-
rspec (~> 2)
|
|
52
|
-
sqlite3
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe ActiveRecord::Comments do
|
|
4
|
-
def normalize_sql(sql)
|
|
5
|
-
sql.gsub("``", '""').gsub(" ", " ").strip
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe ".current_comment" do
|
|
9
|
-
it "be empty when not called" do
|
|
10
|
-
ActiveRecord::Comments.comment("xxx"){}
|
|
11
|
-
ActiveRecord::Comments.send(:current_comment).should == nil
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "be filled when called" do
|
|
15
|
-
result = nil
|
|
16
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
17
|
-
result = ActiveRecord::Comments.send(:current_comment)
|
|
18
|
-
end
|
|
19
|
-
"xxx".should == result
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "concat" do
|
|
23
|
-
result = nil
|
|
24
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
25
|
-
ActiveRecord::Comments.comment("yyy") do
|
|
26
|
-
result = ActiveRecord::Comments.send(:current_comment)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
result.should == "xxx yyy"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "unpop" do
|
|
33
|
-
result = nil
|
|
34
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
35
|
-
ActiveRecord::Comments.comment("yyy") { }
|
|
36
|
-
result = ActiveRecord::Comments.send(:current_comment)
|
|
37
|
-
end
|
|
38
|
-
result.should == "xxx"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe ".comment" do
|
|
43
|
-
it "return results" do
|
|
44
|
-
ActiveRecord::Comments.comment("xxx"){ 1 }.should == 1
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
if ActiveRecord::VERSION::MAJOR == 2
|
|
49
|
-
describe "#construct_finder_sql" do
|
|
50
|
-
it "not be there when not called" do
|
|
51
|
-
ActiveRecord::Comments.comment("xxx"){ }
|
|
52
|
-
normalize_sql(User.scoped(:conditions => {:id => 1}).send(:construct_finder_sql, {})).should ==
|
|
53
|
-
'SELECT * FROM "users" WHERE ("users"."id" = 1)'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "be there when called" do
|
|
57
|
-
result = nil
|
|
58
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
59
|
-
result = User.scoped(:conditions => {:id => 1}).send(:construct_finder_sql, {})
|
|
60
|
-
end
|
|
61
|
-
normalize_sql(result).should == 'SELECT * FROM "users" WHERE ("users"."id" = 1) /* xxx */'
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
describe "#construct_calculation_sql_with_comments" do
|
|
66
|
-
it "not be there when not called" do
|
|
67
|
-
ActiveRecord::Comments.comment("xxx"){ }
|
|
68
|
-
normalize_sql(User.scoped(:conditions => {:id => 1}).send(:construct_calculation_sql_with_comments, "count", "id", {})).should ==
|
|
69
|
-
'SELECT count("users".id) AS count_id FROM "users" WHERE ("users"."id" = 1)'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "be there when called" do
|
|
73
|
-
result = nil
|
|
74
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
75
|
-
result = User.scoped(:conditions => {:id => 1}).send(:construct_calculation_sql_with_comments, "count", "id", {})
|
|
76
|
-
end
|
|
77
|
-
normalize_sql(result).should == 'SELECT count("users".id) AS count_id FROM "users" WHERE ("users"."id" = 1) /* xxx */'
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
describe "#to_sql" do
|
|
82
|
-
it "not be there when not called" do
|
|
83
|
-
ActiveRecord::Comments.comment("xxx"){ }
|
|
84
|
-
normalize_sql(User.where(:id => 1).to_sql).should == 'SELECT "users".* FROM "users" WHERE "users"."id" = 1'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "be there when called" do
|
|
88
|
-
result = nil
|
|
89
|
-
ActiveRecord::Comments.comment("xxx") do
|
|
90
|
-
result = User.where(:id => 1).to_sql
|
|
91
|
-
end
|
|
92
|
-
normalize_sql(result).should == 'SELECT "users".* FROM "users" WHERE "users"."id" = 1 /* xxx */'
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require "active_record/comments"
|
|
2
|
-
|
|
3
|
-
ActiveRecord::Base.establish_connection(
|
|
4
|
-
:adapter => "sqlite3",
|
|
5
|
-
:database => ":memory:"
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
ActiveRecord::Schema.verbose = false
|
|
9
|
-
ActiveRecord::Schema.define(:version => 1) do
|
|
10
|
-
create_table :users do |t|
|
|
11
|
-
t.string :name
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class User < ActiveRecord::Base
|
|
16
|
-
end
|