attribute_delegator 0.0.1 → 0.0.2
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/attribute_delegator.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
class TestAttributeDelegator < Test::Unit::TestCase
|
16
16
|
def setup
|
17
|
-
@entry = Entry.create!(:title => "Entry Title"
|
17
|
+
@entry = Entry.create!(:title => "Entry Title")
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_delegated_attributes_getters_and_setters
|
@@ -6,7 +6,7 @@ class Entry < ActiveRecord::Base
|
|
6
6
|
delegates_attributes_to :entry_metadata, [:page_views]
|
7
7
|
|
8
8
|
has_one :entry_photo
|
9
|
-
delegates_attributes_to :entry_photo, [:photo]
|
9
|
+
delegates_attributes_to :entry_photo, [:format, :photo]
|
10
10
|
end
|
11
11
|
|
12
12
|
class EntryMetadata < ActiveRecord::Base
|
@@ -21,16 +21,13 @@ end
|
|
21
21
|
|
22
22
|
|
23
23
|
class TestMultipleAttributeDelegators < Test::Unit::TestCase
|
24
|
-
def setup
|
25
|
-
@entry = Entry.create!(:title => "Entry Title", :body => "Body of entry")
|
26
|
-
end
|
27
|
-
|
28
24
|
def test_working_with_multiple_delegates
|
29
25
|
page_views = 10
|
30
26
|
photo = "ok pretend this string is a photo"
|
31
27
|
e = Entry.create!({
|
32
28
|
:page_views => page_views,
|
33
|
-
:photo => photo
|
29
|
+
:photo => photo,
|
30
|
+
:format => 'jpeg'
|
34
31
|
})
|
35
32
|
assert_equal photo, e.photo
|
36
33
|
assert_equal photo, e.entry_photo.photo
|
data/test/setup.rb
CHANGED
@@ -13,7 +13,6 @@ ActiveRecord::Base.establish_connection({
|
|
13
13
|
ActiveRecord::Schema.define do
|
14
14
|
create_table "entries", :force => true do |t|
|
15
15
|
t.column "title", :string
|
16
|
-
t.column "body", :text
|
17
16
|
end
|
18
17
|
|
19
18
|
create_table "entry_metadata", :force => true do |t|
|
@@ -23,6 +22,7 @@ ActiveRecord::Schema.define do
|
|
23
22
|
|
24
23
|
create_table "entry_photos", :force => true do |t|
|
25
24
|
t.column "entry_id", :integer
|
26
|
-
t.column "photo", :text
|
25
|
+
t.column "photo", :text, :null => false
|
26
|
+
t.column "format", :string, :null => false
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute_delegator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Clif Reeder
|