assignable_values 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task :default => 'all:spec'
8
8
  namespace :travis_ci do
9
9
 
10
10
  desc 'Things to do before Travis CI begins'
11
- task :prepare => :slimgems do
11
+ task :prepare => [:disable_rubygems_bundler, :slimgems] do
12
12
  end
13
13
 
14
14
  desc 'Install slimgems'
@@ -16,6 +16,11 @@ namespace :travis_ci do
16
16
  system('gem install slimgems')
17
17
  end
18
18
 
19
+ desc 'Disable rubygems-bundler magic'
20
+ task :disable_rubygems_bundler do
21
+ ENV['NOEXEC_DISABLE'] = '1'
22
+ end
23
+
19
24
  end
20
25
 
21
26
  namespace :all do
@@ -10,7 +10,12 @@ module AssignableValues
10
10
  end
11
11
 
12
12
  def association_id_method
13
- "#{property}_id"
13
+ association = model.reflect_on_association(property)
14
+ if association.respond_to?(:foreign_key)
15
+ association.foreign_key # Rails >= 3.1
16
+ else
17
+ association.primary_key_name # Rails 2 + 3.0
18
+ end
14
19
  end
15
20
 
16
21
  def error_property
@@ -1,3 +1,3 @@
1
1
  module AssignableValues
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.7.2)
4
+ assignable_values (0.8.1)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.7.2)
4
+ assignable_values (0.8.1)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- assignable_values (0.7.2)
4
+ assignable_values (0.8.1)
5
5
  activerecord
6
6
 
7
7
  GEM
@@ -186,6 +186,18 @@ describe AssignableValues::ActiveRecord do
186
186
  error.should == I18n.t('errors.messages.inclusion')
187
187
  end
188
188
 
189
+ it 'uses the defined foreign key of the association' do
190
+ klass = Song.disposable_copy do
191
+ belongs_to :creator, :foreign_key => 'artist_id', :class_name => 'Artist'
192
+
193
+ assignable_values_for :creator do
194
+ []
195
+ end
196
+ end
197
+
198
+ klass.new(:creator => Artist.new).should have(1).error_on(:artist_id)
199
+ end
200
+
189
201
  it 'should allow a nil association if the :allow_blank option is set' do
190
202
  klass = Song.disposable_copy do
191
203
  assignable_values_for :artist, :allow_blank => true 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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
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-11-27 00:00:00 +01:00
18
+ date: 2013-12-03 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency