activerecord_worm_table 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/activerecord_worm_table.rb +12 -1
  3. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -110,13 +110,24 @@ module ActiveRecord
110
110
  [base_table_name] + suffixed_table_names
111
111
  end
112
112
 
113
+ def default_active_table_name
114
+ if !defined?(RAILS_ENV) || (RAILS_ENV !~ /^test/)
115
+ base_table_name
116
+ else
117
+ # if in a test environment, make the default version table
118
+ # one of the suffixed tables : code which doesn't use Model.table_name
119
+ # will fail
120
+ suffixed_table_names.first
121
+ end
122
+ end
123
+
113
124
  # name of the active table
114
125
  def active_table_name
115
126
  st = switch_table_name
116
127
  begin
117
128
  connection.select_value( "select current from #{st}" )
118
129
  rescue
119
- end || base_table_name
130
+ end || default_active_table_name
120
131
  end
121
132
 
122
133
  # name of the working table
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_worm_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mccraig mccraig of the clan mccraig