assignable_values 0.6.1 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +15 -0
- data/README.md +3 -2
- data/Rakefile +12 -1
- data/lib/assignable_values/active_record/restriction/base.rb +8 -4
- data/lib/assignable_values/version.rb +1 -1
- data/spec/rails-2.3/Gemfile +4 -2
- data/spec/rails-2.3/Gemfile.lock +37 -21
- data/spec/rails-2.3/{spec_helper.rb → spec/spec_helper.rb} +4 -4
- data/spec/rails-3.0/Gemfile +3 -2
- data/spec/rails-3.0/Gemfile.lock +67 -52
- data/spec/rails-3.0/app_root/config/application.rb +1 -1
- data/spec/rails-3.0/app_root/config/environment.rb +1 -1
- data/spec/rails-3.0/app_root/config/environments/test.rb +1 -1
- data/spec/rails-3.0/app_root/config/initializers/secret_token.rb +1 -1
- data/spec/rails-3.0/app_root/config/initializers/session_store.rb +2 -2
- data/spec/rails-3.0/app_root/config/routes.rb +1 -1
- data/spec/rails-3.0/{spec_helper.rb → spec/spec_helper.rb} +3 -4
- data/spec/rails-3.2/Gemfile +2 -1
- data/spec/rails-3.2/Gemfile.lock +62 -51
- data/spec/rails-3.2/app_root/config/application.rb +1 -1
- data/spec/rails-3.2/app_root/config/environment.rb +1 -1
- data/spec/rails-3.2/app_root/config/environments/test.rb +1 -1
- data/spec/rails-3.2/app_root/config/initializers/secret_token.rb +1 -1
- data/spec/rails-3.2/app_root/config/initializers/session_store.rb +2 -2
- data/spec/rails-3.2/app_root/config/routes.rb +1 -1
- data/spec/rails-3.2/{spec_helper.rb → spec/spec_helper.rb} +3 -4
- data/spec/shared/app_root/app/helpers/application_helper.rb +3 -0
- data/spec/shared/assignable_values/active_record_spec.rb +20 -1
- metadata +90 -100
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
assignable_values - Enums on vitamins
|
1
|
+
assignable_values - Enums on vitamins [![Build Status](https://secure.travis-ci.org/makandra/assignable_values.png?branch=master)](https://travis-ci.org/makandra/assignable_values)
|
2
2
|
=====================================
|
3
3
|
|
4
4
|
`assignable_values` lets you restrict the values that can be assigned to attributes or associations of ActiveRecord models. You can think of it as enums where the list of allowed values is generated at runtime and the value is checked during validation.
|
5
5
|
|
6
|
-
We carefully enhanced the
|
6
|
+
We carefully enhanced the core enum functionality with small tweaks that are useful for web forms, internationalized applications and common authorization patterns.
|
7
7
|
|
8
8
|
|
9
9
|
Restricting scalar attributes
|
@@ -23,6 +23,7 @@ The assigned value is checked during validation:
|
|
23
23
|
Song.new(:genre => 'elephant').valid? # => false
|
24
24
|
|
25
25
|
The validation error message is the same as the one from `validates_inclusion_of` (`errors.messages.inclusion` in your I18n dictionary).
|
26
|
+
You can also set a custom error message with the `:message` option.
|
26
27
|
|
27
28
|
|
28
29
|
### Listing assignable values
|
data/Rakefile
CHANGED
@@ -4,14 +4,25 @@ require 'bundler/gem_tasks'
|
|
4
4
|
desc 'Default: Run all specs.'
|
5
5
|
task :default => 'all:spec'
|
6
6
|
|
7
|
+
|
8
|
+
namespace :travis_ci do
|
9
|
+
|
10
|
+
desc 'Things to do before Travis CI begins'
|
11
|
+
task :prepare do
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
7
16
|
namespace :all do
|
8
17
|
|
9
18
|
desc "Run specs on all spec apps"
|
10
19
|
task :spec do
|
20
|
+
success = true
|
11
21
|
for_each_directory_of('spec/**/Rakefile') do |directory|
|
12
22
|
env = "SPEC=../../#{ENV['SPEC']} " if ENV['SPEC']
|
13
|
-
system("cd #{directory} && #{env} bundle exec rake spec")
|
23
|
+
success &= system("cd #{directory} && #{env} bundle exec rake spec")
|
14
24
|
end
|
25
|
+
fail "Tests failed" unless success
|
15
26
|
end
|
16
27
|
|
17
28
|
namespace :bundle do
|
@@ -34,7 +34,11 @@ module AssignableValues
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def not_included_error_message
|
37
|
-
|
37
|
+
if @options[:message]
|
38
|
+
@options[:message]
|
39
|
+
else
|
40
|
+
I18n.t('errors.messages.inclusion', :default => 'is not included in the list')
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def assignable_value?(record, value)
|
@@ -81,7 +85,7 @@ module AssignableValues
|
|
81
85
|
|
82
86
|
def evaluate_default(record, value_or_proc)
|
83
87
|
if value_or_proc.is_a?(Proc)
|
84
|
-
record.
|
88
|
+
record.instance_exec(&value_or_proc)
|
85
89
|
else
|
86
90
|
value_or_proc
|
87
91
|
end
|
@@ -181,7 +185,7 @@ module AssignableValues
|
|
181
185
|
if delegate?
|
182
186
|
values = assignable_values_from_delegate(record)
|
183
187
|
else
|
184
|
-
values = record.
|
188
|
+
values = record.instance_exec(&@values)
|
185
189
|
end
|
186
190
|
parse_values(values)
|
187
191
|
end
|
@@ -194,7 +198,7 @@ module AssignableValues
|
|
194
198
|
case option
|
195
199
|
when NilClass, TrueClass, FalseClass then option
|
196
200
|
when Symbol then record.send(option)
|
197
|
-
when Proc then record.
|
201
|
+
when Proc then record.instance_exec(&option)
|
198
202
|
else raise "Illegal option type: #{option.inspect}"
|
199
203
|
end
|
200
204
|
end
|
data/spec/rails-2.3/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'sqlite3'
|
4
|
-
gem '
|
4
|
+
gem 'test-unit', '=1.2.3', :platforms => :ruby_19
|
5
|
+
gem 'rails', '~>2.3.10'
|
5
6
|
gem 'rspec', '<2'
|
6
7
|
gem 'rspec-rails', '<2'
|
7
|
-
gem 'ruby-debug'
|
8
|
+
gem 'ruby-debug', :platforms => :ruby_18
|
9
|
+
gem 'debugger', :platforms => :ruby_19
|
8
10
|
gem 'rspec_candy'
|
9
11
|
gem 'assignable_values', :path => '../..'
|
data/spec/rails-2.3/Gemfile.lock
CHANGED
@@ -1,56 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.7.1)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (2.3.
|
11
|
-
actionpack (= 2.3.
|
12
|
-
actionpack (2.3.
|
13
|
-
activesupport (= 2.3.
|
10
|
+
actionmailer (2.3.17)
|
11
|
+
actionpack (= 2.3.17)
|
12
|
+
actionpack (2.3.17)
|
13
|
+
activesupport (= 2.3.17)
|
14
14
|
rack (~> 1.1.0)
|
15
|
-
activerecord (2.3.
|
16
|
-
activesupport (= 2.3.
|
17
|
-
activeresource (2.3.
|
18
|
-
activesupport (= 2.3.
|
19
|
-
activesupport (2.3.
|
15
|
+
activerecord (2.3.17)
|
16
|
+
activesupport (= 2.3.17)
|
17
|
+
activeresource (2.3.17)
|
18
|
+
activesupport (= 2.3.17)
|
19
|
+
activesupport (2.3.17)
|
20
20
|
columnize (0.3.6)
|
21
|
+
debugger (1.3.3)
|
22
|
+
columnize (>= 0.3.1)
|
23
|
+
debugger-linecache (~> 1.1.1)
|
24
|
+
debugger-ruby_core_source (~> 1.2.0)
|
25
|
+
debugger-linecache (1.1.2)
|
26
|
+
debugger-ruby_core_source (>= 1.1.1)
|
27
|
+
debugger-ruby_core_source (1.2.0)
|
28
|
+
hoe (3.5.1)
|
29
|
+
rake (>= 0.8, < 11.0)
|
21
30
|
linecache (0.46)
|
22
31
|
rbx-require-relative (> 0.0.4)
|
23
|
-
rack (1.1.
|
24
|
-
rails (2.3.
|
25
|
-
actionmailer (= 2.3.
|
26
|
-
actionpack (= 2.3.
|
27
|
-
activerecord (= 2.3.
|
28
|
-
activeresource (= 2.3.
|
29
|
-
activesupport (= 2.3.
|
32
|
+
rack (1.1.6)
|
33
|
+
rails (2.3.17)
|
34
|
+
actionmailer (= 2.3.17)
|
35
|
+
actionpack (= 2.3.17)
|
36
|
+
activerecord (= 2.3.17)
|
37
|
+
activeresource (= 2.3.17)
|
38
|
+
activesupport (= 2.3.17)
|
30
39
|
rake (>= 0.8.3)
|
31
|
-
rake (10.0.
|
40
|
+
rake (10.0.3)
|
32
41
|
rbx-require-relative (0.0.9)
|
33
42
|
rspec (1.3.2)
|
34
43
|
rspec-rails (1.3.4)
|
35
44
|
rack (>= 1.0.0)
|
36
45
|
rspec (~> 1.3.1)
|
37
|
-
rspec_candy (0.2.
|
46
|
+
rspec_candy (0.2.8)
|
38
47
|
rspec
|
48
|
+
sneaky-save
|
39
49
|
ruby-debug (0.10.4)
|
40
50
|
columnize (>= 0.1)
|
41
51
|
ruby-debug-base (~> 0.10.4.0)
|
42
52
|
ruby-debug-base (0.10.4)
|
43
53
|
linecache (>= 0.3)
|
44
|
-
|
54
|
+
sneaky-save (0.0.2)
|
55
|
+
activerecord (>= 2.3.2)
|
56
|
+
sqlite3 (1.3.7)
|
57
|
+
test-unit (1.2.3)
|
58
|
+
hoe (>= 1.5.1)
|
45
59
|
|
46
60
|
PLATFORMS
|
47
61
|
ruby
|
48
62
|
|
49
63
|
DEPENDENCIES
|
50
64
|
assignable_values!
|
51
|
-
|
65
|
+
debugger
|
66
|
+
rails (~> 2.3.10)
|
52
67
|
rspec (< 2)
|
53
68
|
rspec-rails (< 2)
|
54
69
|
rspec_candy
|
55
70
|
ruby-debug
|
56
71
|
sqlite3
|
72
|
+
test-unit (= 1.2.3)
|
@@ -1,10 +1,10 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__), "
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../../lib" )
|
2
2
|
|
3
|
-
|
4
|
-
ENV['
|
3
|
+
ENV['RAILS_ENV'] = 'test'
|
4
|
+
ENV['RAILS_ROOT'] = 'app_root'
|
5
5
|
|
6
6
|
# Load the Rails environment and testing framework
|
7
|
-
require "#{File.dirname(__FILE__)}
|
7
|
+
require "#{File.dirname(__FILE__)}/../app_root/config/environment"
|
8
8
|
require 'spec/rails'
|
9
9
|
require 'rspec_candy/all'
|
10
10
|
|
data/spec/rails-3.0/Gemfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'sqlite3'
|
4
|
-
gem 'rails', '
|
4
|
+
gem 'rails', '~>3.0.3'
|
5
5
|
gem 'rspec'
|
6
6
|
gem 'rspec-rails'
|
7
|
-
gem 'ruby-debug'
|
7
|
+
gem 'ruby-debug', :platforms => :ruby_18
|
8
|
+
gem 'debugger', :platforms => :ruby_19
|
8
9
|
gem 'rspec_candy'
|
9
10
|
gem 'assignable_values', :path => '../..'
|
10
11
|
|
data/spec/rails-3.0/Gemfile.lock
CHANGED
@@ -1,46 +1,54 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.7.1)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
-
actionmailer (3.0.
|
12
|
-
actionpack (= 3.0.
|
13
|
-
mail (~> 2.2.
|
14
|
-
actionpack (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
11
|
+
actionmailer (3.0.20)
|
12
|
+
actionpack (= 3.0.20)
|
13
|
+
mail (~> 2.2.19)
|
14
|
+
actionpack (3.0.20)
|
15
|
+
activemodel (= 3.0.20)
|
16
|
+
activesupport (= 3.0.20)
|
17
17
|
builder (~> 2.1.2)
|
18
18
|
erubis (~> 2.6.6)
|
19
|
-
i18n (~> 0.
|
20
|
-
rack (~> 1.2.
|
21
|
-
rack-mount (~> 0.6.
|
22
|
-
rack-test (~> 0.5.
|
19
|
+
i18n (~> 0.5.0)
|
20
|
+
rack (~> 1.2.5)
|
21
|
+
rack-mount (~> 0.6.14)
|
22
|
+
rack-test (~> 0.5.7)
|
23
23
|
tzinfo (~> 0.3.23)
|
24
|
-
activemodel (3.0.
|
25
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.20)
|
25
|
+
activesupport (= 3.0.20)
|
26
26
|
builder (~> 2.1.2)
|
27
|
-
i18n (~> 0.
|
28
|
-
activerecord (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
31
|
-
arel (~> 2.0.
|
27
|
+
i18n (~> 0.5.0)
|
28
|
+
activerecord (3.0.20)
|
29
|
+
activemodel (= 3.0.20)
|
30
|
+
activesupport (= 3.0.20)
|
31
|
+
arel (~> 2.0.10)
|
32
32
|
tzinfo (~> 0.3.23)
|
33
|
-
activeresource (3.0.
|
34
|
-
activemodel (= 3.0.
|
35
|
-
activesupport (= 3.0.
|
36
|
-
activesupport (3.0.
|
33
|
+
activeresource (3.0.20)
|
34
|
+
activemodel (= 3.0.20)
|
35
|
+
activesupport (= 3.0.20)
|
36
|
+
activesupport (3.0.20)
|
37
37
|
arel (2.0.10)
|
38
38
|
builder (2.1.2)
|
39
39
|
columnize (0.3.6)
|
40
|
-
|
40
|
+
debugger (1.3.3)
|
41
|
+
columnize (>= 0.3.1)
|
42
|
+
debugger-linecache (~> 1.1.1)
|
43
|
+
debugger-ruby_core_source (~> 1.2.0)
|
44
|
+
debugger-linecache (1.1.2)
|
45
|
+
debugger-ruby_core_source (>= 1.1.1)
|
46
|
+
debugger-ruby_core_source (1.2.0)
|
47
|
+
diff-lcs (1.2.1)
|
41
48
|
erubis (2.6.6)
|
42
49
|
abstract (>= 1.0.0)
|
43
|
-
i18n (0.
|
50
|
+
i18n (0.5.0)
|
51
|
+
json (1.7.7)
|
44
52
|
linecache (0.46)
|
45
53
|
rbx-require-relative (> 0.0.4)
|
46
54
|
mail (2.2.19)
|
@@ -48,51 +56,57 @@ GEM
|
|
48
56
|
i18n (>= 0.4.0)
|
49
57
|
mime-types (~> 1.16)
|
50
58
|
treetop (~> 1.4.8)
|
51
|
-
mime-types (1.
|
59
|
+
mime-types (1.21)
|
52
60
|
polyglot (0.3.3)
|
53
|
-
rack (1.2.
|
61
|
+
rack (1.2.8)
|
54
62
|
rack-mount (0.6.14)
|
55
63
|
rack (>= 1.0.0)
|
56
64
|
rack-test (0.5.7)
|
57
65
|
rack (>= 1.0)
|
58
|
-
rails (3.0.
|
59
|
-
actionmailer (= 3.0.
|
60
|
-
actionpack (= 3.0.
|
61
|
-
activerecord (= 3.0.
|
62
|
-
activeresource (= 3.0.
|
63
|
-
activesupport (= 3.0.
|
66
|
+
rails (3.0.20)
|
67
|
+
actionmailer (= 3.0.20)
|
68
|
+
actionpack (= 3.0.20)
|
69
|
+
activerecord (= 3.0.20)
|
70
|
+
activeresource (= 3.0.20)
|
71
|
+
activesupport (= 3.0.20)
|
64
72
|
bundler (~> 1.0)
|
65
|
-
railties (= 3.0.
|
66
|
-
railties (3.0.
|
67
|
-
actionpack (= 3.0.
|
68
|
-
activesupport (= 3.0.
|
73
|
+
railties (= 3.0.20)
|
74
|
+
railties (3.0.20)
|
75
|
+
actionpack (= 3.0.20)
|
76
|
+
activesupport (= 3.0.20)
|
69
77
|
rake (>= 0.8.7)
|
78
|
+
rdoc (~> 3.4)
|
70
79
|
thor (~> 0.14.4)
|
71
|
-
rake (10.0.
|
80
|
+
rake (10.0.3)
|
72
81
|
rbx-require-relative (0.0.9)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
rspec-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
rspec-
|
81
|
-
|
82
|
+
rdoc (3.12.2)
|
83
|
+
json (~> 1.4)
|
84
|
+
rspec (2.13.0)
|
85
|
+
rspec-core (~> 2.13.0)
|
86
|
+
rspec-expectations (~> 2.13.0)
|
87
|
+
rspec-mocks (~> 2.13.0)
|
88
|
+
rspec-core (2.13.0)
|
89
|
+
rspec-expectations (2.13.0)
|
90
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
91
|
+
rspec-mocks (2.13.0)
|
92
|
+
rspec-rails (2.13.0)
|
82
93
|
actionpack (>= 3.0)
|
83
94
|
activesupport (>= 3.0)
|
84
95
|
railties (>= 3.0)
|
85
|
-
rspec-core (~> 2.
|
86
|
-
rspec-expectations (~> 2.
|
87
|
-
rspec-mocks (~> 2.
|
88
|
-
rspec_candy (0.2.
|
96
|
+
rspec-core (~> 2.13.0)
|
97
|
+
rspec-expectations (~> 2.13.0)
|
98
|
+
rspec-mocks (~> 2.13.0)
|
99
|
+
rspec_candy (0.2.8)
|
89
100
|
rspec
|
101
|
+
sneaky-save
|
90
102
|
ruby-debug (0.10.4)
|
91
103
|
columnize (>= 0.1)
|
92
104
|
ruby-debug-base (~> 0.10.4.0)
|
93
105
|
ruby-debug-base (0.10.4)
|
94
106
|
linecache (>= 0.3)
|
95
|
-
|
107
|
+
sneaky-save (0.0.2)
|
108
|
+
activerecord (>= 2.3.2)
|
109
|
+
sqlite3 (1.3.7)
|
96
110
|
thor (0.14.6)
|
97
111
|
treetop (1.4.12)
|
98
112
|
polyglot
|
@@ -104,7 +118,8 @@ PLATFORMS
|
|
104
118
|
|
105
119
|
DEPENDENCIES
|
106
120
|
assignable_values!
|
107
|
-
|
121
|
+
debugger
|
122
|
+
rails (~> 3.0.3)
|
108
123
|
rspec
|
109
124
|
rspec-rails
|
110
125
|
rspec_candy
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
|
7
|
+
SpecApp::Application.config.secret_token = 'cb014a08a45243e7143f31e04774c342c1fba329fd594ae1a480d8283b1a851f425dc08044311fb4be6d000b6e6681de7c76d19148419a5ffa0a9f84556d3b33'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
|
3
|
+
SpecApp::Application.config.session_store :cookie_store, :key => '_app_root_session'
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
7
7
|
# (create the session table with "rails generate session_migration")
|
8
|
-
#
|
8
|
+
# SpecApp::Application.config.session_store :active_record_store
|
@@ -1,11 +1,10 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__), "
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../../lib" )
|
2
2
|
|
3
|
-
|
4
|
-
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
ENV['RAILS_ENV'] = 'test'
|
5
4
|
ENV['RAILS_ROOT'] = 'app_root'
|
6
5
|
|
7
6
|
# Load the Rails environment and testing framework
|
8
|
-
require "#{File.dirname(__FILE__)}
|
7
|
+
require "#{File.dirname(__FILE__)}/../app_root/config/environment"
|
9
8
|
require 'rspec/rails'
|
10
9
|
require 'rspec_candy/all'
|
11
10
|
|
data/spec/rails-3.2/Gemfile
CHANGED
data/spec/rails-3.2/Gemfile.lock
CHANGED
@@ -1,113 +1,123 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.7.1)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (3.2.
|
11
|
-
actionpack (= 3.2.
|
10
|
+
actionmailer (3.2.12)
|
11
|
+
actionpack (= 3.2.12)
|
12
12
|
mail (~> 2.4.4)
|
13
|
-
actionpack (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
actionpack (3.2.12)
|
14
|
+
activemodel (= 3.2.12)
|
15
|
+
activesupport (= 3.2.12)
|
16
16
|
builder (~> 3.0.0)
|
17
17
|
erubis (~> 2.7.0)
|
18
18
|
journey (~> 1.0.4)
|
19
|
-
rack (~> 1.4.
|
19
|
+
rack (~> 1.4.5)
|
20
20
|
rack-cache (~> 1.2)
|
21
21
|
rack-test (~> 0.6.1)
|
22
22
|
sprockets (~> 2.2.1)
|
23
|
-
activemodel (3.2.
|
24
|
-
activesupport (= 3.2.
|
23
|
+
activemodel (3.2.12)
|
24
|
+
activesupport (= 3.2.12)
|
25
25
|
builder (~> 3.0.0)
|
26
|
-
activerecord (3.2.
|
27
|
-
activemodel (= 3.2.
|
28
|
-
activesupport (= 3.2.
|
26
|
+
activerecord (3.2.12)
|
27
|
+
activemodel (= 3.2.12)
|
28
|
+
activesupport (= 3.2.12)
|
29
29
|
arel (~> 3.0.2)
|
30
30
|
tzinfo (~> 0.3.29)
|
31
|
-
activeresource (3.2.
|
32
|
-
activemodel (= 3.2.
|
33
|
-
activesupport (= 3.2.
|
34
|
-
activesupport (3.2.
|
31
|
+
activeresource (3.2.12)
|
32
|
+
activemodel (= 3.2.12)
|
33
|
+
activesupport (= 3.2.12)
|
34
|
+
activesupport (3.2.12)
|
35
35
|
i18n (~> 0.6)
|
36
36
|
multi_json (~> 1.0)
|
37
37
|
arel (3.0.2)
|
38
38
|
builder (3.0.4)
|
39
39
|
columnize (0.3.6)
|
40
|
-
|
40
|
+
debugger (1.3.3)
|
41
|
+
columnize (>= 0.3.1)
|
42
|
+
debugger-linecache (~> 1.1.1)
|
43
|
+
debugger-ruby_core_source (~> 1.2.0)
|
44
|
+
debugger-linecache (1.1.2)
|
45
|
+
debugger-ruby_core_source (>= 1.1.1)
|
46
|
+
debugger-ruby_core_source (1.2.0)
|
47
|
+
diff-lcs (1.2.1)
|
41
48
|
erubis (2.7.0)
|
42
49
|
hike (1.2.1)
|
43
|
-
i18n (0.6.
|
50
|
+
i18n (0.6.4)
|
44
51
|
journey (1.0.4)
|
45
|
-
json (1.7.
|
52
|
+
json (1.7.7)
|
46
53
|
linecache (0.46)
|
47
54
|
rbx-require-relative (> 0.0.4)
|
48
55
|
mail (2.4.4)
|
49
56
|
i18n (>= 0.4.0)
|
50
57
|
mime-types (~> 1.16)
|
51
58
|
treetop (~> 1.4.8)
|
52
|
-
mime-types (1.
|
53
|
-
multi_json (1.
|
59
|
+
mime-types (1.21)
|
60
|
+
multi_json (1.6.1)
|
54
61
|
polyglot (0.3.3)
|
55
|
-
rack (1.4.
|
62
|
+
rack (1.4.5)
|
56
63
|
rack-cache (1.2)
|
57
64
|
rack (>= 0.4)
|
58
|
-
rack-ssl (1.3.
|
65
|
+
rack-ssl (1.3.3)
|
59
66
|
rack
|
60
67
|
rack-test (0.6.2)
|
61
68
|
rack (>= 1.0)
|
62
|
-
rails (3.2.
|
63
|
-
actionmailer (= 3.2.
|
64
|
-
actionpack (= 3.2.
|
65
|
-
activerecord (= 3.2.
|
66
|
-
activeresource (= 3.2.
|
67
|
-
activesupport (= 3.2.
|
69
|
+
rails (3.2.12)
|
70
|
+
actionmailer (= 3.2.12)
|
71
|
+
actionpack (= 3.2.12)
|
72
|
+
activerecord (= 3.2.12)
|
73
|
+
activeresource (= 3.2.12)
|
74
|
+
activesupport (= 3.2.12)
|
68
75
|
bundler (~> 1.0)
|
69
|
-
railties (= 3.2.
|
70
|
-
railties (3.2.
|
71
|
-
actionpack (= 3.2.
|
72
|
-
activesupport (= 3.2.
|
76
|
+
railties (= 3.2.12)
|
77
|
+
railties (3.2.12)
|
78
|
+
actionpack (= 3.2.12)
|
79
|
+
activesupport (= 3.2.12)
|
73
80
|
rack-ssl (~> 1.3.2)
|
74
81
|
rake (>= 0.8.7)
|
75
82
|
rdoc (~> 3.4)
|
76
83
|
thor (>= 0.14.6, < 2.0)
|
77
|
-
rake (10.0.
|
84
|
+
rake (10.0.3)
|
78
85
|
rbx-require-relative (0.0.9)
|
79
|
-
rdoc (3.12)
|
86
|
+
rdoc (3.12.2)
|
80
87
|
json (~> 1.4)
|
81
|
-
rspec (2.
|
82
|
-
rspec-core (~> 2.
|
83
|
-
rspec-expectations (~> 2.
|
84
|
-
rspec-mocks (~> 2.
|
85
|
-
rspec-core (2.
|
86
|
-
rspec-expectations (2.
|
87
|
-
diff-lcs (
|
88
|
-
rspec-mocks (2.
|
89
|
-
rspec-rails (2.
|
88
|
+
rspec (2.13.0)
|
89
|
+
rspec-core (~> 2.13.0)
|
90
|
+
rspec-expectations (~> 2.13.0)
|
91
|
+
rspec-mocks (~> 2.13.0)
|
92
|
+
rspec-core (2.13.0)
|
93
|
+
rspec-expectations (2.13.0)
|
94
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
95
|
+
rspec-mocks (2.13.0)
|
96
|
+
rspec-rails (2.13.0)
|
90
97
|
actionpack (>= 3.0)
|
91
98
|
activesupport (>= 3.0)
|
92
99
|
railties (>= 3.0)
|
93
|
-
rspec-core (~> 2.
|
94
|
-
rspec-expectations (~> 2.
|
95
|
-
rspec-mocks (~> 2.
|
96
|
-
rspec_candy (0.2.
|
100
|
+
rspec-core (~> 2.13.0)
|
101
|
+
rspec-expectations (~> 2.13.0)
|
102
|
+
rspec-mocks (~> 2.13.0)
|
103
|
+
rspec_candy (0.2.8)
|
97
104
|
rspec
|
105
|
+
sneaky-save
|
98
106
|
ruby-debug (0.10.4)
|
99
107
|
columnize (>= 0.1)
|
100
108
|
ruby-debug-base (~> 0.10.4.0)
|
101
109
|
ruby-debug-base (0.10.4)
|
102
110
|
linecache (>= 0.3)
|
111
|
+
sneaky-save (0.0.4)
|
112
|
+
activerecord (>= 3.2.0)
|
103
113
|
sprockets (2.2.2)
|
104
114
|
hike (~> 1.2)
|
105
115
|
multi_json (~> 1.0)
|
106
116
|
rack (~> 1.0)
|
107
117
|
tilt (~> 1.1, != 1.3.0)
|
108
|
-
sqlite3 (1.3.
|
109
|
-
thor (0.
|
110
|
-
tilt (1.3.
|
118
|
+
sqlite3 (1.3.7)
|
119
|
+
thor (0.17.0)
|
120
|
+
tilt (1.3.4)
|
111
121
|
treetop (1.4.12)
|
112
122
|
polyglot
|
113
123
|
polyglot (>= 0.3.1)
|
@@ -118,6 +128,7 @@ PLATFORMS
|
|
118
128
|
|
119
129
|
DEPENDENCIES
|
120
130
|
assignable_values!
|
131
|
+
debugger
|
121
132
|
rails (~> 3.2)
|
122
133
|
rspec
|
123
134
|
rspec-rails
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
|
7
|
+
SpecApp::Application.config.secret_token = 'cb014a08a45243e7143f31e04774c342c1fba329fd594ae1a480d8283b1a851f425dc08044311fb4be6d000b6e6681de7c76d19148419a5ffa0a9f84556d3b33'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
|
3
|
+
SpecApp::Application.config.session_store :cookie_store, :key => '_app_root_session'
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
7
7
|
# (create the session table with "rails generate session_migration")
|
8
|
-
#
|
8
|
+
# SpecApp::Application.config.session_store :active_record_store
|
@@ -1,11 +1,10 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__), "
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../../lib" )
|
2
2
|
|
3
|
-
|
4
|
-
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
ENV['RAILS_ENV'] = 'test'
|
5
4
|
ENV['RAILS_ROOT'] = 'app_root'
|
6
5
|
|
7
6
|
# Load the Rails environment and testing framework
|
8
|
-
require "#{File.dirname(__FILE__)}
|
7
|
+
require "#{File.dirname(__FILE__)}/../app_root/config/environment"
|
9
8
|
require 'rspec/rails'
|
10
9
|
require 'rspec_candy/all'
|
11
10
|
|
@@ -112,7 +112,6 @@ describe AssignableValues::ActiveRecord do
|
|
112
112
|
|
113
113
|
context 'if the :allow_blank option is set to a lambda ' do
|
114
114
|
|
115
|
-
|
116
115
|
before :each do
|
117
116
|
@klass = Song.disposable_copy do
|
118
117
|
|
@@ -132,6 +131,26 @@ describe AssignableValues::ActiveRecord do
|
|
132
131
|
|
133
132
|
end
|
134
133
|
|
134
|
+
context 'if the :message option is set to a string' do
|
135
|
+
|
136
|
+
before :each do
|
137
|
+
@klass = Song.disposable_copy do
|
138
|
+
assignable_values_for :genre, :message => 'should be something different' do
|
139
|
+
%w[pop rock]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should use this string as a custom error message' do
|
145
|
+
record = @klass.new(:genre => 'disallowed value')
|
146
|
+
record.valid?
|
147
|
+
errors = record.errors[:genre]
|
148
|
+
error = errors.is_a?(Array) ? errors.first : errors # the return value sometimes was a string, sometimes an Array in Rails
|
149
|
+
error.should == 'should be something different'
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
135
154
|
end
|
136
155
|
|
137
156
|
context 'when validating belongs_to associations' do
|
metadata
CHANGED
@@ -1,107 +1,106 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: assignable_values
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 1
|
10
|
-
version: 0.6.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Henning Koch
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: activerecord
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rails
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
41
35
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 3
|
46
|
-
- 1
|
47
|
-
version: "3.1"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.1'
|
48
38
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rspec
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
41
|
none: false
|
55
|
-
requirements:
|
42
|
+
requirements:
|
56
43
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.8'
|
63
54
|
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: rspec-rails
|
67
55
|
prerelease: false
|
68
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
57
|
none: false
|
70
|
-
requirements:
|
58
|
+
requirements:
|
71
59
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.8'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.8'
|
78
70
|
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: sqlite3
|
82
71
|
prerelease: false
|
83
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
73
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.8'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sqlite3
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
92
86
|
type: :development
|
93
|
-
|
94
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Restrict the values assignable to ActiveRecord attributes or associations.
|
95
|
+
Or enums on steroids.
|
95
96
|
email: henning.koch@makandra.de
|
96
97
|
executables: []
|
97
|
-
|
98
98
|
extensions: []
|
99
|
-
|
100
99
|
extra_rdoc_files: []
|
101
|
-
|
102
|
-
files:
|
100
|
+
files:
|
103
101
|
- .gitignore
|
104
102
|
- .rspec
|
103
|
+
- .travis.yml
|
105
104
|
- README.md
|
106
105
|
- Rakefile
|
107
106
|
- assignable_values.gemspec
|
@@ -127,7 +126,7 @@ files:
|
|
127
126
|
- spec/rails-2.3/app_root/script/console
|
128
127
|
- spec/rails-2.3/rcov.opts
|
129
128
|
- spec/rails-2.3/spec.opts
|
130
|
-
- spec/rails-2.3/spec_helper.rb
|
129
|
+
- spec/rails-2.3/spec/spec_helper.rb
|
131
130
|
- spec/rails-3.0/.rspec
|
132
131
|
- spec/rails-3.0/Gemfile
|
133
132
|
- spec/rails-3.0/Gemfile.lock
|
@@ -148,7 +147,7 @@ files:
|
|
148
147
|
- spec/rails-3.0/app_root/log/.gitkeep
|
149
148
|
- spec/rails-3.0/app_root/script/rails
|
150
149
|
- spec/rails-3.0/rcov.opts
|
151
|
-
- spec/rails-3.0/spec_helper.rb
|
150
|
+
- spec/rails-3.0/spec/spec_helper.rb
|
152
151
|
- spec/rails-3.2/.rspec
|
153
152
|
- spec/rails-3.2/Gemfile
|
154
153
|
- spec/rails-3.2/Gemfile.lock
|
@@ -169,8 +168,9 @@ files:
|
|
169
168
|
- spec/rails-3.2/app_root/log/.gitkeep
|
170
169
|
- spec/rails-3.2/app_root/script/rails
|
171
170
|
- spec/rails-3.2/rcov.opts
|
172
|
-
- spec/rails-3.2/spec_helper.rb
|
171
|
+
- spec/rails-3.2/spec/spec_helper.rb
|
173
172
|
- spec/shared/app_root/app/controllers/application_controller.rb
|
173
|
+
- spec/shared/app_root/app/helpers/application_helper.rb
|
174
174
|
- spec/shared/app_root/app/models/artist.rb
|
175
175
|
- spec/shared/app_root/app/models/recording/vinyl.rb
|
176
176
|
- spec/shared/app_root/app/models/song.rb
|
@@ -180,39 +180,29 @@ files:
|
|
180
180
|
- spec/shared/app_root/db/migrate/003_create_recordings.rb
|
181
181
|
- spec/shared/assignable_values/active_record_spec.rb
|
182
182
|
- spec/shared/assignable_values/humanized_value_spec.rb
|
183
|
-
has_rdoc: true
|
184
183
|
homepage: https://github.com/makandra/assignable_values
|
185
184
|
licenses: []
|
186
|
-
|
187
185
|
post_install_message:
|
188
186
|
rdoc_options: []
|
189
|
-
|
190
|
-
require_paths:
|
187
|
+
require_paths:
|
191
188
|
- lib
|
192
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
190
|
none: false
|
194
|
-
requirements:
|
195
|
-
- -
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
|
198
|
-
|
199
|
-
- 0
|
200
|
-
version: "0"
|
201
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ! '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
196
|
none: false
|
203
|
-
requirements:
|
204
|
-
- -
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
|
207
|
-
segments:
|
208
|
-
- 0
|
209
|
-
version: "0"
|
197
|
+
requirements:
|
198
|
+
- - ! '>='
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
210
201
|
requirements: []
|
211
|
-
|
212
202
|
rubyforge_project:
|
213
|
-
rubygems_version: 1.
|
203
|
+
rubygems_version: 1.8.25
|
214
204
|
signing_key:
|
215
205
|
specification_version: 3
|
216
|
-
summary: Restrict the values assignable to ActiveRecord attributes or associations.
|
206
|
+
summary: Restrict the values assignable to ActiveRecord attributes or associations.
|
207
|
+
Or enums on steroids.
|
217
208
|
test_files: []
|
218
|
-
|