assignable_values 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/Rakefile +10 -12
- data/assignable_values.gemspec +2 -3
- data/lib/assignable_values/active_record/restriction/base.rb +1 -1
- data/lib/assignable_values/active_record/restriction/scalar_attribute.rb +4 -1
- data/lib/assignable_values/version.rb +1 -1
- data/spec/rails-2.3/Gemfile +0 -1
- data/spec/rails-2.3/Gemfile.lock +1 -8
- data/spec/rails-3.0/Gemfile +0 -1
- data/spec/rails-3.0/Gemfile.lock +1 -8
- data/spec/rails-3.2/Gemfile +0 -1
- data/spec/rails-3.2/Gemfile.lock +1 -8
- data/spec/shared/app_root/app/models/song.rb +2 -0
- data/spec/shared/app_root/config/locales/en.yml +3 -0
- data/spec/shared/assignable_values/active_record_spec.rb +26 -0
- metadata +75 -7
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.8.7
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -5,22 +5,16 @@ desc 'Default: Run all specs.'
|
|
5
5
|
task :default => 'all:spec'
|
6
6
|
|
7
7
|
|
8
|
-
namespace :
|
9
|
-
|
10
|
-
desc '
|
11
|
-
task :
|
12
|
-
end
|
8
|
+
namespace :travis do
|
9
|
+
|
10
|
+
desc 'Run tests on Travis CI'
|
11
|
+
task :run => ['slimgems', 'all:bundle:install', 'all:spec']
|
13
12
|
|
14
13
|
desc 'Install slimgems'
|
15
14
|
task :slimgems do
|
16
15
|
system('gem install slimgems')
|
17
16
|
end
|
18
17
|
|
19
|
-
desc 'Disable rubygems-bundler magic'
|
20
|
-
task :disable_rubygems_bundler do
|
21
|
-
ENV['NOEXEC_DISABLE'] = '1'
|
22
|
-
end
|
23
|
-
|
24
18
|
end
|
25
19
|
|
26
20
|
namespace :all do
|
@@ -40,14 +34,18 @@ namespace :all do
|
|
40
34
|
desc "Bundle all spec apps"
|
41
35
|
task :install do
|
42
36
|
for_each_directory_of('spec/**/Gemfile') do |directory|
|
43
|
-
|
37
|
+
Bundler.with_clean_env do
|
38
|
+
system("cd #{directory} && bundle install")
|
39
|
+
end
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
47
43
|
desc "Update all gems, or a list of gem given by the GEM environment variable"
|
48
44
|
task :update do
|
49
45
|
for_each_directory_of('spec/**/Gemfile') do |directory|
|
50
|
-
|
46
|
+
Bundler.with_clean_env do
|
47
|
+
system("cd #{directory} && bundle update #{ENV['GEM']}")
|
48
|
+
end
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
data/assignable_values.gemspec
CHANGED
@@ -11,9 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = s.summary
|
12
12
|
s.license = 'MIT'
|
13
13
|
|
14
|
-
s.files = `git ls-files`.split(
|
15
|
-
s.test_files =
|
16
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
s.test_files = s.files.grep(%r{^spec/})
|
17
16
|
s.require_paths = ["lib"]
|
18
17
|
|
19
18
|
s.add_dependency('activerecord')
|
data/spec/rails-2.3/Gemfile
CHANGED
data/spec/rails-2.3/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.9.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
@@ -18,12 +18,6 @@ GEM
|
|
18
18
|
activesupport (= 2.3.17)
|
19
19
|
activesupport (2.3.17)
|
20
20
|
columnize (0.3.6)
|
21
|
-
debugger (1.6.1)
|
22
|
-
columnize (>= 0.3.1)
|
23
|
-
debugger-linecache (~> 1.2.0)
|
24
|
-
debugger-ruby_core_source (~> 1.2.3)
|
25
|
-
debugger-linecache (1.2.0)
|
26
|
-
debugger-ruby_core_source (1.2.3)
|
27
21
|
hoe (2.8.0)
|
28
22
|
rake (>= 0.8.7)
|
29
23
|
linecache (0.46)
|
@@ -61,7 +55,6 @@ PLATFORMS
|
|
61
55
|
|
62
56
|
DEPENDENCIES
|
63
57
|
assignable_values!
|
64
|
-
debugger
|
65
58
|
hoe (= 2.8.0)
|
66
59
|
rails (~> 2.3.10)
|
67
60
|
rspec (< 2)
|
data/spec/rails-3.0/Gemfile
CHANGED
data/spec/rails-3.0/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.9.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
@@ -37,12 +37,6 @@ GEM
|
|
37
37
|
arel (2.0.10)
|
38
38
|
builder (2.1.2)
|
39
39
|
columnize (0.3.6)
|
40
|
-
debugger (1.6.1)
|
41
|
-
columnize (>= 0.3.1)
|
42
|
-
debugger-linecache (~> 1.2.0)
|
43
|
-
debugger-ruby_core_source (~> 1.2.3)
|
44
|
-
debugger-linecache (1.2.0)
|
45
|
-
debugger-ruby_core_source (1.2.3)
|
46
40
|
diff-lcs (1.2.1)
|
47
41
|
erubis (2.6.6)
|
48
42
|
abstract (>= 1.0.0)
|
@@ -117,7 +111,6 @@ PLATFORMS
|
|
117
111
|
|
118
112
|
DEPENDENCIES
|
119
113
|
assignable_values!
|
120
|
-
debugger
|
121
114
|
rails (~> 3.0.3)
|
122
115
|
rspec
|
123
116
|
rspec-rails
|
data/spec/rails-3.2/Gemfile
CHANGED
data/spec/rails-3.2/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.9.0)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
@@ -37,12 +37,6 @@ GEM
|
|
37
37
|
arel (3.0.2)
|
38
38
|
builder (3.0.4)
|
39
39
|
columnize (0.3.6)
|
40
|
-
debugger (1.6.1)
|
41
|
-
columnize (>= 0.3.1)
|
42
|
-
debugger-linecache (~> 1.2.0)
|
43
|
-
debugger-ruby_core_source (~> 1.2.3)
|
44
|
-
debugger-linecache (1.2.0)
|
45
|
-
debugger-ruby_core_source (1.2.3)
|
46
40
|
diff-lcs (1.2.1)
|
47
41
|
erubis (2.7.0)
|
48
42
|
hike (1.2.1)
|
@@ -127,7 +121,6 @@ PLATFORMS
|
|
127
121
|
|
128
122
|
DEPENDENCIES
|
129
123
|
assignable_values!
|
130
|
-
debugger
|
131
124
|
rails (~> 3.2)
|
132
125
|
rspec
|
133
126
|
rspec-rails
|
@@ -13,6 +13,32 @@ describe AssignableValues::ActiveRecord do
|
|
13
13
|
end.to raise_error(AssignableValues::NoValuesGiven)
|
14
14
|
end
|
15
15
|
|
16
|
+
context 'when validation virtual attributes' do
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
@klass = Song.disposable_copy do
|
20
|
+
assignable_values_for :sub_genre do
|
21
|
+
%w[pop rock]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should validate that the attribute is allowed' do
|
27
|
+
@klass.new(:sub_genre => 'pop').should be_valid
|
28
|
+
@klass.new(:sub_genre => 'disallowed value').should_not be_valid
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not allow nil for the attribute value' do
|
32
|
+
@klass.new(:sub_genre => nil).should_not be_valid
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should generate a method returning the humanized value' do
|
36
|
+
song = @klass.new(:sub_genre => 'pop')
|
37
|
+
song.humanized_sub_genre.should == 'Pop music'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
16
42
|
context 'when validating scalar attributes' do
|
17
43
|
|
18
44
|
context 'without options' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assignable_values
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Henning Koch
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2014-04-17 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ extra_rdoc_files: []
|
|
102
102
|
files:
|
103
103
|
- .gitignore
|
104
104
|
- .rspec
|
105
|
+
- .ruby-version
|
105
106
|
- .travis.yml
|
106
107
|
- LICENSE
|
107
108
|
- README.md
|
@@ -218,5 +219,72 @@ rubygems_version: 1.3.9.5
|
|
218
219
|
signing_key:
|
219
220
|
specification_version: 3
|
220
221
|
summary: Restrict the values assignable to ActiveRecord attributes or associations. Or enums on steroids.
|
221
|
-
test_files:
|
222
|
-
|
222
|
+
test_files:
|
223
|
+
- spec/rails-2.3/Gemfile
|
224
|
+
- spec/rails-2.3/Gemfile.lock
|
225
|
+
- spec/rails-2.3/Rakefile
|
226
|
+
- spec/rails-2.3/app_root/config/boot.rb
|
227
|
+
- spec/rails-2.3/app_root/config/database.yml
|
228
|
+
- spec/rails-2.3/app_root/config/environment.rb
|
229
|
+
- spec/rails-2.3/app_root/config/environments/test.rb
|
230
|
+
- spec/rails-2.3/app_root/config/preinitializer.rb
|
231
|
+
- spec/rails-2.3/app_root/config/routes.rb
|
232
|
+
- spec/rails-2.3/app_root/lib/console_with_fixtures.rb
|
233
|
+
- spec/rails-2.3/app_root/log/.gitignore
|
234
|
+
- spec/rails-2.3/app_root/script/console
|
235
|
+
- spec/rails-2.3/rcov.opts
|
236
|
+
- spec/rails-2.3/spec.opts
|
237
|
+
- spec/rails-2.3/spec/spec_helper.rb
|
238
|
+
- spec/rails-3.0/.rspec
|
239
|
+
- spec/rails-3.0/Gemfile
|
240
|
+
- spec/rails-3.0/Gemfile.lock
|
241
|
+
- spec/rails-3.0/Rakefile
|
242
|
+
- spec/rails-3.0/app_root/.gitignore
|
243
|
+
- spec/rails-3.0/app_root/config/application.rb
|
244
|
+
- spec/rails-3.0/app_root/config/boot.rb
|
245
|
+
- spec/rails-3.0/app_root/config/database.yml
|
246
|
+
- spec/rails-3.0/app_root/config/environment.rb
|
247
|
+
- spec/rails-3.0/app_root/config/environments/test.rb
|
248
|
+
- spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb
|
249
|
+
- spec/rails-3.0/app_root/config/initializers/inflections.rb
|
250
|
+
- spec/rails-3.0/app_root/config/initializers/mime_types.rb
|
251
|
+
- spec/rails-3.0/app_root/config/initializers/secret_token.rb
|
252
|
+
- spec/rails-3.0/app_root/config/initializers/session_store.rb
|
253
|
+
- spec/rails-3.0/app_root/config/routes.rb
|
254
|
+
- spec/rails-3.0/app_root/lib/tasks/.gitkeep
|
255
|
+
- spec/rails-3.0/app_root/log/.gitkeep
|
256
|
+
- spec/rails-3.0/app_root/script/rails
|
257
|
+
- spec/rails-3.0/rcov.opts
|
258
|
+
- spec/rails-3.0/spec/spec_helper.rb
|
259
|
+
- spec/rails-3.2/.rspec
|
260
|
+
- spec/rails-3.2/Gemfile
|
261
|
+
- spec/rails-3.2/Gemfile.lock
|
262
|
+
- spec/rails-3.2/Rakefile
|
263
|
+
- spec/rails-3.2/app_root/.gitignore
|
264
|
+
- spec/rails-3.2/app_root/config/application.rb
|
265
|
+
- spec/rails-3.2/app_root/config/boot.rb
|
266
|
+
- spec/rails-3.2/app_root/config/database.yml
|
267
|
+
- spec/rails-3.2/app_root/config/environment.rb
|
268
|
+
- spec/rails-3.2/app_root/config/environments/test.rb
|
269
|
+
- spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb
|
270
|
+
- spec/rails-3.2/app_root/config/initializers/inflections.rb
|
271
|
+
- spec/rails-3.2/app_root/config/initializers/mime_types.rb
|
272
|
+
- spec/rails-3.2/app_root/config/initializers/secret_token.rb
|
273
|
+
- spec/rails-3.2/app_root/config/initializers/session_store.rb
|
274
|
+
- spec/rails-3.2/app_root/config/routes.rb
|
275
|
+
- spec/rails-3.2/app_root/lib/tasks/.gitkeep
|
276
|
+
- spec/rails-3.2/app_root/log/.gitkeep
|
277
|
+
- spec/rails-3.2/app_root/script/rails
|
278
|
+
- spec/rails-3.2/rcov.opts
|
279
|
+
- spec/rails-3.2/spec/spec_helper.rb
|
280
|
+
- spec/shared/app_root/app/controllers/application_controller.rb
|
281
|
+
- spec/shared/app_root/app/helpers/application_helper.rb
|
282
|
+
- spec/shared/app_root/app/models/artist.rb
|
283
|
+
- spec/shared/app_root/app/models/recording/vinyl.rb
|
284
|
+
- spec/shared/app_root/app/models/song.rb
|
285
|
+
- spec/shared/app_root/config/locales/en.yml
|
286
|
+
- spec/shared/app_root/db/migrate/001_create_artists.rb
|
287
|
+
- spec/shared/app_root/db/migrate/002_create_songs.rb
|
288
|
+
- spec/shared/app_root/db/migrate/003_create_recordings.rb
|
289
|
+
- spec/shared/assignable_values/active_record_spec.rb
|
290
|
+
- spec/shared/assignable_values/humanized_value_spec.rb
|