sample_models 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,24 +1,24 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activerecord (2.3.5)
5
- activesupport (= 2.3.5)
6
- activesupport (2.3.5)
4
+ activerecord (2.3.10)
5
+ activesupport (= 2.3.10)
6
+ activesupport (2.3.10)
7
7
  git (1.2.5)
8
8
  jeweler (1.6.0)
9
9
  bundler (~> 1.0.0)
10
10
  git (>= 1.2.5)
11
11
  rake
12
12
  rake (0.8.7)
13
- sqlite3 (1.3.3)
13
+ sqlite3 (1.3.4)
14
14
  validates_email_format_of (1.4.5)
15
15
 
16
16
  PLATFORMS
17
17
  ruby
18
18
 
19
19
  DEPENDENCIES
20
- activerecord (= 2.3.5)
21
- activesupport (= 2.3.5)
20
+ activerecord (= 2.3.10)
21
+ activesupport (= 2.3.10)
22
22
  bundler (~> 1.0.0)
23
23
  jeweler (~> 1.6.0)
24
24
  sqlite3
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
4
  require 'rubygems'
5
5
 
6
- ActiveRecordVersions = %w(3.0.1 2.3.10 2.3.5)
6
+ ActiveRecordVersions = %w(3.1.1 3.0.1 2.3.10)
7
7
 
8
8
  desc "Run all tests"
9
9
  task :test do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.2.5
@@ -21,7 +21,7 @@ module SampleModels
21
21
  end
22
22
 
23
23
  def run
24
- @instance = @sampler.model_class.new @attrs
24
+ @instance = @sampler.model_class.new @attrs.to_hash
25
25
  save!
26
26
  update_associations
27
27
  @instance
@@ -72,7 +72,12 @@ module SampleModels
72
72
  fill_based_on_string_column_type(column)
73
73
  when :integer
74
74
  unless model.belongs_to_associations.any? { |assoc|
75
- assoc.primary_key_name == column.name
75
+ foreign_key = if assoc.respond_to?(:foreign_key)
76
+ assoc.foreign_key
77
+ else
78
+ assoc.primary_key_name
79
+ end
80
+ foreign_key == column.name
76
81
  }
77
82
  self[column.name] = 1
78
83
  end
@@ -31,8 +31,13 @@ module SampleModels
31
31
 
32
32
  def attach_belongs_to_associations_to_query
33
33
  @model.belongs_to_associations.each do |assoc|
34
+ foreign_key = if assoc.respond_to?(:foreign_key)
35
+ assoc.foreign_key
36
+ else
37
+ assoc.primary_key_name
38
+ end
34
39
  if @attrs.keys.include?(assoc.name.to_s)
35
- @ar_query.conditions[assoc.primary_key_name] = if @attrs[assoc.name]
40
+ @ar_query.conditions[foreign_key] = if @attrs[assoc.name]
36
41
  @attrs[assoc.name].id
37
42
  else
38
43
  @attrs[assoc.name]
@@ -49,8 +49,12 @@ module SampleModels
49
49
  def fix_deleted_associations(instance, orig_attrs)
50
50
  needs_save = false
51
51
  model.belongs_to_associations.each do |assoc|
52
- if instance.send(assoc.primary_key_name) &&
53
- !instance.send(assoc.name)
52
+ foreign_key = if assoc.respond_to?(:foreign_key)
53
+ assoc.foreign_key
54
+ else
55
+ assoc.primary_key_name
56
+ end
57
+ if instance.send(foreign_key) && !instance.send(assoc.name)
54
58
  instance.send("#{assoc.name}=", assoc.klass.sample)
55
59
  needs_save = true
56
60
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sample_models}
8
- s.version = "1.2.4"
8
+ s.version = "1.2.5"
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 = %q{2011-07-16}
12
+ s.date = %q{2011-11-16}
13
13
  s.description = %q{
14
14
  A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
15
15
 
@@ -58,11 +58,10 @@ A library for making it extremely fast for Rails developers to set up and save A
58
58
  s.homepage = %q{http://github.com/fhwang/sample_models}
59
59
  s.licenses = ["MIT"]
60
60
  s.require_paths = ["lib"]
61
- s.rubygems_version = %q{1.3.7}
61
+ s.rubygems_version = %q{1.6.2}
62
62
  s.summary = %q{A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases}
63
63
 
64
64
  if s.respond_to? :specification_version then
65
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
66
65
  s.specification_version = 3
67
66
 
68
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sample_models
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Francis Hwang
@@ -15,11 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-16 00:00:00 -04:00
18
+ date: 2011-11-16 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ name: activerecord
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
25
26
  - - ">="
@@ -28,12 +29,12 @@ dependencies:
28
29
  segments:
29
30
  - 0
30
31
  version: "0"
31
- type: :runtime
32
- name: activerecord
33
32
  prerelease: false
34
- version_requirements: *id001
33
+ type: :runtime
34
+ requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ name: activesupport
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
39
40
  - - ">="
@@ -42,12 +43,12 @@ dependencies:
42
43
  segments:
43
44
  - 0
44
45
  version: "0"
45
- type: :runtime
46
- name: activesupport
47
46
  prerelease: false
48
- version_requirements: *id002
47
+ type: :runtime
48
+ requirement: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ name: bundler
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
51
52
  none: false
52
53
  requirements:
53
54
  - - ~>
@@ -58,12 +59,12 @@ dependencies:
58
59
  - 0
59
60
  - 0
60
61
  version: 1.0.0
61
- type: :development
62
- name: bundler
63
62
  prerelease: false
64
- version_requirements: *id003
63
+ type: :development
64
+ requirement: *id003
65
65
  - !ruby/object:Gem::Dependency
66
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ name: jeweler
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
68
  none: false
68
69
  requirements:
69
70
  - - ~>
@@ -74,10 +75,9 @@ dependencies:
74
75
  - 6
75
76
  - 0
76
77
  version: 1.6.0
77
- type: :development
78
- name: jeweler
79
78
  prerelease: false
80
- version_requirements: *id004
79
+ type: :development
80
+ requirement: *id004
81
81
  description: |
82
82
 
83
83
  A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases. It aims to:
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements: []
157
157
 
158
158
  rubyforge_project:
159
- rubygems_version: 1.3.7
159
+ rubygems_version: 1.6.2
160
160
  signing_key:
161
161
  specification_version: 3
162
162
  summary: A library for making it extremely fast for Rails developers to set up and save ActiveRecord instances when writing test cases