rails_best_practices 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -30,7 +30,7 @@ module RailsBestPractices
30
30
  end
31
31
 
32
32
  def current_user?(call_node)
33
- call_node.message == :current_user or (call_node.subject.message == :current_user and call_node.message == :id)
33
+ call_node.node_type == :call and (call_node.message == :current_user or (call_node.subject.message == :current_user and call_node.message == :id))
34
34
  end
35
35
 
36
36
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_best_practices}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
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"]
12
- s.date = %q{2009-11-13}
12
+ s.date = %q{2009-11-17}
13
13
  s.default_executable = %q{rails_best_practices}
14
14
  s.description = %q{check rails files according to ihower's presentation 'rails best practices'}
15
15
  s.email = %q{flyerhzm@gmail.com}
@@ -88,27 +88,27 @@ Gem::Specification.new do |s|
88
88
  s.rubygems_version = %q{1.3.5}
89
89
  s.summary = %q{check rails files according to ihower's presentation 'rails best practices'}
90
90
  s.test_files = [
91
- "spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb",
92
- "spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
93
- "spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
94
- "spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
95
- "spec/rails_best_practices/checks/use_observer_check_spec.rb",
96
- "spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
97
- "spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
98
- "spec/rails_best_practices/checks/use_filter_check_spec.rb",
91
+ "spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb",
99
92
  "spec/rails_best_practices/checks/always_add_db_index_check_spec.rb",
100
- "spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb",
93
+ "spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb",
94
+ "spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb",
101
95
  "spec/rails_best_practices/checks/law_of_demeter_check_spec.rb",
102
- "spec/rails_best_practices/checks/use_scope_access_check_spec.rb",
103
- "spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb",
104
- "spec/rails_best_practices/checks/not_use_default_route_check_spec.rb",
96
+ "spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb",
97
+ "spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb",
98
+ "spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb",
105
99
  "spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb",
106
- "spec/rails_best_practices/checks/use_model_callback_check_spec.rb",
107
- "spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb",
100
+ "spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb",
101
+ "spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb",
102
+ "spec/rails_best_practices/checks/nested_model_forms_check_spec.rb",
103
+ "spec/rails_best_practices/checks/not_use_default_route_check_spec.rb",
104
+ "spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb",
105
+ "spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb",
108
106
  "spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb",
107
+ "spec/rails_best_practices/checks/use_filter_check_spec.rb",
109
108
  "spec/rails_best_practices/checks/use_model_association_check_spec.rb",
110
- "spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb",
111
- "spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb",
109
+ "spec/rails_best_practices/checks/use_model_callback_check_spec.rb",
110
+ "spec/rails_best_practices/checks/use_observer_check_spec.rb",
111
+ "spec/rails_best_practices/checks/use_scope_access_check_spec.rb",
112
112
  "spec/spec_helper.rb"
113
113
  ]
114
114
 
@@ -167,5 +167,27 @@ describe RailsBestPractices::Checks::UseScopeAccessCheck do
167
167
  errors.should_not be_empty
168
168
  errors[0].to_s.should == "app/controllers/posts_controller.rb:6 - use scope access"
169
169
  end
170
+
171
+ it "should no error in use_scope_access_check" do
172
+ content = <<-EOF
173
+ class CommentsController < ApplicationController
174
+
175
+ def add_comment
176
+ @current_user = User.find_by_id(session[:user_id])
177
+ @id = params[:post_id]
178
+ @error = ""
179
+ if (@text = params[:text]) == ""
180
+ @error = "Please enter a comment!"
181
+ else
182
+ @comment = Comment.create_object(@text, @id, @current_user.id)
183
+ end
184
+ unless @comment
185
+ @error = "Comment could not be saved."
186
+ end
187
+ end
188
+ end
189
+ EOF
190
+ @runner.check('app/controllers/comments_controller.rb', content)
191
+ end
170
192
  end
171
193
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_best_practices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-13 00:00:00 +08:00
12
+ date: 2009-11-17 00:00:00 +08:00
13
13
  default_executable: rails_best_practices
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -133,25 +133,25 @@ signing_key:
133
133
  specification_version: 3
134
134
  summary: check rails files according to ihower's presentation 'rails best practices'
135
135
  test_files:
136
+ - spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
137
+ - spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
136
138
  - spec/rails_best_practices/checks/isolate_seed_data_check_spec.rb
137
- - spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb
138
- - spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
139
+ - spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb
140
+ - spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
141
+ - spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
139
142
  - spec/rails_best_practices/checks/move_code_into_controller_check_spec.rb
140
- - spec/rails_best_practices/checks/use_observer_check_spec.rb
141
- - spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb
143
+ - spec/rails_best_practices/checks/move_code_into_helper_check_spec.rb
144
+ - spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb
145
+ - spec/rails_best_practices/checks/move_model_logic_into_model_check_spec.rb
146
+ - spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb
142
147
  - spec/rails_best_practices/checks/nested_model_forms_check_spec.rb
143
- - spec/rails_best_practices/checks/use_filter_check_spec.rb
144
- - spec/rails_best_practices/checks/always_add_db_index_check_spec.rb
145
- - spec/rails_best_practices/checks/many_to_many_collection_check_spec.rb
146
- - spec/rails_best_practices/checks/law_of_demeter_check_spec.rb
147
- - spec/rails_best_practices/checks/use_scope_access_check_spec.rb
148
- - spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
149
148
  - spec/rails_best_practices/checks/not_use_default_route_check_spec.rb
150
- - spec/rails_best_practices/checks/move_finder_to_named_scope_check_spec.rb
151
- - spec/rails_best_practices/checks/use_model_callback_check_spec.rb
152
- - spec/rails_best_practices/checks/add_model_virtual_attribute_check_spec.rb
149
+ - spec/rails_best_practices/checks/overuse_route_customizations_check_spec.rb
150
+ - spec/rails_best_practices/checks/replace_complex_creation_with_factory_method_check_spec.rb
153
151
  - spec/rails_best_practices/checks/replace_instance_variable_with_local_variable_check_spec.rb
152
+ - spec/rails_best_practices/checks/use_filter_check_spec.rb
154
153
  - spec/rails_best_practices/checks/use_model_association_check_spec.rb
155
- - spec/rails_best_practices/checks/needless_deep_nesting_check_spec.rb
156
- - spec/rails_best_practices/checks/keep_finders_on_their_own_model_check_spec.rb
154
+ - spec/rails_best_practices/checks/use_model_callback_check_spec.rb
155
+ - spec/rails_best_practices/checks/use_observer_check_spec.rb
156
+ - spec/rails_best_practices/checks/use_scope_access_check_spec.rb
157
157
  - spec/spec_helper.rb