global_uid 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,11 +32,11 @@ module GlobalUid
32
32
  end
33
33
 
34
34
  def drop_table_with_global_uid(name, options = {})
35
- if !GlobalUid::Base.global_uid_options[:disabled] && options[:use_global_uid] != false
35
+ if !GlobalUid::Base.global_uid_options[:disabled] && options[:use_global_uid] == true
36
36
  id_table_name = options[:global_uid_table] || GlobalUid::Base.id_table_from_name(name)
37
37
  GlobalUid::Base.drop_uid_tables(id_table_name,options)
38
38
  end
39
- return drop_table_without_global_uid(name,options)
39
+ drop_table_without_global_uid(name,options)
40
40
  end
41
41
 
42
42
  end
@@ -14,6 +14,20 @@ class CreateWithNoParams < ActiveRecord::Migration
14
14
  end
15
15
  end
16
16
 
17
+ class CreateWithExplicitUidTrue < ActiveRecord::Migration
18
+ group :change if self.respond_to?(:group)
19
+
20
+ def self.up
21
+ create_table :with_global_uids, :use_global_uid => true do |t|
22
+ t.string :description
23
+ end
24
+ end
25
+
26
+ def self.down
27
+ drop_table :with_global_uids, :use_global_uid => true
28
+ end
29
+ end
30
+
17
31
  class CreateWithNamedID < ActiveRecord::Migration
18
32
  group :change if self.respond_to?(:group)
19
33
 
@@ -93,6 +107,22 @@ class GlobalUIDTest < ActiveSupport::TestCase
93
107
  end
94
108
  end
95
109
 
110
+ context "dropping a table" do
111
+ should "not drop the global-uid tables" do
112
+ CreateWithNoParams.up
113
+ GlobalUid::Base.with_connections do |cx|
114
+ assert cx.table_exists?('with_global_uids_ids')
115
+ end
116
+
117
+ CreateWithNoParams.down
118
+ GlobalUid::Base.with_connections do |cx|
119
+ assert cx.table_exists?('with_global_uids_ids')
120
+ end
121
+
122
+
123
+ end
124
+ end
125
+
96
126
  context "with global-uid disabled, globally" do
97
127
  setup do
98
128
  GlobalUid::Base.global_uid_options[:disabled] = true
@@ -128,6 +158,22 @@ class GlobalUIDTest < ActiveSupport::TestCase
128
158
  end
129
159
  end
130
160
 
161
+ context "with :use_global_uid => true" do
162
+ context "dropping a table" do
163
+ should "drop the global-uid tables" do
164
+ CreateWithExplicitUidTrue.up
165
+ GlobalUid::Base.with_connections do |cx|
166
+ assert cx.table_exists?('with_global_uids_ids')
167
+ end
168
+
169
+ CreateWithExplicitUidTrue.down
170
+ GlobalUid::Base.with_connections do |cx|
171
+ assert !cx.table_exists?('with_global_uids_ids')
172
+ end
173
+ end
174
+ end
175
+ end
176
+
131
177
  context "with global-uid disabled in the migration" do
132
178
  setup do
133
179
  CreateWithoutGlobalUIDs.up