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.
@@ -0,0 +1 @@
1
+ 1.8.7
@@ -5,11 +5,11 @@ rvm:
5
5
  - ree
6
6
  services:
7
7
  - mysql
8
- before_script: rake travis_ci:prepare
9
- script: rake all:bundle:install all:spec
8
+ script: rake travis:run
10
9
  notifications:
11
10
  email:
12
11
  - fail@makandra.de
13
12
  branches:
14
13
  only:
15
14
  - master
15
+ - travis-testing
data/Rakefile CHANGED
@@ -5,22 +5,16 @@ desc 'Default: Run all specs.'
5
5
  task :default => 'all:spec'
6
6
 
7
7
 
8
- namespace :travis_ci do
9
-
10
- desc 'Things to do before Travis CI begins'
11
- task :prepare => [:disable_rubygems_bundler, :slimgems] do
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
- system("cd #{directory} && bundle install")
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
- system("cd #{directory} && bundle update #{ENV['GEM']}")
46
+ Bundler.with_clean_env do
47
+ system("cd #{directory} && bundle update #{ENV['GEM']}")
48
+ end
51
49
  end
52
50
  end
53
51
 
@@ -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("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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')
@@ -92,7 +92,7 @@ module AssignableValues
92
92
  end
93
93
 
94
94
  def parse_values(values)
95
- { :values => values.to_a }
95
+ { :values => Array(values) }
96
96
  end
97
97
 
98
98
  def current_value(record)
@@ -89,7 +89,10 @@ module AssignableValues
89
89
  end
90
90
 
91
91
  def previously_saved_value(record)
92
- record.send("#{property}_was")
92
+ was_method_name = "#{property}_was"
93
+ if record.respond_to?(was_method_name)
94
+ record.send(was_method_name)
95
+ end
93
96
  end
94
97
 
95
98
  end
@@ -1,3 +1,3 @@
1
1
  module AssignableValues
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -7,6 +7,5 @@ gem 'rails', '~>2.3.10'
7
7
  gem 'rspec', '<2'
8
8
  gem 'rspec-rails', '<2'
9
9
  gem 'ruby-debug', :platforms => :ruby_18
10
- gem 'debugger', :platforms => :ruby_19
11
10
  gem 'rspec_candy'
12
11
  gem 'assignable_values', :path => '../..'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.8.1)
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)
@@ -5,7 +5,6 @@ gem 'rails', '~>3.0.3'
5
5
  gem 'rspec'
6
6
  gem 'rspec-rails'
7
7
  gem 'ruby-debug', :platforms => :ruby_18
8
- gem 'debugger', :platforms => :ruby_19
9
8
  gem 'rspec_candy'
10
9
  gem 'assignable_values', :path => '../..'
11
10
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.8.1)
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
@@ -5,7 +5,6 @@ gem 'rails', '~>3.2'
5
5
  gem 'rspec'
6
6
  gem 'rspec-rails'
7
7
  gem 'ruby-debug', :platforms => :ruby_18
8
- gem 'debugger', :platforms => :ruby_19
9
8
  gem 'rspec_candy'
10
9
  gem 'assignable_values', :path => '../..'
11
10
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.8.1)
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
@@ -2,4 +2,6 @@ class Song < ActiveRecord::Base
2
2
 
3
3
  belongs_to :artist
4
4
 
5
+ attr_accessor :sub_genre
6
+
5
7
  end
@@ -12,6 +12,9 @@ en:
12
12
  genre:
13
13
  pop: 'Pop music'
14
14
  rock: 'Rock music'
15
+ sub_genre:
16
+ pop: 'Pop music'
17
+ rock: 'Rock music'
15
18
  year:
16
19
  '1977': 'The year a new hope was born'
17
20
  '1980': 'The year the Empire stroke back'
@@ -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: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 1
10
- version: 0.8.1
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: 2013-12-03 00:00:00 +01:00
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