bulk_data_methods 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +24 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +108 -0
  5. data/LICENSE +30 -0
  6. data/README +68 -0
  7. data/Rakefile +1 -0
  8. data/bulk_data_methods.gemspec +20 -0
  9. data/lib/bulk_data_methods/bulk_methods_mixin.rb +228 -0
  10. data/lib/bulk_data_methods/monkey_patch_postgres.rb +30 -0
  11. data/lib/bulk_data_methods/version.rb +3 -0
  12. data/lib/bulk_data_methods.rb +3 -0
  13. data/spec/bulk_data_methods/bulk_methods_mixin_spec.rb +436 -0
  14. data/spec/dummy/.rspec +1 -0
  15. data/spec/dummy/README +1 -0
  16. data/spec/dummy/Rakefile +7 -0
  17. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  18. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  19. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  20. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  21. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  22. data/spec/dummy/config/application.rb +65 -0
  23. data/spec/dummy/config/boot.rb +10 -0
  24. data/spec/dummy/config/database-sample.yml +32 -0
  25. data/spec/dummy/config/environment.rb +5 -0
  26. data/spec/dummy/config/environments/development.rb +37 -0
  27. data/spec/dummy/config/environments/production.rb +67 -0
  28. data/spec/dummy/config/environments/test.rb +37 -0
  29. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/spec/dummy/config/initializers/inflections.rb +15 -0
  31. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  32. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  33. data/spec/dummy/config/initializers/session_store.rb +8 -0
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/spec/dummy/config/locales/en.yml +5 -0
  36. data/spec/dummy/config/routes.rb +58 -0
  37. data/spec/dummy/config.ru +4 -0
  38. data/spec/dummy/public/404.html +26 -0
  39. data/spec/dummy/public/422.html +26 -0
  40. data/spec/dummy/public/500.html +25 -0
  41. data/spec/dummy/public/favicon.ico +0 -0
  42. data/spec/dummy/script/rails +6 -0
  43. data/spec/dummy/spec/spec_helper.rb +38 -0
  44. data/spec/spec_helper.rb +33 -0
  45. data/spec/support/tables_spec_helper.rb +47 -0
  46. metadata +173 -0
@@ -0,0 +1,436 @@
1
+ require 'spec_helper'
2
+ require "#{File.dirname(__FILE__)}/../support/tables_spec_helper"
3
+
4
+ describe "BulkMethodsMixin" do
5
+ include TablesSpecHelper
6
+
7
+ before do
8
+ class Employee < ActiveRecord::Base
9
+ extend BulkMethodsMixin
10
+ end
11
+ create_tables
12
+ end
13
+
14
+ describe "create_many" do
15
+
16
+ context "when call method with empty rows" do
17
+ it "returns empty array" do
18
+ Employee.create_many("").should == []
19
+ end
20
+ end # when call method with empty rows
21
+
22
+ context "when try to create records with the given id" do
23
+ it "records created" do
24
+ Employee.create_many([{ :id => Employee.connection.next_sequence_value(Employee.sequence_name),
25
+ :name => 'Keith',
26
+ :company_id => 2
27
+ },
28
+ { :id => Employee.connection.next_sequence_value(Employee.sequence_name),
29
+ :name => 'Mike',
30
+ :company_id => 3
31
+ },
32
+ { :id => Employee.connection.next_sequence_value(Employee.sequence_name),
33
+ :name => 'Alex',
34
+ :company_id => 1
35
+ }])
36
+ Employee.all.map{ |r| r.name }.should == ["Keith", "Mike", "Alex"]
37
+ end
38
+ end # when try to create records with the given id
39
+
40
+ context "when try to create records without the given id" do
41
+ it "records created" do
42
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
43
+ { :name => 'Mike', :company_id => 3 },
44
+ { :name => 'Alex', :company_id => 1 }])
45
+ Employee.all.map{ |r| r.name }.should == ["Keith", "Mike", "Alex"]
46
+ end
47
+ end # when try to create records without the given id
48
+
49
+ context "when try to create records with a mixture of given ids and non-given ids" do
50
+ it "records created" do
51
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
52
+ { :id => Employee.connection.next_sequence_value(Employee.sequence_name),
53
+ :name => 'Mike',
54
+ :company_id => 3
55
+ },
56
+ { :name => 'Mark', :company_id => 1 },
57
+ { :id => Employee.connection.next_sequence_value(Employee.sequence_name),
58
+ :name => 'Alex',
59
+ :company_id => 1
60
+ }])
61
+ Employee.all.map{ |r| r.name }.should == ["Keith", "Mike", "Mark", "Alex"]
62
+ end
63
+ end # when try to create records with a mixture of given ids and non-given ids
64
+
65
+ context "when try to create records with the given created_at" do
66
+ it "records created" do
67
+ Employee.create_many([{ :name => 'Keith',
68
+ :company_id => 2,
69
+ :created_at => Time.zone.parse('2012-01-02')
70
+ },
71
+ { :name => 'Mike',
72
+ :company_id => 3,
73
+ :created_at => Time.zone.parse('2012-01-03')
74
+ },
75
+ { :name => 'Alex',
76
+ :company_id => 1,
77
+ :created_at => Time.zone.parse('2012-01-04')
78
+ }])
79
+ Employee.all.map{ |r| r.created_at }.should == [
80
+ Time.zone.parse('2012-01-02'),
81
+ Time.zone.parse('2012-01-03'),
82
+ Time.zone.parse('2012-01-04')
83
+ ]
84
+ end
85
+ end # when try to create records with the given created_at
86
+
87
+ context "when try to create records without the given created_at" do
88
+ it "records created" do
89
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
90
+ { :name => 'Mike', :company_id => 3 },
91
+ { :name => 'Alex', :company_id => 1 }])
92
+ Employee.all.each{ |r| r.created_at.between?(Time.now - 3.minute, Time.now + 3.minute) }.
93
+ should be_true
94
+ end
95
+ end # when try to create records without the given created_at
96
+
97
+ context "when try to create records without options" do
98
+ it "generates one insert queries" do
99
+ Employee.should_receive(:find_by_sql).once.and_return([])
100
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
101
+ { :name => 'Alex', :company_id => 1 },
102
+ { :name => 'Mark', :company_id => 2 },
103
+ { :name => 'Phil', :company_id => 3 }])
104
+ end
105
+ end # when try to create records without options
106
+
107
+ context "when call method with option 'slice_size' equal 2" do
108
+ it "generates two insert queries" do
109
+ Employee.should_receive(:find_by_sql).twice.and_return([])
110
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
111
+ { :name => 'Alex', :company_id => 1 },
112
+ { :name => 'Mark', :company_id => 2 },
113
+ { :name => 'Phil', :company_id => 3 }],
114
+ { :slice_size => 2})
115
+ end
116
+ end # when call method with option 'slice_size' equal 2
117
+
118
+ context "when create two records with options 'returning' equal id" do
119
+ it "returns last records id" do
120
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
121
+ { :name => 'Alex', :company_id => 3 }],
122
+ { :returning => [:id] }).
123
+ last.id.should == 2
124
+ end
125
+ end # when create two records with options 'returning' equal id
126
+
127
+ context "when try to create two records and doesn't
128
+ the same number of keys and options check_consistency equal false" do
129
+ it "records created, last salary is nil" do
130
+ Employee.create_many([{ :company_id => 2, :name => 'Keith', :salary => 1002 },
131
+ { :name => 'Alex', :company_id => 3 }],
132
+ { :check_consistency => false })
133
+ Employee.find(2).salary.should == nil
134
+ end
135
+ end # when try to create two records and doesn't
136
+ # the same number of keys and options check_consistency equal false
137
+
138
+ context "when try to create two records and doesn't the same number of keys" do
139
+ it "raises BulkUploadDataInconsistent" do
140
+ lambda { Employee.create_many([{ :company_id => 2, :name => 'Keith', :salary => 1002 },
141
+ { :name => 'Alex', :company_id => 3}])
142
+ }.should raise_error(BulkMethodsMixin::BulkUploadDataInconsistent)
143
+ end
144
+ end # when try to create two records and doesn't the same number of keys
145
+
146
+ context "when try to create records in the table that has all the different sql types" do
147
+
148
+ before do
149
+ ActiveRecord::Base.connection.execute <<-SQL
150
+ ALTER TABLE employees ADD COLUMN test_string character varying;
151
+ ALTER TABLE employees ADD COLUMN test_float float;
152
+ ALTER TABLE employees ADD COLUMN test_decimal decimal;
153
+ ALTER TABLE employees ADD COLUMN test_time time;
154
+ ALTER TABLE employees ADD COLUMN test_time_string time;
155
+ ALTER TABLE employees ADD COLUMN test_date date;
156
+ ALTER TABLE employees ADD COLUMN test_date_string date;
157
+ ALTER TABLE employees ADD COLUMN test_bytea bytea;
158
+ ALTER TABLE employees ADD COLUMN test_boolean boolean;
159
+ ALTER TABLE employees ADD COLUMN test_xml xml;
160
+ ALTER TABLE employees ADD COLUMN test_tsvector tsvector;
161
+ SQL
162
+ Employee.reset_column_information
163
+ end
164
+
165
+ after do
166
+ ActiveRecord::Base.connection.reset!
167
+ end
168
+
169
+ context "non-null values" do
170
+ it "returns record with all sql types" do
171
+ lambda { Employee.create_many([{ :name => 'Keith',
172
+ :company_id => 2,
173
+ :created_at => Time.zone.parse('2012-12-21'),
174
+ :updated_at => '2012-12-21 00:00:00',
175
+ :test_string => "string",
176
+ :test_float => 12.34,
177
+ :test_decimal => 123456789101112,
178
+ :test_time => Time.now,
179
+ :test_time_string => '00:00:00',
180
+ :test_date => Date.parse('2012-12-21'),
181
+ :test_date_string => '2012-12-21',
182
+ :test_bytea => "text".bytes.to_a,
183
+ :test_boolean => false,
184
+ :test_xml => ["text"].to_xml,
185
+ :test_tsvector => "test string",
186
+ }]) }.should_not raise_error
187
+ Employee.all.size.should == 1
188
+ end
189
+ end # non-null values
190
+
191
+ context "null values" do
192
+ it "returns record with all sql types" do
193
+ lambda { Employee.create_many([{ :name => 'Keith',
194
+ :company_id => 2,
195
+ :created_at => nil,
196
+ :updated_at => nil,
197
+ :salary => nil,
198
+ :test_string => nil,
199
+ :test_float => nil,
200
+ :test_decimal => nil,
201
+ :test_time => nil,
202
+ :test_time_string => nil,
203
+ :test_date => nil,
204
+ :test_date_string => nil,
205
+ :test_bytea => nil,
206
+ :test_boolean => nil,
207
+ :test_xml => nil,
208
+ :test_tsvector => nil,
209
+ }]) }.should_not raise_error
210
+ Employee.all.size.should == 1
211
+ end
212
+ end # null values
213
+
214
+ end # when try to create records in the table that has all the different sql types
215
+
216
+ end # create_many
217
+
218
+ describe "update_many" do
219
+
220
+ before do
221
+ Employee.create_many([{ :name => 'Keith', :company_id => 2 },
222
+ { :name => 'Alex', :company_id => 1 },
223
+ { :name => 'Mark', :company_id => 2 },
224
+ { :name => 'Phil', :company_id => 3 }])
225
+ end
226
+
227
+ context "when call method with empty rows" do
228
+ it "returns empty array" do
229
+ Employee.update_many("").should == []
230
+ end
231
+ end # when call method with empty rows
232
+
233
+ context "when try to update records without options" do
234
+
235
+ context "input parameters is hash" do
236
+ it "records updated" do
237
+ Employee.update_many({ { :id => 1 } => {
238
+ :name => 'Elvis'
239
+ },
240
+ { :id => 2 } => {
241
+ :name => 'Freddi'
242
+ } })
243
+ Employee.find(1).name.should == "Elvis"
244
+ Employee.find(2).name.should == "Freddi"
245
+ end
246
+ end # input parameters is hash
247
+
248
+ context "input parameters is array" do
249
+ it "records updated" do
250
+ Employee.update_many([{ :id => 1,
251
+ :name => 'Elvis'
252
+ },
253
+ { :id => 2,
254
+ :name => 'Freddi'
255
+ }])
256
+ Employee.find(1).name.should == "Elvis"
257
+ Employee.find(2).name.should == "Freddi"
258
+ end
259
+ end # input parameters is array
260
+
261
+ context "when try to update two records and doesn't the same number of keys" do
262
+ it "raises BulkUploadDataInconsistent" do
263
+ lambda { Employee.update_many([{ :id => 1, :name => 'Elvis', :salary => 1002 },
264
+ { :name => 'Freddi', :id => 2}])
265
+ }.should raise_error(BulkMethodsMixin::BulkUploadDataInconsistent)
266
+ end
267
+ end # when try to update two records and doesn't the same number of keys
268
+
269
+ context "when try to update records with the given updated_at" do
270
+ it "records created" do
271
+ Employee.update_many([{ :id => 1,
272
+ :updated_at => Time.zone.parse('2012-01-02')
273
+ },
274
+ { :id => 2,
275
+ :updated_at => Time.zone.parse('2012-01-03')
276
+ },
277
+ { :id => 3,
278
+ :updated_at => Time.zone.parse('2012-01-04')
279
+ },
280
+ { :id => 4,
281
+ :updated_at => Time.zone.parse('2012-01-05')
282
+ }])
283
+ Employee.all.map{ |r| r.updated_at }.should == [
284
+ Time.zone.parse('2012-01-02'),
285
+ Time.zone.parse('2012-01-03'),
286
+ Time.zone.parse('2012-01-04'),
287
+ Time.zone.parse('2012-01-05')
288
+ ]
289
+ end
290
+ end # when try to update records with the given updated_at
291
+
292
+ end # when try to update records without options
293
+
294
+ context "when call method with option :slice_size set is default" do
295
+ it "generates one insert queries" do
296
+ Employee.should_receive(:find_by_sql).once.and_return([])
297
+ Employee.update_many([{ :id => 1, :name => 'Elvis' },
298
+ { :id => 2, :name => 'Freddi'},
299
+ { :id => 3, :name => 'Patric'},
300
+ { :id => 4, :name => 'Jane'}])
301
+ end
302
+ end # when call method with option :slice_size set is default
303
+
304
+
305
+ context "when call method with option :slice_size = 2" do
306
+ it "generates two insert queries" do
307
+ Employee.should_receive(:find_by_sql).twice.and_return([])
308
+ Employee.update_many([{ :id => 1, :name => 'Elvis' },
309
+ { :id => 2, :name => 'Freddi'},
310
+ { :id => 3, :name => 'Patric'},
311
+ { :id => 4, :name => 'Jane'}],
312
+ { :slice_size => 2})
313
+ end
314
+ end # when call method with option :slice_size = 2
315
+
316
+ context "when try to update two records and doesn't
317
+ the same number of keys and options check_consistency equal false" do
318
+ it "raises ActiveRecord::StatementInvalid" do
319
+ lambda {
320
+ Employee.update_many([{ :id => 1, :name => 'Elvis', :salary => 1002 },
321
+ { :name => 'Freddi', :id => 2}],
322
+ { :check_consistency => false })
323
+ }.should raise_error(ActiveRecord::StatementInvalid)
324
+ end
325
+ end # when try to update two records and doesn't
326
+ # the same number of keys and options check_consistency equal false
327
+
328
+ context "when update two records with options 'returning' equal :name" do
329
+ it "returns last records name" do
330
+ Employee.update_many([{ :id => 1, :name => 'Elvis' },
331
+ { :id => 2, :name => 'Freddi'}],
332
+ { :returning => [:name] }).
333
+ last.name.should == 'Freddi'
334
+ end
335
+ end # when update two records with options 'returning' equal :name
336
+
337
+ context "when update method with options :set_array equal 'salary = datatable.salary'" do
338
+ it "updates only salary column" do
339
+ Employee.update_many([{ :id => 1, :name => 'Elvis', :salary => 12 },
340
+ { :id => 2, :name => 'Freddi',:salary => 22}],
341
+ { :set_array => '"salary = datatable.salary"' })
342
+ Employee.find(1).name.should_not == "Elvis"
343
+ Employee.find(1).salary.should == 12
344
+ Employee.find(2).name.should_not == "Freddi"
345
+ Employee.find(2).salary.should == 22
346
+ end
347
+ end # when update method with options :set_array equal 'salary = datatable.salary'
348
+
349
+ context "when update method with options :where" do
350
+ it "updates only name column, where salary equal input values" do
351
+ Employee.update_many([{ :id => 1, :name => 'Elvis', :salary => 12 },
352
+ { :id => 2, :name => 'Freddi',:salary => 22}],
353
+ { :where => '"#{table_name}.salary = datatable.salary"' })
354
+ Employee.find(1).name.should_not == "Elvis"
355
+ Employee.find(1).salary.should == 3
356
+ Employee.find(2).name.should_not == "Freddi"
357
+ Employee.find(2).salary.should == 3
358
+ end
359
+ end # when update method with options :where
360
+
361
+ context "when try to update records in the table that has all the different sql types" do
362
+
363
+ before do
364
+ ActiveRecord::Base.connection.execute <<-SQL
365
+ ALTER TABLE employees ADD COLUMN test_string character varying;
366
+ ALTER TABLE employees ADD COLUMN test_float float;
367
+ ALTER TABLE employees ADD COLUMN test_decimal decimal;
368
+ ALTER TABLE employees ADD COLUMN test_time time;
369
+ ALTER TABLE employees ADD COLUMN test_time_string time;
370
+ ALTER TABLE employees ADD COLUMN test_date date;
371
+ ALTER TABLE employees ADD COLUMN test_date_string date;
372
+ ALTER TABLE employees ADD COLUMN test_bytea bytea;
373
+ ALTER TABLE employees ADD COLUMN test_boolean boolean;
374
+ ALTER TABLE employees ADD COLUMN test_xml xml;
375
+ ALTER TABLE employees ADD COLUMN test_tsvector tsvector;
376
+ SQL
377
+ Employee.reset_column_information
378
+ end
379
+
380
+ after do
381
+ ActiveRecord::Base.connection.reset!
382
+ end
383
+
384
+ context "non-null values" do
385
+ it "returns record with all sql types" do
386
+ lambda { Employee.update_many([{ :id => 1,
387
+ :name => 'Keith',
388
+ :company_id => 2,
389
+ :created_at => Time.zone.parse('2012-12-21'),
390
+ :updated_at => '2012-12-21 00:00:00',
391
+ :test_string => "string",
392
+ :test_float => 12.34,
393
+ :test_decimal => 123456789101112,
394
+ :test_time => Time.now,
395
+ :test_time_string => '00:00:00',
396
+ :test_date => Date.parse('2012-12-21'),
397
+ :test_date_string => '2012-12-21',
398
+ :test_bytea => "text".bytes.to_a,
399
+ :test_boolean => false,
400
+ :test_xml => ["text"].to_xml,
401
+ :test_tsvector => "test string",
402
+ }]) }.should_not raise_error
403
+ Employee.find(1).test_boolean.should == false
404
+ Employee.find(1).test_tsvector.should == "'string' 'test'"
405
+ end
406
+ end # non-null values
407
+
408
+ context "null values" do
409
+ it "returns record with all sql types" do
410
+ lambda { Employee.update_many([{ :id => 1,
411
+ :name => 'Keith',
412
+ :company_id => 2,
413
+ :updated_at => nil,
414
+ :salary => nil,
415
+ :test_string => nil,
416
+ :test_float => nil,
417
+ :test_decimal => nil,
418
+ :test_time => nil,
419
+ :test_time_string => nil,
420
+ :test_date => nil,
421
+ :test_date_string => nil,
422
+ :test_bytea => nil,
423
+ :test_boolean => nil,
424
+ :test_xml => nil,
425
+ :test_tsvector => nil,
426
+ }]) }.should_not raise_error
427
+ Employee.find(1).test_boolean.should == nil
428
+ Employee.find(1).test_tsvector.should == nil
429
+ end
430
+ end # null values
431
+
432
+ end # when try to update records in the table that has all the different sql types
433
+
434
+ end # update_many
435
+
436
+ end # BulkMethodsMixin
data/spec/dummy/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/spec/dummy/README ADDED
@@ -0,0 +1 @@
1
+ == dummy project
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,65 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "active_resource/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require
12
+ require "bulk_data_methods"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Custom directories with classes and modules you want to be autoloadable.
21
+ # config.autoload_paths += %W(#{config.root}/extras)
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named.
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Activate observers that should always be running.
28
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
29
+
30
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
31
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
32
+ # config.time_zone = 'Central Time (US & Canada)'
33
+
34
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
35
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
36
+ # config.i18n.default_locale = :de
37
+
38
+ # Configure the default encoding used in templates for Ruby 1.9.
39
+ config.encoding = "utf-8"
40
+
41
+ # Configure sensitive parameters which will be filtered from the log file.
42
+ config.filter_parameters += [:password]
43
+
44
+ # Enable escaping HTML in JSON.
45
+ config.active_support.escape_html_entities_in_json = true
46
+
47
+ # Use SQL instead of Active Record's schema dumper when creating the database.
48
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
49
+ # like if you have constraints or database-specific column types
50
+ # config.active_record.schema_format = :sql
51
+
52
+ # Enforce whitelist mode for mass assignment.
53
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
54
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
55
+ # parameters by using an attr_accessible or attr_protected declaration.
56
+ config.active_record.whitelist_attributes = true
57
+
58
+ # Enable the asset pipeline
59
+ config.assets.enabled = true
60
+
61
+ # Version of your assets, change this if you want to expire all your assets
62
+ config.assets.version = '1.0'
63
+ end
64
+ end
65
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,32 @@
1
+ common: &common
2
+ adapter: postgresql
3
+ username: postgres
4
+ password: postgres
5
+ encoding: SQL_ASCII
6
+ template: template0
7
+ pool: 5
8
+ timeout: 5000
9
+
10
+ local: &local
11
+ host: 127.0.0.1
12
+
13
+ # -----------------
14
+ # *** part ***
15
+ # -----------------
16
+
17
+ development:
18
+ <<: *common
19
+ <<: *local
20
+ database: bulk_data_methods_production
21
+
22
+ production:
23
+ <<: *common
24
+ <<: *local
25
+ database: bulk_data_methods_production
26
+
27
+
28
+ test:
29
+ <<: *common
30
+ <<: *local
31
+ database: bulk_data_methods_test
32
+
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Raise exception on mass assignment protection for Active Record models
26
+ config.active_record.mass_assignment_sanitizer = :strict
27
+
28
+ # Log the query plan for queries taking more than this (works
29
+ # with SQLite, MySQL, and PostgreSQL)
30
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
31
+
32
+ # Do not compress assets
33
+ config.assets.compress = false
34
+
35
+ # Expands the lines which load the assets
36
+ config.assets.debug = true
37
+ end