lol_dba 1.6.1 → 1.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f8f30bc53bf7278cad306997f434ba8de25169b
4
- data.tar.gz: 6420eeecffc2fcb69aca524eca6978d2e294a89d
3
+ metadata.gz: ed0a092881863ebd48f2561980814fa873e7140c
4
+ data.tar.gz: c5fba5c48943648577294aafc66d71dc8471e552
5
5
  SHA512:
6
- metadata.gz: bb7439613b407c72b0cc2d192a57fd291da192aa5835a7e6fbb2787f84834949774b50711838e675e5f21afce8cf741da7acd6cfd7282322ab87a134deeae78c
7
- data.tar.gz: ceb284d9f78a6c9821fca67586b6483c033b51e01473ae3f1a51ad9f07eb419db0336848a01c6af69923f175f87053b1b078b9b25adadd4b7a924a702a8425ae
6
+ metadata.gz: c36497910a4c76bdbd0b30bc4fa1f70ff3feb4219ea57e0af467197d1e9138c4906614d236ff54ab4a5e8191ed168948579faf45349ac8fd4e215526b1dd37a6
7
+ data.tar.gz: fc5fb00645da95082db6f39c30fe67956824510885bb792a326ea03cfd1f3c68590e23a25631acc5d278f007a2952a55f2fa905c2b153f6b555341ba5bfddb76
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .bundle
2
2
  .rvmrc
3
3
  .DS_Store
4
- .gem
4
+ .gem
5
+ .idea
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord'
4
- gem 'actionpack'
5
- gem 'railties'
3
+ gem 'rails'
6
4
  gem 'rspec-rails'
7
5
  gem 'sqlite3'
data/Gemfile.lock CHANGED
@@ -1,67 +1,99 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actionpack (4.0.0)
5
- activesupport (= 4.0.0)
6
- builder (~> 3.1.0)
7
- erubis (~> 2.7.0)
4
+ actionmailer (4.1.6)
5
+ actionpack (= 4.1.6)
6
+ actionview (= 4.1.6)
7
+ mail (~> 2.5, >= 2.5.4)
8
+ actionpack (4.1.6)
9
+ actionview (= 4.1.6)
10
+ activesupport (= 4.1.6)
8
11
  rack (~> 1.5.2)
9
12
  rack-test (~> 0.6.2)
10
- activemodel (4.0.0)
11
- activesupport (= 4.0.0)
12
- builder (~> 3.1.0)
13
- activerecord (4.0.0)
14
- activemodel (= 4.0.0)
15
- activerecord-deprecated_finders (~> 1.0.2)
16
- activesupport (= 4.0.0)
17
- arel (~> 4.0.0)
18
- activerecord-deprecated_finders (1.0.3)
19
- activesupport (4.0.0)
20
- i18n (~> 0.6, >= 0.6.4)
21
- minitest (~> 4.2)
22
- multi_json (~> 1.3)
13
+ actionview (4.1.6)
14
+ activesupport (= 4.1.6)
15
+ builder (~> 3.1)
16
+ erubis (~> 2.7.0)
17
+ activemodel (4.1.6)
18
+ activesupport (= 4.1.6)
19
+ builder (~> 3.1)
20
+ activerecord (4.1.6)
21
+ activemodel (= 4.1.6)
22
+ activesupport (= 4.1.6)
23
+ arel (~> 5.0.0)
24
+ activesupport (4.1.6)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
23
28
  thread_safe (~> 0.1)
24
- tzinfo (~> 0.3.37)
25
- arel (4.0.0)
26
- atomic (1.1.10)
27
- builder (3.1.4)
28
- diff-lcs (1.2.4)
29
+ tzinfo (~> 1.1)
30
+ arel (5.0.1.20140414130214)
31
+ builder (3.2.2)
32
+ diff-lcs (1.2.5)
29
33
  erubis (2.7.0)
30
- i18n (0.6.4)
31
- minitest (4.7.5)
32
- multi_json (1.7.7)
34
+ hike (1.2.3)
35
+ i18n (0.6.11)
36
+ json (1.8.1)
37
+ mail (2.6.1)
38
+ mime-types (>= 1.16, < 3)
39
+ mime-types (2.3)
40
+ minitest (5.4.1)
41
+ multi_json (1.10.1)
33
42
  rack (1.5.2)
34
43
  rack-test (0.6.2)
35
44
  rack (>= 1.0)
36
- railties (4.0.0)
37
- actionpack (= 4.0.0)
38
- activesupport (= 4.0.0)
45
+ rails (4.1.6)
46
+ actionmailer (= 4.1.6)
47
+ actionpack (= 4.1.6)
48
+ actionview (= 4.1.6)
49
+ activemodel (= 4.1.6)
50
+ activerecord (= 4.1.6)
51
+ activesupport (= 4.1.6)
52
+ bundler (>= 1.3.0, < 2.0)
53
+ railties (= 4.1.6)
54
+ sprockets-rails (~> 2.0)
55
+ railties (4.1.6)
56
+ actionpack (= 4.1.6)
57
+ activesupport (= 4.1.6)
39
58
  rake (>= 0.8.7)
40
59
  thor (>= 0.18.1, < 2.0)
41
- rake (10.1.0)
42
- rspec-core (2.14.4)
43
- rspec-expectations (2.14.0)
44
- diff-lcs (>= 1.1.3, < 2.0)
45
- rspec-mocks (2.14.1)
46
- rspec-rails (2.14.0)
60
+ rake (10.3.2)
61
+ rspec-core (3.1.4)
62
+ rspec-support (~> 3.1.0)
63
+ rspec-expectations (3.1.1)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.1.0)
66
+ rspec-mocks (3.1.1)
67
+ rspec-support (~> 3.1.0)
68
+ rspec-rails (3.1.0)
47
69
  actionpack (>= 3.0)
48
70
  activesupport (>= 3.0)
49
71
  railties (>= 3.0)
50
- rspec-core (~> 2.14.0)
51
- rspec-expectations (~> 2.14.0)
52
- rspec-mocks (~> 2.14.0)
53
- sqlite3 (1.3.7)
54
- thor (0.18.1)
55
- thread_safe (0.1.2)
56
- atomic
57
- tzinfo (0.3.37)
72
+ rspec-core (~> 3.1.0)
73
+ rspec-expectations (~> 3.1.0)
74
+ rspec-mocks (~> 3.1.0)
75
+ rspec-support (~> 3.1.0)
76
+ rspec-support (3.1.0)
77
+ sprockets (2.12.2)
78
+ hike (~> 1.2)
79
+ multi_json (~> 1.0)
80
+ rack (~> 1.0)
81
+ tilt (~> 1.1, != 1.3.0)
82
+ sprockets-rails (2.1.4)
83
+ actionpack (>= 3.0)
84
+ activesupport (>= 3.0)
85
+ sprockets (~> 2.8)
86
+ sqlite3 (1.3.9)
87
+ thor (0.19.1)
88
+ thread_safe (0.3.4)
89
+ tilt (1.4.1)
90
+ tzinfo (1.2.2)
91
+ thread_safe (~> 0.1)
58
92
 
59
93
  PLATFORMS
60
94
  ruby
61
95
 
62
96
  DEPENDENCIES
63
- actionpack
64
- activerecord
65
- railties
97
+ rails
66
98
  rspec-rails
67
99
  sqlite3
data/bin/lol_dba CHANGED
File without changes
data/lib/lol_dba.rb CHANGED
@@ -74,7 +74,7 @@ EOM
74
74
  end
75
75
 
76
76
  def self.check_for_indexes(migration_format = false)
77
- Dir.glob(Rails.root + "app/models/**/*.rb").sort.each {|file| require file }
77
+ Rails.application.eager_load! unless ENV["RAILS_ENV"] == 'test'
78
78
 
79
79
  model_classes = []
80
80
  ObjectSpace.each_object(Module) do |obj|
@@ -1,3 +1,3 @@
1
1
  module LolDba
2
- VERSION = "1.6.1" unless defined? LolDba::VERSION
2
+ VERSION = "1.6.2" unless defined? LolDba::VERSION
3
3
  end
@@ -7,64 +7,64 @@ describe "Collect indexes based on associations:" do
7
7
  let(:warning_messages){ lol_dba[1] }
8
8
 
9
9
  it "find relationship indexes" do
10
- relationship_indexes.should_not be_empty
10
+ expect(relationship_indexes).not_to be_empty
11
11
 
12
- relationship_indexes.should have_key("companies")
13
- relationship_indexes.should have_key("companies_freelancers")
14
- relationship_indexes.should have_key("addresses")
15
- relationship_indexes.should have_key("purchases")
12
+ expect(relationship_indexes).to have_key("companies")
13
+ expect(relationship_indexes).to have_key("companies_freelancers")
14
+ expect(relationship_indexes).to have_key("addresses")
15
+ expect(relationship_indexes).to have_key("purchases")
16
16
  end
17
17
 
18
18
  it "find indexes for belongs_to" do
19
- relationship_indexes["addresses"].should include("country_id")
19
+ expect(relationship_indexes["addresses"]).to include("country_id")
20
20
  end
21
21
 
22
22
  it "find indexes for belongs_to with custom foreign key" do
23
- relationship_indexes["companies"].should include("owner_id")
23
+ expect(relationship_indexes["companies"]).to include("owner_id")
24
24
  end
25
25
 
26
26
  it "find indexes for has_and_belongs_to_many" do
27
- relationship_indexes["companies_freelancers"].should include(["freelancer_id", "company_id"])
27
+ expect(relationship_indexes["companies_freelancers"]).to include(["freelancer_id", "company_id"])
28
28
  end
29
29
 
30
30
  it "find indexes for has_and_belongs_to_many with custom join_table, primary and foreign keys" do
31
- relationship_indexes["purchases"].should include(["present_id", "buyer_id"])
31
+ expect(relationship_indexes["purchases"]).to include(["present_id", "buyer_id"])
32
32
  end
33
33
 
34
34
  it "do not add an already existing index" do
35
- relationship_indexes["companies"].should_not include("country_id")
35
+ expect(relationship_indexes["companies"]).not_to include("country_id")
36
36
  end
37
37
 
38
38
  it "find indexes for has_many :through" do
39
- relationship_indexes["billable_weeks"].should include(["remote_worker_id", "timesheet_id"])
39
+ expect(relationship_indexes["billable_weeks"]).to include(["remote_worker_id", "timesheet_id"])
40
40
  end
41
41
 
42
42
  it "find indexes for has_many :through with source and foreign key" do
43
- relationship_indexes["complex_billable_week"].should include(["freelancer_id", "id_complex_timesheet"])
43
+ expect(relationship_indexes["complex_billable_week"]).to include(["freelancer_id", "id_complex_timesheet"])
44
44
  end
45
45
 
46
46
  it "do not include wrong class" do
47
- relationship_indexes["wrongs"].should be_nil
48
- relationship_indexes["addresses_wrongs"].should be_nil
47
+ expect(relationship_indexes["wrongs"]).to be_nil
48
+ expect(relationship_indexes["addresses_wrongs"]).to be_nil
49
49
  end
50
50
 
51
51
  it "have warnings(non-existent table) on test data" do
52
- warning_messages.should_not be_empty
53
- warning_messages.should =~ /\'wrongs\'/
54
- warning_messages.should =~ /\'addresses_wrongs\'/
52
+ expect(warning_messages).not_to be_empty
53
+ expect(warning_messages).to match(/\'wrongs\'/)
54
+ expect(warning_messages).to match(/\'addresses_wrongs\'/)
55
55
  end
56
56
 
57
57
  it "find indexes for STI" do
58
- relationship_indexes["users"].should include(["id", "type"])
58
+ expect(relationship_indexes["users"]).to include(["id", "type"])
59
59
  end
60
60
 
61
61
  it "find indexes for STI with custom inheritance column" do
62
- relationship_indexes["freelancers"].should include(["id", "worker_type"])
62
+ expect(relationship_indexes["freelancers"]).to include(["id", "worker_type"])
63
63
  end
64
64
 
65
65
  it "find indexes, than use custom class name option in association" do
66
- relationship_indexes["employers_freelancers"].should be_nil
67
- relationship_indexes["companies_freelancers"].should include(["freelancer_id", "company_id"])
66
+ expect(relationship_indexes["employers_freelancers"]).to be_nil
67
+ expect(relationship_indexes["companies_freelancers"]).to include(["freelancer_id", "company_id"])
68
68
  end
69
69
 
70
70
  end
@@ -7,15 +7,13 @@ describe "Function form_migration_content:" do
7
7
  end
8
8
 
9
9
  it "print migration skeleton with set name" do
10
- #$stdout.should_receive(:puts).with(/TestMigration/i)
11
10
  migration = LolDba.form_migration_content("TestMigration", @add)
12
- migration.should =~ /class TestMigration/i
11
+ expect(migration).to match(/class TestMigration/i)
13
12
  end
14
13
 
15
14
  it "print migration with add_keys params" do
16
- # $stdout.should_receive(:puts).with(/add_index :report, :_id_test_plan/i)
17
15
  migration = LolDba.form_migration_content("TestMigration", @add)
18
- migration.should =~ /add_index :report, :_id_test_plan/i
16
+ expect(migration).to match(/add_index :report, :_id_test_plan/i)
19
17
  end
20
18
  end
21
19
 
@@ -23,27 +21,27 @@ describe "Function form_data_for_migration:" do
23
21
 
24
22
  it "return data for migrations for non-indexed single key in table" do
25
23
  relationship_indexes = {:users => [:user_id]}
26
- LolDba.stub(:key_exists?).with(:users, :user_id).and_return(false)
24
+ allow(LolDba).to receive(:key_exists?).with(:users, :user_id).and_return(false)
27
25
 
28
26
  add_indexes = LolDba.form_data_for_migration(relationship_indexes)
29
27
 
30
- add_indexes.first.should == "add_index :users, :user_id"
28
+ expect(add_indexes.first).to eq("add_index :users, :user_id")
31
29
  end
32
30
 
33
31
  it "return data for migrations for non-indexed composite key in table" do
34
32
  relationship_indexes = {:friends => [[:user_id, :friend_id]]}
35
- LolDba.stub(:key_exists?).with(:friends, [:user_id, :friend_id]).and_return(false)
33
+ allow(LolDba).to receive(:key_exists?).with(:friends, [:user_id, :friend_id]).and_return(false)
36
34
 
37
35
  add_indexes = LolDba.form_data_for_migration(relationship_indexes)
38
36
 
39
- add_indexes.first.should == "add_index :friends, [:user_id, :friend_id]"
37
+ expect(add_indexes.first).to eq("add_index :friends, [:user_id, :friend_id]")
40
38
  end
41
39
 
42
40
  it "ignore empty or nil keys for table" do
43
41
  relationship_indexes = {:table => [""], :table2 => [nil]}
44
42
  add_indexes = LolDba.form_data_for_migration(relationship_indexes)
45
43
 
46
- add_indexes.should be_empty
44
+ expect(add_indexes).to be_empty
47
45
  end
48
46
 
49
47
  end
@@ -51,19 +49,19 @@ end
51
49
  describe "Function key_exists?:" do
52
50
 
53
51
  it "return true if key is already indexed" do
54
- LolDba.key_exists?("companies", "country_id").should be_true
52
+ expect(LolDba.key_exists?("companies", "country_id")).to be_truthy
55
53
  end
56
54
 
57
55
  it "return false if key is not indexed yet" do
58
- LolDba.key_exists?("addresses", "country_id").should be_false
56
+ expect(LolDba.key_exists?("addresses", "country_id")).to be_falsey
59
57
  end
60
58
 
61
59
  it "return true if key is primary key(default)" do
62
- LolDba.key_exists?("addresses", "id").should be_true
60
+ expect(LolDba.key_exists?("addresses", "id")).to be_truthy
63
61
  end
64
62
 
65
63
  it "return true if key is custom primary key" do
66
- LolDba.key_exists?("gifts", "custom_primary_key").should be_true
64
+ expect(LolDba.key_exists?("gifts", "custom_primary_key")).to be_truthy
67
65
  end
68
66
 
69
67
  end
@@ -75,23 +73,23 @@ describe "Function puts_migration_content:" do
75
73
  end
76
74
 
77
75
  it "print migration code" do
78
- $stdout.should_receive(:puts).with("")
79
- $stdout.should_receive(:puts).with(/TIP/)
80
- $stdout.should_receive(:puts).with(/TestMigration/i)
76
+ expect($stdout).to receive(:puts).with("")
77
+ expect($stdout).to receive(:puts).with(/TIP/)
78
+ expect($stdout).to receive(:puts).with(/TestMigration/i)
81
79
  LolDba.puts_migration_content("TestMigration", @relationship_indexes, "")
82
80
  end
83
81
 
84
82
  it "print warning messages if they exist" do
85
83
  warning = "warning text here"
86
- $stdout.should_receive(:puts).at_least(:once).with(warning)
87
- $stdout.should_receive(:puts)
84
+ expect($stdout).to receive(:puts).at_least(:once).with(warning)
85
+ expect($stdout).to receive(:puts)
88
86
 
89
87
  LolDba.puts_migration_content("TestMigration", {}, warning)
90
88
  end
91
89
 
92
90
  it "print nothing if no indexes and warning messages exist" do
93
- $stdout.should_receive(:puts).with("")
94
- $stdout.should_receive(:puts).with("Yey, no missing indexes found!")
91
+ expect($stdout).to receive(:puts).with("")
92
+ expect($stdout).to receive(:puts).with("Yey, no missing indexes found!")
95
93
  LolDba.puts_migration_content("TestMigration",{}, "")
96
94
  end
97
95
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,4 @@
1
- require 'active_record'
2
- require 'active_support'
3
- require 'action_controller'
1
+ require 'rails/all'
4
2
  require 'lol_dba'
5
3
  require 'rspec/rails'
6
4
 
@@ -16,7 +14,7 @@ module Rails
16
14
  "spec/fixtures/"
17
15
  end
18
16
  end
19
-
17
+ Dir.glob("#{Rails.root}/app/models/*.rb").sort.each { |file| require_dependency file }
20
18
  load 'fixtures/schema.rb'
21
19
 
22
20
  root_dir = File.dirname(__FILE__)
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.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Plentz
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-09-08 00:00:00.000000000 Z
15
+ date: 2014-09-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord