sample_models 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
@@ -9,7 +9,8 @@ module SampleModels
9
9
 
10
10
  def belongs_to_assoc(column_name)
11
11
  model.belongs_to_associations.detect { |assoc|
12
- assoc.foreign_key == column_name
12
+ assoc.foreign_key == column_name ||
13
+ assoc.foreign_type == column_name
13
14
  }
14
15
  end
15
16
 
@@ -72,6 +72,14 @@ module SampleModels
72
72
  @assoc.primary_key_name
73
73
  end
74
74
  end
75
+
76
+ def foreign_type
77
+ if @assoc.respond_to?(:foreign_type)
78
+ @assoc.foreign_type
79
+ else
80
+ @assoc.instance_variable_get(:@options)[:foreign_type]
81
+ end
82
+ end
75
83
 
76
84
  def has_many?
77
85
  @assoc.macro == :has_many
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sample_models"
8
- s.version = "2.3.0"
8
+ s.version = "2.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Francis Hwang"]
12
- s.date = "2012-03-10"
12
+ s.date = "2012-03-19"
13
13
  s.description = "\nA library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:\n\n* meet all your validations automatically\n* only make you specify the attributes you care about\n* give you a rich set of features so you can specify associated values as concisely as possible\n* do this with as little configuration as possible\n"
14
14
  s.email = "francis.hwang@profitably.com"
15
15
  s.extra_rdoc_files = [
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + "/../test_helper"
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '/../test_helper'))
2
2
 
3
3
  class PolymorphicBelongsToTest < SampleModelsTestCase
4
4
  def test_fills_association_with_anything_from_another_class
@@ -12,6 +12,11 @@ class PolymorphicBelongsToTest < SampleModelsTestCase
12
12
  blog_post = BlogPost.sample
13
13
  bookmark = Bookmark.sample :bookmarkable => blog_post
14
14
  assert_equal blog_post, bookmark.bookmarkable
15
+ assert(
16
+ Bookmark.all(
17
+ :conditions => {:bookmarkable_type => 'BlogPost'}
18
+ ).include?(bookmark)
19
+ )
15
20
  end
16
21
 
17
22
  def test_can_specify_association_with_other_leading_associations
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sample_models
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.3.0
5
+ version: 2.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Francis Hwang
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-10 00:00:00 Z
13
+ date: 2012-03-19 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord