Skip to content

Commit d732947

Browse files
committed
update rails_best_practices/always_add_db_index description
1 parent 902258c commit d732947

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/rails_best_practices/always_add_db_index.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Synvert::Rewriter.new 'rails_best_practices', 'always_add_db_index' do
44
description <<~EOS
5+
Review db/schema.rb file to make sure every reference key has a database index.
6+
7+
See the best practice details here https://rails-bestpractices.com/posts/2010/07/24/always-add-db-index/
58
EOS
69

710
call_helper 'rails/parse'

spec/rails_best_practices/always_add_db_index_spec.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe 'Rails always add db index' do
5+
RSpec.describe 'Rails Best Practices always add db index' do
66
before { load_helpers(%w[helpers/parse_rails]) }
77

88
context 'index exists' do
@@ -100,9 +100,7 @@ class Picture < ApplicationRecord
100100
belongs_to :imageable, polymorphic: true
101101
end
102102
EOF
103-
let(:warnings) { [
104-
'/db/schema.rb#6: always add db index pictures => ["imageable_type", "imageable_id"]',
105-
] }
103+
let(:warnings) { ['/db/schema.rb#6: always add db index pictures => ["imageable_type", "imageable_id"]'] }
106104

107105
include_examples 'warnable'
108106
end
@@ -124,9 +122,7 @@ class Comment < ApplicationRecord
124122
belongs_to :commentor, foreign_key: :user_id
125123
end
126124
EOF
127-
let(:warnings) { [
128-
'/db/schema.rb#6: always add db index comments => ["user_id"]'
129-
] }
125+
let(:warnings) { ['/db/schema.rb#6: always add db index comments => ["user_id"]'] }
130126

131127
include_examples 'warnable'
132128
end

0 commit comments

Comments
 (0)