rails_spreadsheet_reader 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTMwNzIzNDhlOTA5ZDU4NzYxNzQ4OWY3ODhiNWZlZjhhZmI0NDg3ZA==
4
+ Nzc2ODllYzU0OGI0N2I4MzRhMDIzMmUzNTAxOWEzYWI4MjI2OWQ1MQ==
5
5
  data.tar.gz: !binary |-
6
- NTZjOGQwNDdjZDVkYzIyNzkyNGZjM2Y0YTc2Zjg3ZGI4YWI1NzRmNw==
6
+ OTI2ODJlYTgzNDZlZjM4OTkzNDA3ZWRhNzQ1MWY5ODIxZjBjYmIxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGNkMjk0NDM5YThjMzE3NWNhMTE1MTIyZjhiOTQ0NTMwZjUwZjM1MmQxZDIw
10
- ZGZiNTA3ZGYxMDU5YjFlNTAwMTg2NTcwYTkxNTliN2FkZWM2ODk1YzgzNzM1
11
- YTg5Y2M0YzU4MWQxMGY0MWI3ZTRjZmZmNzVkZDEwYzBlMmMyMzA=
9
+ MDIxMTAxMDM0ZjdiOTcyZTA0NjE5YmMwMzVjNGE3MjAzODc1NjNhNDlhNzFj
10
+ MzAwMTc4MDAxOTA1MTQ4ZGMyYjM0OWNmMmQ4OWM3NDJjMjJjOTNkZjMxNTZl
11
+ MzQzMjAxMmQxMjNhMjc5Nzg2MGMyMjQ5N2Y5ODhjMTg1OGU0MTQ=
12
12
  data.tar.gz: !binary |-
13
- MmUzMDAzZTJkZDQ5OWNmNDZmMGIxNDYyYzI1MzUxYWMwYjdkNjExYTBkMTQz
14
- ZDRiZTI2YTI5MDI2NjM3YWZhYTk3ZmMwNmNhZDNlZTIzNTFhMTdkNWQzYzVk
15
- Y2Q0MWVlNGNkNDcxMzI5NjRlMGJkNWQ3NWQxNTZkODE2ZDQ5YzA=
13
+ OTY3MDgwYmYwMjMwMTc5YzRmMWRjZDQ4ZTg1MGYwNDJjODc2YmRjZjgwZjBj
14
+ YjczYjdjZDMwMWQ0ZTUyNGNkMzFjYmVkOTgzNzgyMGNiOTQwNzhhZDUxZmI0
15
+ M2NlNzVmZDUzZmIwMjA2YWEwNmM4MDYxZGZmMTMwNGRjYzYxNGI=
@@ -16,7 +16,7 @@ module RailsSpreadsheetReader
16
16
  # Copy a ActiveModel::Model errors
17
17
  def copy_errors(model)
18
18
  model.errors.each do |key, value|
19
- self.errors[key] = value
19
+ errors.add(key, value)
20
20
  end
21
21
  end
22
22
 
@@ -1,3 +1,3 @@
1
1
  module RailsSpreadsheetReader
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/spec/base_spec.rb CHANGED
@@ -73,4 +73,14 @@ describe RailsSpreadsheetReader::Base do
73
73
  expect(row_collection.errors.full_messages).to eq(["Email can't be blank"])
74
74
  end
75
75
 
76
+ it 'copy_errors' do
77
+ user_spreadsheet = UserSpreadsheet.new
78
+ user_spreadsheet.errors.add(:username, 'is unique')
79
+ expect(user_spreadsheet.valid?).to eq(false)
80
+ expect(user_spreadsheet.invalid?).to eq(true)
81
+ valid = UserSpreadsheet.new
82
+ valid.copy_errors(user_spreadsheet)
83
+ expect(valid.valid?).to eq(false)
84
+ end
85
+
76
86
  end
@@ -8,4 +8,8 @@ class UserSpreadsheet < RailsSpreadsheetReader::Base
8
8
  { :username => 0, :email => 1, :gender => 2 }
9
9
  end
10
10
 
11
+ def make_invalid
12
+ errors[:username] = 'is invalid'
13
+ end
14
+
11
15
  end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require_relative 'models/invalid_column_spreadsheet'
3
+ require_relative 'models/user_spreadsheet'
4
+ require_relative 'models/user_invalid_spreadsheet'
5
+ require_relative 'models/empty_column_spreadsheet.rb'
6
+
7
+ describe RailsSpreadsheetReader::RowCollection do
8
+
9
+ it 'empty properties' do
10
+ collection = RailsSpreadsheetReader::RowCollection.new
11
+ expect(collection.rows).to eq([])
12
+ expect(collection.invalid?).to eq(false)
13
+ expect(collection.valid?).to eq(true)
14
+ expect(collection.errors).to eq(nil)
15
+ end
16
+
17
+ it 'push rows' do
18
+ collection = RailsSpreadsheetReader::RowCollection.new
19
+ user_spreadsheet = UserSpreadsheet.new
20
+ collection.push(user_spreadsheet)
21
+ expect(collection.rows.count).to eq(1)
22
+ end
23
+
24
+ it 'push invalid rows' do
25
+ collection = RailsSpreadsheetReader::RowCollection.new
26
+ user_spreadsheet = UserSpreadsheet.new
27
+ user_spreadsheet.make_invalid
28
+ expect(user_spreadsheet.invalid?).to eq(true)
29
+ collection.push(user_spreadsheet)
30
+ expect(collection.valid?).to eq(false)
31
+ expect(collection.invalid?).to eq(true)
32
+ end
33
+
34
+ it 'set_invalid_row' do
35
+ collection = RailsSpreadsheetReader::RowCollection.new
36
+ row = UserSpreadsheet.new
37
+ model = UserSpreadsheet.new
38
+ model.make_invalid
39
+ collection.push(row)
40
+ collection.set_invalid_row(row, model)
41
+ expect(collection.valid?).to eq(false)
42
+ expect(collection.invalid?).to eq(true)
43
+ expect(collection.invalid_row).to_not eq(nil)
44
+ end
45
+
46
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_spreadsheet_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - muzk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - spec/models/invalid_column_spreadsheet.rb
121
121
  - spec/models/user_invalid_spreadsheet.rb
122
122
  - spec/models/user_spreadsheet.rb
123
+ - spec/row_collection_spec.rb
123
124
  - spec/spec_helper.rb
124
125
  homepage: https://github.com/HasuSoftware/rails_spreadsheet_reader
125
126
  licenses:
@@ -153,4 +154,5 @@ test_files:
153
154
  - spec/models/invalid_column_spreadsheet.rb
154
155
  - spec/models/user_invalid_spreadsheet.rb
155
156
  - spec/models/user_spreadsheet.rb
157
+ - spec/row_collection_spec.rb
156
158
  - spec/spec_helper.rb