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 +6 -6
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sample_models/creation.rb +7 -2
- data/lib/sample_models/finder.rb +6 -1
- data/lib/sample_models/sampler.rb +6 -2
- data/sample_models.gemspec +3 -4
- metadata +22 -22
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
|
-
activesupport (= 2.3.
|
6
|
-
activesupport (2.3.
|
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.
|
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.
|
21
|
-
activesupport (= 2.3.
|
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
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
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
|
-
|
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
|
data/lib/sample_models/finder.rb
CHANGED
@@ -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[
|
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
|
53
|
-
|
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
|
data/sample_models.gemspec
CHANGED
@@ -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.
|
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-
|
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.
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
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-
|
18
|
+
date: 2011-11-16 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
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
|
-
|
33
|
+
type: :runtime
|
34
|
+
requirement: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
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
|
-
|
47
|
+
type: :runtime
|
48
|
+
requirement: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
|
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
|
-
|
63
|
+
type: :development
|
64
|
+
requirement: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
-
|
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
|
-
|
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.
|
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
|