consistency_fail 0.3.1 → 0.3.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.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -19,6 +19,7 @@ constraint. You'll need a database-level constraint for cases like these.
19
19
  consistency_fail will find your missing unique indexes, so you can add them and
20
20
  stop ignoring the C in ACID.
21
21
  EOF
22
+ s.license = "MIT"
22
23
 
23
24
  s.add_development_dependency "activerecord", "~>3.0"
24
25
  s.add_development_dependency "rspec"
@@ -12,9 +12,14 @@ module ConsistencyFail
12
12
  # TODO: handle has_one :through cases (multicolumn index on the join table?)
13
13
  def desired_indexes(model)
14
14
  instances(model).map do |a|
15
+ if a.respond_to?(:foreign_key)
16
+ foreign_key = a.foreign_key
17
+ else
18
+ foreign_key = a.primary_key_name
19
+ end
15
20
  ConsistencyFail::Index.new(a.class_name.constantize,
16
21
  a.table_name.to_s,
17
- [a.foreign_key])
22
+ [foreign_key])
18
23
  end.compact
19
24
  end
20
25
  private :desired_indexes
@@ -12,7 +12,7 @@ module ConsistencyFail
12
12
  end
13
13
 
14
14
  def dirs
15
- load_path.select { |lp| MODEL_DIRECTORY_REGEXP =~ lp }
15
+ load_path.select { |lp| MODEL_DIRECTORY_REGEXP =~ lp.to_s }
16
16
  end
17
17
 
18
18
  def preload_all
@@ -1,3 +1,3 @@
1
1
  module ConsistencyFail
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -60,6 +60,14 @@ describe ConsistencyFail::Introspectors::HasOne do
60
60
  indexes.should == [ConsistencyFail::Index.new(fake_ar_model("Address"), "addresses", ["user_id"])]
61
61
  end
62
62
 
63
+ it "finds one in Rails 3.0.x (where foreign_key is not defined)" do
64
+ @association.stub!(:table_name => :addresses, :class_name => @address_string, :primary_key_name => "user_id")
65
+ @address_class.stub_chain(:connection, :indexes).with("addresses").and_return([])
66
+
67
+ indexes = subject.missing_indexes(@model)
68
+ indexes.should == [ConsistencyFail::Index.new(fake_ar_model("Address"), "addresses", ["user_id"])]
69
+ end
70
+
63
71
  it "finds none when they're already in place" do
64
72
  @association.stub!(:table_name => :addresses, :class_name => @address_string, :foreign_key => "user_id")
65
73
  index = ConsistencyFail::Index.new(double('model'), "addresses", ["user_id"])
data/spec/models_spec.rb CHANGED
@@ -15,6 +15,12 @@ describe ConsistencyFail::Models do
15
15
  models.dirs.should == ["app/models", "some/other/models"]
16
16
  end
17
17
 
18
+ it "accepts and matches path names as well as strings" do
19
+ models = models([Pathname.new("app/models")])
20
+ lambda { models.dirs }.should_not raise_error(TypeError)
21
+ models.dirs.should == [Pathname.new("app/models")]
22
+ end
23
+
18
24
  it "preloads models by calling require_dependency" do
19
25
  models = models(["foo/bar/baz", "app/models", "some/other/models"])
20
26
  Dir.stub(:glob).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consistency_fail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-18 00:00:00.000000000 Z
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -66,6 +66,7 @@ extensions: []
66
66
  extra_rdoc_files: []
67
67
  files:
68
68
  - .gitignore
69
+ - .rspec
69
70
  - Gemfile
70
71
  - LICENSE
71
72
  - README.md
@@ -95,7 +96,8 @@ files:
95
96
  - spec/reporter_spec.rb
96
97
  - spec/spec_helper.rb
97
98
  homepage: http://github.com/trptcolin/consistency_fail
98
- licenses: []
99
+ licenses:
100
+ - MIT
99
101
  post_install_message:
100
102
  rdoc_options: []
101
103
  require_paths: