dupe 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dupe/attribute_template.rb +2 -2
- data/spec/lib_specs/dupe_spec.rb +28 -0
- metadata +2 -2
|
@@ -58,12 +58,12 @@ class Dupe
|
|
|
58
58
|
# ===> :title, 'test'
|
|
59
59
|
def generate(value=NilValue)
|
|
60
60
|
if value == NilValue
|
|
61
|
-
v = @default.respond_to?(:call) ? @default.call : @default
|
|
61
|
+
v = @default.respond_to?(:call) ? @default.call : (@default.dup rescue @default)
|
|
62
62
|
else
|
|
63
63
|
v = (@transformer ? @transformer.call(value) : value)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
return @name,
|
|
66
|
+
return @name, v
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
end
|
data/spec/lib_specs/dupe_spec.rb
CHANGED
|
@@ -433,4 +433,32 @@ describe Dupe do
|
|
|
433
433
|
end
|
|
434
434
|
|
|
435
435
|
end
|
|
436
|
+
|
|
437
|
+
describe "creating resources should not change definitions (regression test)" do
|
|
438
|
+
before do
|
|
439
|
+
Dupe.define :book do |book|
|
|
440
|
+
book.authors []
|
|
441
|
+
book.genre do
|
|
442
|
+
Dupe.find_or_create :genre, :name => 'Sci-fi'
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
it "should not add a record to the definition when the default value is an array" do
|
|
448
|
+
b = Dupe.create :book
|
|
449
|
+
a = Dupe.create :author
|
|
450
|
+
b.authors << a
|
|
451
|
+
b.authors.include?(a).should be_true
|
|
452
|
+
b2 = Dupe.create :book
|
|
453
|
+
b2.authors.should be_empty
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
it "should not dupe the value returned by a lazy attribute" do
|
|
457
|
+
b = Dupe.create :book
|
|
458
|
+
b2 = Dupe.create :book
|
|
459
|
+
b.genre.should == b2.genre
|
|
460
|
+
b.genre.name = 'Science Fiction'
|
|
461
|
+
b2.genre.name.should == 'Science Fiction'
|
|
462
|
+
end
|
|
463
|
+
end
|
|
436
464
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dupe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Parker
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-02-
|
|
12
|
+
date: 2010-02-12 00:00:00 -05:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|