low_card_tables 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGE2MGZlMWQ4YzViMjI3OWNmYjU2ZTUwN2Y0YjJiMzVhMGM3MTVmMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzY1YzdhODVlZmJmMzQ3MWQ3MjA0OTcyNGI1YjE5ZTU2NzhmYjRhNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGM4YTRiMWMzODdjODQ5OTZiZmRjYmZhMzAzZWJlNTZhNGQwOGYyZTQyOTFm
|
10
|
+
MmIxOThiMTFhYzMzMGNlZDg0YmViODE0MGM3YzJiNTU0YjA2YTJmOGYwNDNk
|
11
|
+
NmZjMWJjNmY4NGE5Y2M5NTAzZjkyNTBiNDIxYTA3NWY2ZTM1ZmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzAxN2RmZDJiOGZkOTNhNDM0NjRjNzI1NDBjN2I0MzhiOWIxYzczYjVmNThh
|
14
|
+
ZmFlZWNmNThkNGFhZGJlZWU0MTg0MTNjMjA3MTBmZWMzYWI1NTE5YWRhYzBi
|
15
|
+
M2ZkZWMyZjc4YjI0ZjcwM2FlYzFmNDVkYzU2MDNhYjFkMjY1MmY=
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# `low_card_tables` Changelog
|
2
2
|
|
3
|
-
## 1.0.
|
3
|
+
## 1.0.2, 2014-07-24
|
4
|
+
|
5
|
+
* Fixed an issue where, if someone had defined an `ActiveRecord::Base` subclass with a `nil` `table_name`, migrations
|
6
|
+
would fail.
|
7
|
+
|
8
|
+
## 1.0.1, 2014-07-07
|
4
9
|
|
5
10
|
* Fixed an issue where you couldn't migrate a low-card column into existence with a migration — because if you
|
6
11
|
declared a low-card column that didn't exist, you'd immediately receive an error. Now this works properly.
|
@@ -210,7 +210,8 @@ module LowCardTables
|
|
210
210
|
# Make sure we load all models
|
211
211
|
::Rails.application.eager_load! if defined?(::Rails) && ::Rails.respond_to?(:application) && ::Rails.application && ::Rails.application.respond_to?(:eager_load!)
|
212
212
|
out = ::ActiveRecord::Base.descendants.detect do |klass|
|
213
|
-
klass.table_name
|
213
|
+
klass.table_name &&
|
214
|
+
klass.table_name.strip.downcase == table_name.to_s.strip.downcase &&
|
214
215
|
klass.is_low_card_table? &&
|
215
216
|
klass.name && klass.name.strip.length > 0
|
216
217
|
end
|
@@ -59,6 +59,18 @@ describe "LowCardTables migration support" do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
it "should not blow up if there's an ActiveRecord subclass around that has no table name" do
|
63
|
+
define_model_class(:TableWithoutName, nil) { }
|
64
|
+
|
65
|
+
migrate do
|
66
|
+
create_table :non_low_card_table do |t|
|
67
|
+
t.string :name
|
68
|
+
end
|
69
|
+
|
70
|
+
drop_table :non_low_card_table
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
62
74
|
it "should handle schema changes to the low-card table" do
|
63
75
|
tn = @table_name
|
64
76
|
migrate do
|
@@ -80,16 +80,16 @@ describe LowCardTables::ActiveRecord::Migrations do
|
|
80
80
|
|
81
81
|
context "with mock low-card model" do
|
82
82
|
before :each do
|
83
|
-
non_low_card_class = Object.new
|
83
|
+
@non_low_card_class = Object.new
|
84
84
|
@low_card_class = Object.new
|
85
85
|
|
86
|
-
|
87
|
-
|
86
|
+
allow(@non_low_card_class).to receive(:table_name).and_return('bar')
|
87
|
+
allow(@low_card_class).to receive(:table_name).and_return('foo')
|
88
88
|
|
89
89
|
expect(@low_card_class).to receive(:is_low_card_table?).and_return(true)
|
90
90
|
expect(@low_card_class).to receive(:name).at_least(:once).and_return('Whatever')
|
91
91
|
|
92
|
-
expect(::ActiveRecord::Base).to receive(:descendants).and_return([ non_low_card_class, @low_card_class ])
|
92
|
+
expect(::ActiveRecord::Base).to receive(:descendants).and_return([ @non_low_card_class, @low_card_class ])
|
93
93
|
end
|
94
94
|
|
95
95
|
%w{add_column remove_column create_table change_table}.each do |method_name|
|
@@ -127,6 +127,22 @@ describe LowCardTables::ActiveRecord::Migrations do
|
|
127
127
|
out
|
128
128
|
end
|
129
129
|
|
130
|
+
it "should not fail if there's an ActiveRecord subclass around with no table_name" do
|
131
|
+
allow(@non_low_card_class).to receive(:table_name).and_return(nil)
|
132
|
+
|
133
|
+
expect(@low_card_class).to receive(:low_card_remove_unique_index!).once.ordered
|
134
|
+
|
135
|
+
expect(@low_card_class).to receive(:reset_column_information).at_least(2).times.ordered
|
136
|
+
expect(@low_card_class).to receive(:low_card_value_column_names).twice.ordered.and_return([ 'x', 'y' ])
|
137
|
+
|
138
|
+
expect(LowCardTables::VersionSupport).to receive(:clear_schema_cache!).once.ordered.with(@low_card_class)
|
139
|
+
|
140
|
+
expect(@low_card_class).to receive(:low_card_ensure_has_unique_index!).once.with(true).ordered
|
141
|
+
|
142
|
+
@migration.send(@method, *@args, &@proc)
|
143
|
+
@migration.calls.should == [ { :name => @method, :args => @args, :block => @proc } ]
|
144
|
+
end
|
145
|
+
|
130
146
|
it "should call #eager_load, pick up an AR descendant properly, and enforce the index" do
|
131
147
|
expect(@low_card_class).to receive(:low_card_remove_unique_index!).once.ordered
|
132
148
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: low_card_tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Geweke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|