lol_dba 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -3
- data/Gemfile.lock +40 -42
- data/lib/lol_dba.rb +17 -22
- data/lib/lol_dba/sql_generator.rb +9 -9
- data/lib/lol_dba/version.rb +1 -1
- data/lol_dba.gemspec +0 -2
- data/spec/associations_index_spec.rb +1 -1
- data/spec/common_function_spec.rb +8 -17
- data/spec/fixtures/app/models/complex_billable_week.rb +2 -2
- data/spec/fixtures/app/models/complex_timesheet.rb +1 -1
- data/spec/fixtures/app/models/freelancer.rb +1 -1
- data/spec/fixtures/app/models/gift.rb +1 -1
- data/spec/fixtures/app/models/timesheet.rb +1 -1
- data/spec/spec_helper.rb +3 -24
- metadata +3 -38
- data/.rspec +0 -2
- data/spec/ar_find_index_spec.rb +0 -33
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (3.2.
|
5
|
-
activemodel (= 3.2.
|
6
|
-
activesupport (= 3.2.
|
4
|
+
actionpack (3.2.9)
|
5
|
+
activemodel (= 3.2.9)
|
6
|
+
activesupport (= 3.2.9)
|
7
7
|
builder (~> 3.0.0)
|
8
8
|
erubis (~> 2.7.0)
|
9
|
-
journey (~> 1.0.
|
9
|
+
journey (~> 1.0.4)
|
10
10
|
rack (~> 1.4.0)
|
11
|
-
rack-cache (~> 1.
|
11
|
+
rack-cache (~> 1.2)
|
12
12
|
rack-test (~> 0.6.1)
|
13
|
-
sprockets (~> 2.1
|
14
|
-
activemodel (3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
sprockets (~> 2.2.1)
|
14
|
+
activemodel (3.2.9)
|
15
|
+
activesupport (= 3.2.9)
|
16
16
|
builder (~> 3.0.0)
|
17
|
-
activerecord (3.2.
|
18
|
-
activemodel (= 3.2.
|
19
|
-
activesupport (= 3.2.
|
17
|
+
activerecord (3.2.9)
|
18
|
+
activemodel (= 3.2.9)
|
19
|
+
activesupport (= 3.2.9)
|
20
20
|
arel (~> 3.0.2)
|
21
21
|
tzinfo (~> 0.3.29)
|
22
|
-
activesupport (3.2.
|
22
|
+
activesupport (3.2.9)
|
23
23
|
i18n (~> 0.6)
|
24
24
|
multi_json (~> 1.0)
|
25
25
|
arel (3.0.2)
|
26
|
-
builder (3.0.
|
26
|
+
builder (3.0.4)
|
27
27
|
diff-lcs (1.1.3)
|
28
28
|
erubis (2.7.0)
|
29
29
|
hike (1.2.1)
|
30
|
-
i18n (0.6.
|
31
|
-
journey (1.0.
|
32
|
-
json (1.
|
33
|
-
multi_json (1.
|
30
|
+
i18n (0.6.1)
|
31
|
+
journey (1.0.4)
|
32
|
+
json (1.7.5)
|
33
|
+
multi_json (1.5.0)
|
34
34
|
rack (1.4.1)
|
35
35
|
rack-cache (1.2)
|
36
36
|
rack (>= 0.4)
|
37
37
|
rack-ssl (1.3.2)
|
38
38
|
rack
|
39
|
-
rack-test (0.6.
|
39
|
+
rack-test (0.6.2)
|
40
40
|
rack (>= 1.0)
|
41
|
-
railties (3.2.
|
42
|
-
actionpack (= 3.2.
|
43
|
-
activesupport (= 3.2.
|
41
|
+
railties (3.2.9)
|
42
|
+
actionpack (= 3.2.9)
|
43
|
+
activesupport (= 3.2.9)
|
44
44
|
rack-ssl (~> 1.3.2)
|
45
45
|
rake (>= 0.8.7)
|
46
46
|
rdoc (~> 3.4)
|
47
|
-
thor (
|
48
|
-
rake (0.
|
47
|
+
thor (>= 0.14.6, < 2.0)
|
48
|
+
rake (10.0.3)
|
49
49
|
rdoc (3.12)
|
50
50
|
json (~> 1.4)
|
51
|
-
rspec (2.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
rspec-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
sprockets (2.1.2)
|
51
|
+
rspec-core (2.12.2)
|
52
|
+
rspec-expectations (2.12.1)
|
53
|
+
diff-lcs (~> 1.1.3)
|
54
|
+
rspec-mocks (2.12.0)
|
55
|
+
rspec-rails (2.12.0)
|
56
|
+
actionpack (>= 3.0)
|
57
|
+
activesupport (>= 3.0)
|
58
|
+
railties (>= 3.0)
|
59
|
+
rspec-core (~> 2.12.0)
|
60
|
+
rspec-expectations (~> 2.12.0)
|
61
|
+
rspec-mocks (~> 2.12.0)
|
62
|
+
sprockets (2.2.2)
|
64
63
|
hike (~> 1.2)
|
64
|
+
multi_json (~> 1.0)
|
65
65
|
rack (~> 1.0)
|
66
66
|
tilt (~> 1.1, != 1.3.0)
|
67
|
-
sqlite3 (1.3.
|
68
|
-
thor (0.
|
67
|
+
sqlite3 (1.3.6)
|
68
|
+
thor (0.16.0)
|
69
69
|
tilt (1.3.3)
|
70
|
-
tzinfo (0.3.
|
70
|
+
tzinfo (0.3.35)
|
71
71
|
|
72
72
|
PLATFORMS
|
73
73
|
ruby
|
@@ -76,7 +76,5 @@ DEPENDENCIES
|
|
76
76
|
actionpack
|
77
77
|
activerecord
|
78
78
|
railties
|
79
|
-
rspec
|
80
|
-
simplecov
|
81
|
-
simplecov-html
|
79
|
+
rspec-rails
|
82
80
|
sqlite3
|
data/lib/lol_dba.rb
CHANGED
@@ -4,18 +4,14 @@ module LolDba
|
|
4
4
|
require "lol_dba/migration"
|
5
5
|
require "lol_dba/railtie.rb" if defined?(Rails)
|
6
6
|
|
7
|
-
def self.form_migration_content(migration_name,
|
7
|
+
def self.form_migration_content(migration_name, index_array)
|
8
8
|
migration = <<EOM
|
9
9
|
## run `rails g migration AddMissingIndexes` and add the following content
|
10
10
|
|
11
11
|
|
12
12
|
class #{migration_name} < ActiveRecord::Migration
|
13
|
-
def
|
14
|
-
#{
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.down
|
18
|
-
#{del_index_array.uniq.join("\n ")}
|
13
|
+
def change
|
14
|
+
#{index_array.uniq.join("\n ")}
|
19
15
|
end
|
20
16
|
end
|
21
17
|
EOM
|
@@ -62,7 +58,6 @@ EOM
|
|
62
58
|
|
63
59
|
def self.form_data_for_migration(missing_indexes)
|
64
60
|
add = []
|
65
|
-
remove = []
|
66
61
|
missing_indexes.each do |table_name, keys_to_add|
|
67
62
|
keys_to_add.each do |key|
|
68
63
|
next if key.blank?
|
@@ -70,14 +65,12 @@ EOM
|
|
70
65
|
if key.is_a?(Array)
|
71
66
|
keys = key.collect {|k| ":#{k}"}
|
72
67
|
add << "add_index :#{table_name}, [#{keys.join(', ')}]"
|
73
|
-
remove << "remove_index :#{table_name}, :column => [#{keys.join(', ')}]"
|
74
68
|
else
|
75
69
|
add << "add_index :#{table_name}, :#{key}"
|
76
|
-
remove << "remove_index :#{table_name}, :#{key}"
|
77
70
|
end
|
78
71
|
end
|
79
72
|
end
|
80
|
-
return add
|
73
|
+
return add
|
81
74
|
end
|
82
75
|
|
83
76
|
def self.check_for_indexes(migration_format = false)
|
@@ -132,12 +125,13 @@ EOM
|
|
132
125
|
# has_many tables are threaten by the other side of the relation
|
133
126
|
next unless reflection_options.options[:through]
|
134
127
|
|
135
|
-
|
128
|
+
association_clazz = class_name.reflections[reflection_options.options[:through]].klass
|
129
|
+
table_name = association_clazz.table_name
|
136
130
|
|
137
131
|
foreign_key = get_through_foreign_key(class_name, reflection_options)
|
138
132
|
|
139
133
|
if reflection_options.options[:source]
|
140
|
-
association_class = reflection_options.options[:source].
|
134
|
+
association_class = association_clazz.reflections[reflection_options.options[:source]].klass
|
141
135
|
association_foreign_key = get_through_foreign_key(association_class, reflection_options)
|
142
136
|
else
|
143
137
|
# go to joining model through has_many and find belongs_to
|
@@ -164,13 +158,14 @@ EOM
|
|
164
158
|
@index_migrations[table_name] += [composite_keys.reverse] unless @index_migrations[table_name].include?(composite_keys.reverse)
|
165
159
|
end
|
166
160
|
rescue Exception => e
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
161
|
+
puts "Some errors here:"
|
162
|
+
puts "Please, create an issue with the following information here https://github.com/plentz/lol_dba/issues:"
|
163
|
+
puts "***************************"
|
164
|
+
puts "Class: #{class_name}"
|
165
|
+
puts "Association type: #{reflection_options.macro}"
|
166
|
+
puts "Association options: #{reflection_options.options}"
|
167
|
+
puts "Exception: #{e.message}"
|
168
|
+
e.backtrace.each{|trace| puts trace}
|
174
169
|
end
|
175
170
|
end # case end
|
176
171
|
end # each_pair end
|
@@ -191,8 +186,8 @@ EOM
|
|
191
186
|
if indexes.keys.empty?
|
192
187
|
puts "Yey, no missing indexes found!"
|
193
188
|
else
|
194
|
-
add
|
195
|
-
puts form_migration_content(migration_name, add
|
189
|
+
add = form_data_for_migration(indexes)
|
190
|
+
puts form_migration_content(migration_name, add)
|
196
191
|
end
|
197
192
|
end
|
198
193
|
|
@@ -12,14 +12,14 @@ module LolDba
|
|
12
12
|
|
13
13
|
def redefine_execute_methods
|
14
14
|
save_original_methods
|
15
|
-
connection.class.send(:define_method, :execute) {|*args| Writer.write(args.first) }
|
16
|
-
connection.class.send(:define_method, :do_execute) {|*args| Writer.write(args.first) }
|
17
|
-
connection.class.send(:define_method, :column_for) {|*args| args.last }
|
18
|
-
connection.class.send(:define_method, :change_column) {|*args| [] }
|
19
|
-
connection.class.send(:define_method, :rename_column) {|*args| [] }
|
20
|
-
connection.class.send(:define_method, :tables) {|*args| [] }
|
21
|
-
connection.class.send(:define_method, :select_all) {|*args| [] }
|
22
|
-
connection.class.send(:define_method, :indexes) {|*args| [] }
|
15
|
+
connection.class.send(:define_method, :execute) { |*args| Writer.write(args.first) }
|
16
|
+
connection.class.send(:define_method, :do_execute) { |*args| Writer.write(args.first) }
|
17
|
+
connection.class.send(:define_method, :column_for) { |*args| args.last }
|
18
|
+
connection.class.send(:define_method, :change_column) { |*args| [] }
|
19
|
+
connection.class.send(:define_method, :rename_column) { |*args| [] }
|
20
|
+
connection.class.send(:define_method, :tables) { |*args| [] }
|
21
|
+
connection.class.send(:define_method, :select_all) { |*args| [] }
|
22
|
+
connection.class.send(:define_method, :indexes) { |*args| [] }
|
23
23
|
end
|
24
24
|
|
25
25
|
def save_original_methods
|
@@ -46,7 +46,7 @@ module LolDba
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def generate
|
49
|
-
generate_instead_of_executing { migrations.each{|file| up_and_down(file) } }
|
49
|
+
generate_instead_of_executing { migrations.each { |file| up_and_down(file) } }
|
50
50
|
end
|
51
51
|
|
52
52
|
def up_and_down(file)
|
data/lib/lol_dba/version.rb
CHANGED
data/lol_dba.gemspec
CHANGED
@@ -4,27 +4,19 @@ describe "Function form_migration_content:" do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@add = ["add_index :report, :_id_test_plan"]
|
7
|
-
@remove = ["remove_index :report, :_id_test_plan"]
|
8
7
|
end
|
9
8
|
|
10
9
|
it "print migration skeleton with set name" do
|
11
10
|
#$stdout.should_receive(:puts).with(/TestMigration/i)
|
12
|
-
migration = LolDba.form_migration_content("TestMigration", @add
|
11
|
+
migration = LolDba.form_migration_content("TestMigration", @add)
|
13
12
|
migration.should =~ /class TestMigration/i
|
14
13
|
end
|
15
14
|
|
16
15
|
it "print migration with add_keys params" do
|
17
16
|
# $stdout.should_receive(:puts).with(/add_index :report, :_id_test_plan/i)
|
18
|
-
migration = LolDba.form_migration_content("TestMigration", @add
|
17
|
+
migration = LolDba.form_migration_content("TestMigration", @add)
|
19
18
|
migration.should =~ /add_index :report, :_id_test_plan/i
|
20
19
|
end
|
21
|
-
|
22
|
-
it "print migration with remove_keys params" do
|
23
|
-
# $stdout.should_receive(:puts).with(/remove_index :report, :_id_test_plan/i)
|
24
|
-
migration = LolDba.form_migration_content("TestMigration", @add, @remove)
|
25
|
-
migration.should =~ /remove_index :report, :_id_test_plan/i
|
26
|
-
end
|
27
|
-
|
28
20
|
end
|
29
21
|
|
30
22
|
describe "Function form_data_for_migration:" do
|
@@ -33,28 +25,25 @@ describe "Function form_data_for_migration:" do
|
|
33
25
|
relationship_indexes = {:users => [:user_id]}
|
34
26
|
LolDba.stub(:key_exists?).with(:users, :user_id).and_return(false)
|
35
27
|
|
36
|
-
add_indexes
|
28
|
+
add_indexes = LolDba.form_data_for_migration(relationship_indexes)
|
37
29
|
|
38
30
|
add_indexes.first.should == "add_index :users, :user_id"
|
39
|
-
remove_indexes.first.should == "remove_index :users, :user_id"
|
40
31
|
end
|
41
32
|
|
42
33
|
it "return data for migrations for non-indexed composite key in table" do
|
43
34
|
relationship_indexes = {:friends => [[:user_id, :friend_id]]}
|
44
35
|
LolDba.stub(:key_exists?).with(:friends, [:user_id, :friend_id]).and_return(false)
|
45
36
|
|
46
|
-
add_indexes
|
37
|
+
add_indexes = LolDba.form_data_for_migration(relationship_indexes)
|
47
38
|
|
48
39
|
add_indexes.first.should == "add_index :friends, [:user_id, :friend_id]"
|
49
|
-
remove_indexes.first.should == "remove_index :friends, :column => [:user_id, :friend_id]"
|
50
40
|
end
|
51
41
|
|
52
42
|
it "ignore empty or nil keys for table" do
|
53
43
|
relationship_indexes = {:table => [""], :table2 => [nil]}
|
54
|
-
add_indexes
|
44
|
+
add_indexes = LolDba.form_data_for_migration(relationship_indexes)
|
55
45
|
|
56
46
|
add_indexes.should be_empty
|
57
|
-
remove_indexes.should be_empty
|
58
47
|
end
|
59
48
|
|
60
49
|
end
|
@@ -93,13 +82,15 @@ describe "Function puts_migration_content:" do
|
|
93
82
|
|
94
83
|
it "print warning messages if they exist" do
|
95
84
|
warning = "warning text here"
|
96
|
-
$stdout.should_receive(:puts).with(
|
85
|
+
$stdout.should_receive(:puts).at_least(:once).with(warning)
|
86
|
+
$stdout.should_receive(:puts)
|
97
87
|
|
98
88
|
LolDba.puts_migration_content("TestMigration", {}, warning)
|
99
89
|
end
|
100
90
|
|
101
91
|
it "print nothing if no indexes and warning messages exist" do
|
102
92
|
$stdout.should_receive(:puts).with("")
|
93
|
+
$stdout.should_receive(:puts).with("Yey, no missing indexes found!")
|
103
94
|
LolDba.puts_migration_content("TestMigration",{}, "")
|
104
95
|
end
|
105
96
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class ComplexBillableWeek < ActiveRecord::Base
|
2
2
|
# Use for testing custom has_many :through
|
3
3
|
|
4
|
-
|
4
|
+
self.table_name = :complex_billable_week
|
5
5
|
|
6
|
-
belongs_to :
|
6
|
+
belongs_to :slave, :class_name => 'Freelancer'
|
7
7
|
belongs_to :complex_timesheet, :foreign_key => :id_complex_timesheet
|
8
8
|
|
9
9
|
end
|
@@ -2,6 +2,6 @@ class ComplexTimesheet < ActiveRecord::Base
|
|
2
2
|
# Use for testing custom has_many :through
|
3
3
|
|
4
4
|
has_many :complex_billable_weeks, :foreign_key => :id_complex_timesheet
|
5
|
-
has_many :workers, :through => :complex_billable_weeks, :source => :
|
5
|
+
has_many :workers, :through => :complex_billable_weeks, :source => :slave
|
6
6
|
|
7
7
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Gift < ActiveRecord::Base
|
2
2
|
|
3
|
-
|
3
|
+
self.primary_key = :custom_primary_key
|
4
4
|
has_and_belongs_to_many :users, :join_table => "purchases", :association_foreign_key => 'buyer_id', :foreign_key => 'present_id'
|
5
5
|
|
6
6
|
def search_all(name, price)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,21 +1,10 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
SimpleCov.adapters.define 'lol_dba' do
|
4
|
-
add_group 'Libraries', 'lib'
|
5
|
-
|
6
|
-
add_filter 'spec'
|
7
|
-
end
|
8
|
-
|
9
|
-
SimpleCov.start 'lol_dba'
|
10
|
-
|
11
|
-
require 'rubygems'
|
12
|
-
require 'bundler/setup'
|
13
|
-
|
14
1
|
require 'active_record'
|
15
2
|
require 'active_support'
|
16
3
|
require 'action_controller'
|
17
|
-
|
18
4
|
require 'lol_dba'
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
ENV["RAILS_ENV"] ||= 'test'
|
19
8
|
|
20
9
|
ActiveRecord::Base.establish_connection(
|
21
10
|
:adapter => "sqlite3",
|
@@ -28,14 +17,8 @@ class Rails
|
|
28
17
|
end
|
29
18
|
end
|
30
19
|
|
31
|
-
RSpec.configure do |config|
|
32
|
-
# some (optional) config here
|
33
|
-
#config.fixture_path = "spec/fixtures"
|
34
|
-
end
|
35
|
-
|
36
20
|
load 'fixtures/schema.rb'
|
37
21
|
|
38
|
-
|
39
22
|
root_dir = File.dirname(__FILE__)
|
40
23
|
|
41
24
|
# Load models
|
@@ -43,7 +26,3 @@ Dir["#{root_dir}/fixtures/app/models/**/*.rb"].each { |f| require f}
|
|
43
26
|
|
44
27
|
# load controllers
|
45
28
|
Dir["#{root_dir}/fixtures/app/controllers/**/*.rb"].each { |f| require f}
|
46
|
-
|
47
|
-
SimpleCov.at_exit do
|
48
|
-
SimpleCov.result.format!
|
49
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lol_dba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-
|
16
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activerecord
|
@@ -63,38 +63,6 @@ dependencies:
|
|
63
63
|
- - ! '>='
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '3.0'
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: sqlite3
|
68
|
-
requirement: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - ! '>='
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
|
-
requirements:
|
79
|
-
- - ! '>='
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: rspec
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ! '>='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
98
66
|
description: lol_dba is a small package of rake tasks that scan your application models
|
99
67
|
and displays a list of columns that probably should be indexed. Also, it can generate
|
100
68
|
.sql migration scripts.
|
@@ -108,7 +76,6 @@ extensions: []
|
|
108
76
|
extra_rdoc_files: []
|
109
77
|
files:
|
110
78
|
- .gitignore
|
111
|
-
- .rspec
|
112
79
|
- Gemfile
|
113
80
|
- Gemfile.lock
|
114
81
|
- README.md
|
@@ -121,7 +88,6 @@ files:
|
|
121
88
|
- lib/lol_dba/writer.rb
|
122
89
|
- lib/tasks/lol_dba.rake
|
123
90
|
- lol_dba.gemspec
|
124
|
-
- spec/ar_find_index_spec.rb
|
125
91
|
- spec/associations_index_spec.rb
|
126
92
|
- spec/common_function_spec.rb
|
127
93
|
- spec/fixtures/app/controllers/cats_controller.rb
|
@@ -163,13 +129,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
129
|
version: '0'
|
164
130
|
requirements: []
|
165
131
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.8.
|
132
|
+
rubygems_version: 1.8.24
|
167
133
|
signing_key:
|
168
134
|
specification_version: 3
|
169
135
|
summary: A small package of rake tasks to track down missing database indexes and
|
170
136
|
generate sql migration scripts
|
171
137
|
test_files:
|
172
|
-
- spec/ar_find_index_spec.rb
|
173
138
|
- spec/associations_index_spec.rb
|
174
139
|
- spec/common_function_spec.rb
|
175
140
|
- spec/fixtures/app/controllers/cats_controller.rb
|
data/.rspec
DELETED
data/spec/ar_find_index_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Collect indexes based on AR::Base.find calls:" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@find_by_indexes, @warning_messages = LolDba.ar_find_indexes(false)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "not show indexes for primary keys" do
|
10
|
-
@find_by_indexes["users"].should_not include("id")
|
11
|
-
@find_by_indexes["gifts"].should_not include("custom_primary_key")
|
12
|
-
@find_by_indexes["freelancers"].should_not include("id")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "find_by indexes for self.find_by_email_and_name" do
|
16
|
-
@find_by_indexes["users"].should include(["email", "name"])
|
17
|
-
@find_by_indexes["users"].should include(["name", "email"])
|
18
|
-
end
|
19
|
-
|
20
|
-
it "find_by indexes for Gift.find_all_by_name_and_price" do
|
21
|
-
@find_by_indexes["gifts"].should include(["name", "price"])
|
22
|
-
@find_by_indexes["gifts"].should include(["price", "name"])
|
23
|
-
end
|
24
|
-
|
25
|
-
it "find_by indexes from UsersController" do
|
26
|
-
@find_by_indexes["freelancers"].should include("name")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "do not have warning on test data" do
|
30
|
-
@warning_messages.should be_empty
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|