autocomplete_for 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :gemcutter
2
+
3
+ gem 'activerecord', '~> 3.0.10'
4
+ gem 'pg'
5
+ gem 'rake'
6
+ gem 'jeweler'
7
+ gem 'gemcutter'
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.10)
5
+ activesupport (= 3.0.10)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.5.0)
8
+ activerecord (3.0.10)
9
+ activemodel (= 3.0.10)
10
+ activesupport (= 3.0.10)
11
+ arel (~> 2.0.10)
12
+ tzinfo (~> 0.3.23)
13
+ activesupport (3.0.10)
14
+ arel (2.0.10)
15
+ builder (2.1.2)
16
+ gemcutter (0.7.0)
17
+ git (1.2.5)
18
+ i18n (0.5.0)
19
+ jeweler (1.6.4)
20
+ bundler (~> 1.0)
21
+ git (>= 1.2.5)
22
+ rake
23
+ pg (0.11.0)
24
+ rake (0.8.7)
25
+ tzinfo (0.3.30)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ activerecord (~> 3.0.10)
32
+ gemcutter
33
+ jeweler
34
+ pg
35
+ rake
data/Rakefile CHANGED
@@ -12,12 +12,13 @@ begin
12
12
  s.homepage = "http://github.com/sskirby/autocomplete_for"
13
13
  s.rubyforge_project = 'autocomplete_for'
14
14
  s.authors = ["Sean Kirby"]
15
- s.add_dependency('activerecord', '~> 2.3.4')
15
+ s.add_dependency('activerecord', '~> 3.0.0')
16
16
  s.add_development_dependency('pg')
17
17
  end
18
+ Jeweler::GemcutterTasks.new
18
19
 
19
20
  rescue LoadError
20
- puts "Jeweler not available. Install it with: gem install jeweler"
21
+ puts "Jeweler or Gemcutter not available. Install it with: gem install jeweler gemcutter"
21
22
  end
22
23
 
23
24
  desc 'Default: run unit tests.'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,60 +1,70 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{autocomplete_for}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sean Kirby"]
12
- s.date = %q{2010-09-24}
12
+ s.date = %q{2011-10-13}
13
13
  s.description = %q{Model-side logic for autocompleting belongs_to associations}
14
14
  s.email = %q{sskirby@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.markdown"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.markdown",
22
- "Rakefile",
23
- "VERSION",
24
- "autocomplete_for.gemspec",
25
- "lib/autocomplete_for.rb",
26
- "lib/autocomplete_for/autocomplete_for.rb",
27
- "rails/init.rb",
28
- "test/autocomplete_for_test.rb",
29
- "test/database.yml",
30
- "test/schema.rb",
31
- "test/test_helper.rb"
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "MIT-LICENSE",
22
+ "README.markdown",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "autocomplete_for.gemspec",
26
+ "lib/autocomplete_for.rb",
27
+ "lib/autocomplete_for/autocomplete_for.rb",
28
+ "rails/init.rb",
29
+ "test/autocomplete_for_test.rb",
30
+ "test/database.yml",
31
+ "test/schema.rb",
32
+ "test/test_helper.rb"
32
33
  ]
33
34
  s.homepage = %q{http://github.com/sskirby/autocomplete_for}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
35
  s.require_paths = ["lib"]
36
36
  s.rubyforge_project = %q{autocomplete_for}
37
37
  s.rubygems_version = %q{1.3.7}
38
38
  s.summary = %q{Model-side logic for autocompleting belongs_to associations}
39
- s.test_files = [
40
- "test/schema.rb",
41
- "test/autocomplete_for_test.rb",
42
- "test/test_helper.rb"
43
- ]
44
39
 
45
40
  if s.respond_to? :specification_version then
46
41
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
42
  s.specification_version = 3
48
43
 
49
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.4"])
45
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.10"])
46
+ s.add_runtime_dependency(%q<pg>, [">= 0"])
47
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
48
+ s.add_runtime_dependency(%q<jeweler>, [">= 0"])
49
+ s.add_runtime_dependency(%q<gemcutter>, [">= 0"])
50
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.0"])
51
51
  s.add_development_dependency(%q<pg>, [">= 0"])
52
52
  else
53
- s.add_dependency(%q<activerecord>, ["~> 2.3.4"])
53
+ s.add_dependency(%q<activerecord>, ["~> 3.0.10"])
54
+ s.add_dependency(%q<pg>, [">= 0"])
55
+ s.add_dependency(%q<rake>, [">= 0"])
56
+ s.add_dependency(%q<jeweler>, [">= 0"])
57
+ s.add_dependency(%q<gemcutter>, [">= 0"])
58
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
54
59
  s.add_dependency(%q<pg>, [">= 0"])
55
60
  end
56
61
  else
57
- s.add_dependency(%q<activerecord>, ["~> 2.3.4"])
62
+ s.add_dependency(%q<activerecord>, ["~> 3.0.10"])
63
+ s.add_dependency(%q<pg>, [">= 0"])
64
+ s.add_dependency(%q<rake>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, [">= 0"])
66
+ s.add_dependency(%q<gemcutter>, [">= 0"])
67
+ s.add_dependency(%q<activerecord>, ["~> 3.0.0"])
58
68
  s.add_dependency(%q<pg>, [">= 0"])
59
69
  end
60
70
  end
@@ -79,18 +79,17 @@ module AutocompleteFor
79
79
  unless allow_nil
80
80
  # we must make sure that the validate_by_customer validation runs
81
81
  # after ALL validations on autocomplete fields
82
- # see rails/activesupport/lib/active_support/callbacks.rb line #208
83
- # probably won't work in Rails 3
84
- @validate_callbacks.delete(:"validate_by_#{association}")
85
- validate :"validate_by_#{association}"
86
-
82
+ #skip_callback :validate, :by, :"#{association}"
83
+
84
+ validate :"validate_by_#{association}"
85
+
87
86
  unless instance_methods.include?("validate_by_#{association}")
88
87
 
89
88
  # def validate_by_customer
90
89
  # self.errors.add_on_blank(:customer) unless @@customer_autocompolete_error_fields.any? {|ef| self.errors[ef]}
91
90
  # end
92
91
  define_method(:"validate_by_#{association}") do
93
- self.errors.add_on_blank(:"#{association}") unless self.class.instance_variable_get(error_fields_name).any? {|ef| self.errors[ef]}
92
+ self.errors.add_on_blank(:"#{association}") unless self.class.instance_variable_get(error_fields_name).any? {|ef| self.errors[ef].any? }
94
93
  end
95
94
  end
96
95
  end
@@ -49,27 +49,27 @@ class AutocompleteForTest < ActiveSupport::TestCase
49
49
  @autocomplete_for_vendor.update_attributes :vendor_name => "Not a Vendor Name"
50
50
 
51
51
  assert_nil @autocomplete_for_vendor.vendor
52
- assert @autocomplete_for_vendor.errors.on(:vendor_name)
53
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_code)
54
- assert_nil @autocomplete_for_vendor.errors.on(:vendor)
52
+ assert @autocomplete_for_vendor.errors[:vendor_name].any?
53
+ assert @autocomplete_for_vendor.errors[:vendor_code].empty?
54
+ assert @autocomplete_for_vendor.errors[:vendor].empty?
55
55
  end
56
56
 
57
57
  test "with blank name" do
58
58
  @autocomplete_for_vendor.update_attributes :vendor_name => ""
59
59
 
60
60
  assert_nil @autocomplete_for_vendor.vendor
61
- assert @autocomplete_for_vendor.errors.on(:vendor_name)
62
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_code)
63
- assert_nil @autocomplete_for_vendor.errors.on(:vendor)
61
+ assert @autocomplete_for_vendor.errors[:vendor_name].any?
62
+ assert @autocomplete_for_vendor.errors[:vendor_code].empty?
63
+ assert @autocomplete_for_vendor.errors[:vendor].empty?
64
64
  end
65
65
 
66
66
  test "with nil name" do
67
67
  @autocomplete_for_vendor.update_attributes :vendor_name => nil
68
68
 
69
69
  assert_nil @autocomplete_for_vendor.vendor
70
- assert @autocomplete_for_vendor.errors.on(:vendor)
71
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_code)
72
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_name)
70
+ assert_equal 1, @autocomplete_for_vendor.errors[:vendor].size, @autocomplete_for_vendor.errors[:vendor]
71
+ assert @autocomplete_for_vendor.errors[:vendor_code].empty?
72
+ assert @autocomplete_for_vendor.errors[:vendor_name].empty?
73
73
  end
74
74
 
75
75
  test "should clear existing association" do
@@ -78,10 +78,10 @@ class AutocompleteForTest < ActiveSupport::TestCase
78
78
 
79
79
  @autocomplete_for_vendor.update_attributes :vendor_name => ""
80
80
  assert_nil @autocomplete_for_vendor.vendor
81
- assert @autocomplete_for_vendor.errors.on(:vendor_name)
81
+ assert @autocomplete_for_vendor.errors[:vendor_name].any?
82
82
 
83
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_code)
84
- assert_nil @autocomplete_for_vendor.errors.on(:vendor)
83
+ assert @autocomplete_for_vendor.errors[:vendor_code].empty?
84
+ assert @autocomplete_for_vendor.errors[:vendor].empty?
85
85
  end
86
86
 
87
87
  test "should not clear existing association" do
@@ -98,10 +98,10 @@ class AutocompleteForTest < ActiveSupport::TestCase
98
98
 
99
99
  @autocomplete_for_vendor.update_attributes :vendor_code => ""
100
100
  assert_nil @autocomplete_for_vendor.vendor
101
- assert @autocomplete_for_vendor.errors.on(:vendor_code)
101
+ assert @autocomplete_for_vendor.errors[:vendor_code].any?
102
102
 
103
- assert_nil @autocomplete_for_vendor.errors.on(:vendor_name)
104
- assert_nil @autocomplete_for_vendor.errors.on(:vendor)
103
+ assert @autocomplete_for_vendor.errors[:vendor_name].empty?
104
+ assert @autocomplete_for_vendor.errors[:vendor].empty?
105
105
  end
106
106
 
107
107
  test "allow_nil with valid name" do
@@ -114,9 +114,9 @@ class AutocompleteForTest < ActiveSupport::TestCase
114
114
  @autocomplete_for_customer.update_attributes :customer_name => "Not A Customer Name"
115
115
 
116
116
  assert_nil @autocomplete_for_customer.customer
117
- assert @autocomplete_for_customer.errors.on(:customer_name)
118
- assert_nil @autocomplete_for_customer.errors.on(:customer_code)
119
- assert_nil @autocomplete_for_customer.errors.on(:customer)
117
+ assert @autocomplete_for_customer.errors[:customer_name].any?
118
+ assert @autocomplete_for_customer.errors[:customer_code].empty?
119
+ assert @autocomplete_for_customer.errors[:customer].empty?
120
120
  end
121
121
 
122
122
  test "allow_nil with blank name" do
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'active_support'
2
+ require 'active_support/core_ext'
3
3
  require 'active_support/test_case'
4
4
 
5
5
  require 'test/unit'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autocomplete_for
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ segments_generated: true
11
+ version: 0.2.0
11
12
  platform: ruby
12
13
  authors:
13
14
  - Sean Kirby
@@ -15,29 +16,58 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-09-24 00:00:00 -04:00
19
+ date: 2011-10-13 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: activerecord
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 11
28
+ hash: 19
30
29
  segments:
31
- - 2
32
30
  - 3
33
- - 4
34
- version: 2.3.4
31
+ - 0
32
+ - 10
33
+ segments_generated: true
34
+ version: 3.0.10
35
+ requirement: *id001
36
+ prerelease: false
35
37
  type: :runtime
36
- version_requirements: *id001
38
+ name: activerecord
37
39
  - !ruby/object:Gem::Dependency
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ segments_generated: true
49
+ version: "0"
50
+ requirement: *id002
51
+ prerelease: false
52
+ type: :runtime
38
53
  name: pg
54
+ - !ruby/object:Gem::Dependency
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ segments_generated: true
64
+ version: "0"
65
+ requirement: *id003
39
66
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
67
+ type: :runtime
68
+ name: rake
69
+ - !ruby/object:Gem::Dependency
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
41
71
  none: false
42
72
  requirements:
43
73
  - - ">="
@@ -45,9 +75,59 @@ dependencies:
45
75
  hash: 3
46
76
  segments:
47
77
  - 0
78
+ segments_generated: true
48
79
  version: "0"
80
+ requirement: *id004
81
+ prerelease: false
82
+ type: :runtime
83
+ name: jeweler
84
+ - !ruby/object:Gem::Dependency
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ segments_generated: true
94
+ version: "0"
95
+ requirement: *id005
96
+ prerelease: false
97
+ type: :runtime
98
+ name: gemcutter
99
+ - !ruby/object:Gem::Dependency
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 7
106
+ segments:
107
+ - 3
108
+ - 0
109
+ - 0
110
+ segments_generated: true
111
+ version: 3.0.0
112
+ requirement: *id006
113
+ prerelease: false
114
+ type: :runtime
115
+ name: activerecord
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
125
+ segments_generated: true
126
+ version: "0"
127
+ requirement: *id007
128
+ prerelease: false
49
129
  type: :development
50
- version_requirements: *id002
130
+ name: pg
51
131
  description: Model-side logic for autocompleting belongs_to associations
52
132
  email: sskirby@gmail.com
53
133
  executables: []
@@ -57,7 +137,8 @@ extensions: []
57
137
  extra_rdoc_files:
58
138
  - README.markdown
59
139
  files:
60
- - .gitignore
140
+ - Gemfile
141
+ - Gemfile.lock
61
142
  - MIT-LICENSE
62
143
  - README.markdown
63
144
  - Rakefile
@@ -75,8 +156,8 @@ homepage: http://github.com/sskirby/autocomplete_for
75
156
  licenses: []
76
157
 
77
158
  post_install_message:
78
- rdoc_options:
79
- - --charset=UTF-8
159
+ rdoc_options: []
160
+
80
161
  require_paths:
81
162
  - lib
82
163
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -87,6 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
168
  hash: 3
88
169
  segments:
89
170
  - 0
171
+ segments_generated: true
90
172
  version: "0"
91
173
  required_rubygems_version: !ruby/object:Gem::Requirement
92
174
  none: false
@@ -96,6 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
178
  hash: 3
97
179
  segments:
98
180
  - 0
181
+ segments_generated: true
99
182
  version: "0"
100
183
  requirements: []
101
184
 
@@ -104,7 +187,5 @@ rubygems_version: 1.3.7
104
187
  signing_key:
105
188
  specification_version: 3
106
189
  summary: Model-side logic for autocompleting belongs_to associations
107
- test_files:
108
- - test/schema.rb
109
- - test/autocomplete_for_test.rb
110
- - test/test_helper.rb
190
+ test_files: []
191
+
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.log
2
- *.swp
3
- .rvmrc
4
- tags
5
- pkg