rails_best_practices 0.3.20 → 0.3.21

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 CHANGED
@@ -1 +1 @@
1
- 0.3.20
1
+ 0.3.21
@@ -22,7 +22,7 @@ module RailsBestPractices
22
22
  private
23
23
 
24
24
  def others_finder?(node)
25
- node.message == :find and node.subject.node_type == :call
25
+ node.message == :find and node.subject.node_type == :call and node.arguments.size > 1
26
26
  end
27
27
  end
28
28
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_best_practices}
8
- s.version = "0.3.20"
8
+ s.version = "0.3.21"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Richard Huang"]
@@ -54,7 +54,7 @@ describe RailsBestPractices::Checks::KeepFindersOnTheirOwnModelCheck do
54
54
  errors.should be_empty
55
55
  end
56
56
 
57
- it "should not keep finders on thier own model without finder" do
57
+ it "should not keep finders on their own model without finder" do
58
58
  content = <<-EOF
59
59
  class Post < ActiveRecord::Base
60
60
  has_many :comments
@@ -68,4 +68,19 @@ describe RailsBestPractices::Checks::KeepFindersOnTheirOwnModelCheck do
68
68
  errors = @runner.errors
69
69
  errors.should be_empty
70
70
  end
71
+
72
+ it "should not keep finders on their own model with ruby Array#find" do
73
+ content = <<-EOF
74
+ class Post < ActiveRecord::Base
75
+ has_many :comments
76
+
77
+ def active_comments
78
+ self.comments.find {|comment| comment.status == 'active'}
79
+ end
80
+ end
81
+ EOF
82
+ @runner.check('app/models/post.rb', content)
83
+ errors = @runner.errors
84
+ errors.should be_empty
85
+ end
71
86
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 20
9
- version: 0.3.20
8
+ - 21
9
+ version: 0.3.21
10
10
  platform: ruby
11
11
  authors:
12
12
  - Richard Huang