rails-schema-validations 0.5.1 → 0.6

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.
@@ -1,7 +1,7 @@
1
1
  # this will put it in the scope of a model
2
2
  module ActiveRecord::Validations::ClassMethods
3
3
  def validations_from_schema
4
- self.content_columns.map do |col|
4
+ self.columns.map do |col|
5
5
  case col.type
6
6
  when :integer
7
7
  # assuming unsigned!
@@ -17,8 +17,13 @@ def load_schema
17
17
  t.send(kind, "#{kind}_limit", :limit => 4)
18
18
  t.send(kind, "#{kind}_limit_notnull", :limit => 4, :null => false)
19
19
  end
20
- t.timestamps
20
+
21
+ t.integer :indexed_id, :null => false
22
+ t.integer :unique_id, :null => false
21
23
  end
24
+
25
+ add_index 'models', ['indexed_id']
26
+ add_index 'models', ['unique_id'], :unqiue => true
22
27
  end
23
28
  end
24
29
 
@@ -32,7 +37,7 @@ context Model do
32
37
  setup { Model.new }
33
38
 
34
39
  def asserts_error_on field, value
35
- asserts("#{field} has an error with #{value}") do
40
+ asserts("#{field} has an error with #{value.inspect}") do
36
41
  topic.send("#{field}=", value)
37
42
  topic.valid?
38
43
  topic.errors[field.to_sym].present?
@@ -40,7 +45,7 @@ context Model do
40
45
  end
41
46
 
42
47
  def asserts_no_error_on field, value
43
- asserts("#{field} has no error with #{value}") do
48
+ asserts("#{field} has no error with #{value.inspect}") do
44
49
  topic.send("#{field}=", value)
45
50
  topic.valid?
46
51
  topic.errors[field.to_sym].blank?
@@ -65,4 +70,7 @@ context Model do
65
70
 
66
71
  asserts_no_error_on :string_limit, '12'
67
72
  asserts_no_error_on :integer_limit, 2 ** (8 * 3)
73
+
74
+ asserts_error_on :indexed_id, nil
75
+ asserts_error_on :unique_id, nil
68
76
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-schema-validations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
8
+ - 6
9
+ version: "0.6"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Greg Weber
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-24 00:00:00 -07:00
17
+ date: 2010-09-28 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies: []
21
20