super_list 1.2.0 → 1.2.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.
- data/Gemfile +1 -1
- data/Gemfile.lock +26 -26
- data/VERSION +1 -1
- data/lib/super_list.rb +3 -1
- data/test/dummy/app/models/user.rb +1 -0
- data/test/dummy/db/migrate/20110227014750_create_users.rb +1 -0
- data/test/factories.rb +1 -0
- data/test/super_list_test.rb +5 -0
- metadata +7 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,12 +2,12 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
abstract (1.0.0)
|
5
|
-
actionmailer (3.0.
|
6
|
-
actionpack (= 3.0.
|
5
|
+
actionmailer (3.0.5)
|
6
|
+
actionpack (= 3.0.5)
|
7
7
|
mail (~> 2.2.15)
|
8
|
-
actionpack (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
8
|
+
actionpack (3.0.5)
|
9
|
+
activemodel (= 3.0.5)
|
10
|
+
activesupport (= 3.0.5)
|
11
11
|
builder (~> 2.1.2)
|
12
12
|
erubis (~> 2.6.6)
|
13
13
|
i18n (~> 0.4)
|
@@ -15,20 +15,20 @@ GEM
|
|
15
15
|
rack-mount (~> 0.6.13)
|
16
16
|
rack-test (~> 0.5.7)
|
17
17
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
18
|
+
activemodel (3.0.5)
|
19
|
+
activesupport (= 3.0.5)
|
20
20
|
builder (~> 2.1.2)
|
21
21
|
i18n (~> 0.4)
|
22
|
-
activerecord (3.0.
|
23
|
-
activemodel (= 3.0.
|
24
|
-
activesupport (= 3.0.
|
22
|
+
activerecord (3.0.5)
|
23
|
+
activemodel (= 3.0.5)
|
24
|
+
activesupport (= 3.0.5)
|
25
25
|
arel (~> 2.0.2)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
30
|
-
activesupport (3.0.
|
31
|
-
arel (2.0.
|
27
|
+
activeresource (3.0.5)
|
28
|
+
activemodel (= 3.0.5)
|
29
|
+
activesupport (= 3.0.5)
|
30
|
+
activesupport (3.0.5)
|
31
|
+
arel (2.0.9)
|
32
32
|
builder (2.1.2)
|
33
33
|
capybara (0.4.1.1)
|
34
34
|
celerity (>= 0.7.9)
|
@@ -68,17 +68,17 @@ GEM
|
|
68
68
|
rack (>= 1.0.0)
|
69
69
|
rack-test (0.5.7)
|
70
70
|
rack (>= 1.0)
|
71
|
-
rails (3.0.
|
72
|
-
actionmailer (= 3.0.
|
73
|
-
actionpack (= 3.0.
|
74
|
-
activerecord (= 3.0.
|
75
|
-
activeresource (= 3.0.
|
76
|
-
activesupport (= 3.0.
|
71
|
+
rails (3.0.5)
|
72
|
+
actionmailer (= 3.0.5)
|
73
|
+
actionpack (= 3.0.5)
|
74
|
+
activerecord (= 3.0.5)
|
75
|
+
activeresource (= 3.0.5)
|
76
|
+
activesupport (= 3.0.5)
|
77
77
|
bundler (~> 1.0)
|
78
|
-
railties (= 3.0.
|
79
|
-
railties (3.0.
|
80
|
-
actionpack (= 3.0.
|
81
|
-
activesupport (= 3.0.
|
78
|
+
railties (= 3.0.5)
|
79
|
+
railties (3.0.5)
|
80
|
+
actionpack (= 3.0.5)
|
81
|
+
activesupport (= 3.0.5)
|
82
82
|
rake (>= 0.8.7)
|
83
83
|
thor (~> 0.14.4)
|
84
84
|
rake (0.8.7)
|
@@ -107,6 +107,6 @@ DEPENDENCIES
|
|
107
107
|
capybara (>= 0.4.0)
|
108
108
|
factory_girl
|
109
109
|
jeweler (~> 1.5.2)
|
110
|
-
rails (= 3.0.
|
110
|
+
rails (= 3.0.5)
|
111
111
|
rcov
|
112
112
|
sqlite3-ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/lib/super_list.rb
CHANGED
@@ -79,7 +79,9 @@ module SuperListActiveRecord
|
|
79
79
|
data = SuperList[data]
|
80
80
|
options = data.options.merge(options)
|
81
81
|
|
82
|
-
|
82
|
+
unless options[:no_validation]
|
83
|
+
validates_inclusion_of original_column, { :in => data.keys }.merge(options)
|
84
|
+
end
|
83
85
|
|
84
86
|
define_method "#{column}" do |*opt|
|
85
87
|
opt = opt[0].is_a?(Hash) ? opt[0] : {}
|
@@ -2,4 +2,5 @@ class User < ActiveRecord::Base
|
|
2
2
|
super_list :gender, 'Gender'
|
3
3
|
super_list :gender1, 'Gender', :allow_blank => false, :use_i18n => true
|
4
4
|
super_list :gender2, 'Gender', :use_i18n => true, :i18n_default => '未知'
|
5
|
+
super_list :gender3, 'Gender', :use_i18n => true, :i18n_default => '未知', :no_validation => true
|
5
6
|
end
|
data/test/factories.rb
CHANGED
data/test/super_list_test.rb
CHANGED
@@ -27,6 +27,11 @@ class SuperListTest < ActiveSupport::TestCase
|
|
27
27
|
assert !Factory.build(:user, :gender1 => '').valid?
|
28
28
|
end
|
29
29
|
|
30
|
+
test "no validations for gender2" do
|
31
|
+
assert Factory.build(:user, :gender3 => 'A').valid?
|
32
|
+
assert Factory.build(:user, :gender3 => 'M').valid?
|
33
|
+
end
|
34
|
+
|
30
35
|
test "SuperList gender (don't use i18n)" do
|
31
36
|
u = Factory(:user, :gender => 'F')
|
32
37
|
assert_equal u.gender.to_s, 'Female'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jinzhu
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-09 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -85,12 +85,12 @@ dependencies:
|
|
85
85
|
requirements:
|
86
86
|
- - "="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
hash:
|
88
|
+
hash: 13
|
89
89
|
segments:
|
90
90
|
- 3
|
91
91
|
- 0
|
92
|
-
-
|
93
|
-
version: 3.0.
|
92
|
+
- 5
|
93
|
+
version: 3.0.5
|
94
94
|
requirement: *id005
|
95
95
|
prerelease: false
|
96
96
|
name: rails
|