activerecord-import 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 603d47cf7c69bfa501fa6a00ef55e0f49bab67db
4
- data.tar.gz: ebb0d7a548d9a927e089cde6577ad384ca53ce2d
3
+ metadata.gz: eb77d17b829e2ac21c8816b01c3d365b4f9ddc6e
4
+ data.tar.gz: 301500da2b010aaac8473af8c5436124c59c0ca0
5
5
  SHA512:
6
- metadata.gz: 4d9bdc42b8d118443140245e045ae3f2452824b86777bf47ba5bccb31017bbce637fb7937c0dd700e0ad17226a925fec3b53c8cb6ed778bbda4926ecb6f1a7bf
7
- data.tar.gz: b0b4d863c26efbcea8a72239ca69a8d21ae95952f2f677dfb3d241f14550f0035f3779527edc9d28d0b2705e46ba6336a36e984478d283455325c9653d15381c
6
+ metadata.gz: 242c10dbb23c6236cd2e2f10328a6c63e567c3fa55bb899c05771b37c7bc3507632495779deffdf52dcd8798c7785398be1493330d32f69953a20d3e0a1348be
7
+ data.tar.gz: 1c8eccfa18fef779eb2c6c86cde365cd6254efc453b09734e19ceafe62d93af445de0042e0ef6d840f7c7e9e5546f93432ff2a3fe9bde3f4a97d6319031be2f5
@@ -270,7 +270,7 @@ class ActiveRecord::Base
270
270
  # this next line breaks sqlite.so with a segmentation fault
271
271
  # if model.new_record? || options[:on_duplicate_key_update]
272
272
  column_names.map do |name|
273
- model.send( "#{name}_before_type_cast" )
273
+ model.read_attribute_before_type_cast(name.to_s)
274
274
  end
275
275
  # end
276
276
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -365,6 +365,34 @@ describe "#import" do
365
365
 
366
366
  end
367
367
 
368
+ context 'When importing models with Enum fields' do
369
+ it 'should be able to import enum fields' do
370
+ Book.delete_all if Book.count > 0
371
+ books = [
372
+ Book.new(:author_name => "Foo", :title => "Baz", status: 0),
373
+ Book.new(:author_name => "Foo2", :title => "Baz2", status: 1),
374
+ ]
375
+ Book.import books
376
+ assert_equal 2, Book.count
377
+ assert_equal 0, Book.first.read_attribute('status')
378
+ assert_equal 1, Book.last.read_attribute('status')
379
+ end
380
+
381
+ if ENV['AR_VERSION'].to_i > 4.1
382
+ it 'should be able to import enum fields by name' do
383
+ Book.delete_all if Book.count > 0
384
+ books = [
385
+ Book.new(:author_name => "Foo", :title => "Baz", status: :draft),
386
+ Book.new(:author_name => "Foo2", :title => "Baz2", status: :published),
387
+ ]
388
+ Book.import books
389
+ assert_equal 2, Book.count
390
+ assert_equal 0, Book.first.read_attribute('status')
391
+ assert_equal 1, Book.last.read_attribute('status')
392
+ end
393
+ end
394
+ end
395
+
368
396
  describe "importing when model has default_scope" do
369
397
  it "doesn't import the default scope values" do
370
398
  assert_difference "Widget.unscoped.count", +2 do
@@ -2,4 +2,7 @@ class Book < ActiveRecord::Base
2
2
  belongs_to :topic, :inverse_of=>:books
3
3
  has_many :chapters, :autosave => true, :inverse_of => :book
4
4
  has_many :end_notes, :autosave => true, :inverse_of => :book
5
+ if ENV['AR_VERSION'].to_i >= 4.1
6
+ enum status: [:draft, :published]
7
+ end
5
8
  end
@@ -64,6 +64,7 @@ ActiveRecord::Schema.define do
64
64
  t.column :publish_date, :date
65
65
  t.column :topic_id, :integer
66
66
  t.column :for_sale, :boolean, :default => true
67
+ t.column :status, :integer
67
68
  end
68
69
 
69
70
  create_table :chapters, :force => true do |t|
@@ -11,6 +11,7 @@ ActiveRecord::Schema.define do
11
11
  t.column :publish_date, :date
12
12
  t.column :topic_id, :integer
13
13
  t.column :for_sale, :boolean, :default => true
14
+ t.column :status, :integer
14
15
  end
15
16
  execute "ALTER TABLE books ADD FULLTEXT( `title`, `publisher`, `author_name` )"
16
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -213,3 +213,4 @@ test_files:
213
213
  - test/travis/database.yml
214
214
  - test/value_sets_bytes_parser_test.rb
215
215
  - test/value_sets_records_parser_test.rb
216
+ has_rdoc: