rails_best_practices 0.3.9 → 0.3.10

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.9
1
+ 0.3.10
@@ -31,16 +31,18 @@ module RailsBestPractices
31
31
  end
32
32
 
33
33
  def evaluate_start(node)
34
- if @files.include? node.file
35
- @parse = true if :up == node.message
36
- else
37
- @files << node.file
38
- end
34
+ if :up == node.message
35
+ if @files.include? node.file
36
+ @parse = true if :up == node.message
37
+ else
38
+ @files << node.file
39
+ end
39
40
 
40
- if @parse and :up == node.message
41
- check_references(node.body)
42
- else
43
- remember_indexes(node.body)
41
+ if @parse
42
+ check_references(node.body)
43
+ else
44
+ remember_indexes(node.body)
45
+ end
44
46
  end
45
47
  end
46
48
 
@@ -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.9"
8
+ s.version = "0.3.10"
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-26}
12
+ s.date = %q{2009-11-28}
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}
@@ -148,9 +148,53 @@ describe RailsBestPractices::Checks::AlwaysAddDbIndexCheck do
148
148
  end
149
149
  EOF
150
150
  @runner.check('db/migrate/20090918130258_create_comments.rb', content)
151
- @runner.check('db/migrate/20090919130258_add_indexes_to_comments.rb', add_index_content)
151
+ @runner.check('db/migrate/20090919130260_add_indexes_to_comments.rb', add_index_content)
152
152
  @runner.check('db/migrate/20090918130258_create_comments.rb', content)
153
- @runner.check('db/migrate/20090919130258_add_indexes_to_comments.rb', add_index_content)
153
+ @runner.check('db/migrate/20090919130260_add_indexes_to_comments.rb', add_index_content)
154
+ errors = @runner.errors
155
+ errors.should be_empty
156
+ end
157
+
158
+ it "should not always add db index with add_index in another migration file and a migration between them" do
159
+ content = <<-EOF
160
+ class CreateComments < ActiveRecord::Migration
161
+ def self.up
162
+ create_table "comments", :force => true do |t|
163
+ t.string :content
164
+ t.integer :post_id
165
+ t.integer :user_id
166
+ end
167
+ end
168
+
169
+ def self.down
170
+ drop_table "comments"
171
+ end
172
+ end
173
+ EOF
174
+ another_content = <<-EOF
175
+ class Settings < ActiveRecord::Migration
176
+ def self.my_escape(val)
177
+ end
178
+
179
+ def self.up
180
+ add_column :settings, :groep, :string, :limit => 50
181
+ end
182
+ end
183
+ EOF
184
+ add_index_content = <<-EOF
185
+ class AddIndexesToComments < ActiveRecord::Migration
186
+ def self.up
187
+ add_index :comments, :post_id
188
+ add_index :comments, :user_id
189
+ end
190
+ end
191
+ EOF
192
+ @runner.check('db/migrate/20090918140258_create_comments.rb', content)
193
+ @runner.check('db/migrate/20090918140259_settings.rb', another_content)
194
+ @runner.check('db/migrate/20090919140260_add_indexes_to_comments.rb', add_index_content)
195
+ @runner.check('db/migrate/20090918140258_create_comments.rb', content)
196
+ @runner.check('db/migrate/20090918140259_settings.rb', another_content)
197
+ @runner.check('db/migrate/20090919140260_add_indexes_to_comments.rb', add_index_content)
154
198
  errors = @runner.errors
155
199
  errors.should be_empty
156
200
  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.9
4
+ version: 0.3.10
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-26 00:00:00 +08:00
12
+ date: 2009-11-28 00:00:00 +08:00
13
13
  default_executable: rails_best_practices
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency