csv_record 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -2
- data/lib/csv_record/connector.rb +2 -0
- data/lib/csv_record/version.rb +1 -1
- data/lib/csv_record/writer.rb +2 -2
- data/test/csv_record/reader_test.rb +14 -31
- metadata +1 -1
data/README.md
CHANGED
data/lib/csv_record/connector.rb
CHANGED
data/lib/csv_record/version.rb
CHANGED
data/lib/csv_record/writer.rb
CHANGED
@@ -35,7 +35,7 @@ module CsvRecord
|
|
35
35
|
def __destroy__
|
36
36
|
self.class.parse_database_file do |row|
|
37
37
|
new_row = row
|
38
|
-
new_row = nil if self.id == row.field('id').to_i
|
38
|
+
new_row = nil if self.id.to_i == row.field('id').to_i
|
39
39
|
new_row
|
40
40
|
end
|
41
41
|
empty_fields
|
@@ -58,7 +58,7 @@ module CsvRecord
|
|
58
58
|
set_updated_at
|
59
59
|
self.class.parse_database_file do |row|
|
60
60
|
new_row = row
|
61
|
-
new_row = self.values if self.id == row.field('id').to_i
|
61
|
+
new_row = self.values if self.id.to_i == row.field('id').to_i
|
62
62
|
new_row
|
63
63
|
end
|
64
64
|
true
|
@@ -51,41 +51,24 @@ describe CsvRecord::Reader do
|
|
51
51
|
Car.count.must_equal 2
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
cars.last.save
|
60
|
-
end
|
61
|
-
Car.find(cars.first.id).wont_be_nil
|
62
|
-
Car.find(cars.first.id).must_be_instance_of Car
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'querying by object' do
|
66
|
-
cars = []
|
67
|
-
3.times do
|
68
|
-
cars << car.clone
|
69
|
-
cars.last.save
|
70
|
-
end
|
71
|
-
Car.find(cars.first).wont_be_nil
|
72
|
-
Car.find(cars.first.id).must_be_instance_of Car
|
54
|
+
it 'querying by id' do
|
55
|
+
cars = []
|
56
|
+
3.times do
|
57
|
+
cars << car.clone
|
58
|
+
cars.last.save
|
73
59
|
end
|
60
|
+
Car.find(cars.first.id).wont_be_nil
|
61
|
+
Car.find(cars.first.id).must_be_instance_of Car
|
74
62
|
end
|
75
63
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
year: 1997,
|
82
|
-
make: 'Ford'
|
83
|
-
)
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'dinamyc finders' do
|
87
|
-
|
64
|
+
it 'querying by object' do
|
65
|
+
cars = []
|
66
|
+
3.times do
|
67
|
+
cars << car.clone
|
68
|
+
cars.last.save
|
88
69
|
end
|
70
|
+
Car.find(cars.first).wont_be_nil
|
71
|
+
Car.find(cars.first.id).must_be_instance_of Car
|
89
72
|
end
|
90
73
|
end
|
91
74
|
end
|