polymorphic_identity 0.0.2 → 0.0.3
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/CHANGELOG +21 -0
- data/README +14 -3
- data/Rakefile +3 -4
- data/test/{app_root/test/fixtures → fixtures}/articles.yml +0 -0
- data/test/{app_root/test/fixtures → fixtures}/authors.yml +0 -0
- data/test/{app_root/test/fixtures → fixtures}/comments.yml +0 -0
- data/test/{app_root/test/fixtures → fixtures}/pages.yml +0 -0
- data/test/{app_root/test/fixtures → fixtures}/users.yml +0 -0
- data/test/unit/polymorphic_identity_test.rb +4 -8
- metadata +21 -29
data/CHANGELOG
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*SVN*
|
2
|
+
|
3
|
+
*0.0.3* (September 26th, 2007)
|
4
|
+
|
5
|
+
* Move test fixtures out of the test application root directory
|
6
|
+
|
7
|
+
* Remove gem dependency on activerecord
|
8
|
+
|
9
|
+
*0.0.2* (August 5th, 2007)
|
10
|
+
|
11
|
+
* Add api documentation
|
12
|
+
|
13
|
+
* Fix Rakefile syntax errors
|
14
|
+
|
15
|
+
* Refactor tests
|
16
|
+
|
17
|
+
* Use the plugin_test_helper plugin for helping create a Rails environment
|
18
|
+
|
19
|
+
*0.0.1* (February 12th, 2007)
|
20
|
+
|
21
|
+
* Initial release
|
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= polymorphic_identity
|
2
2
|
|
3
|
-
polymorphic_identity dynamically generates aliases for polymorphic associations
|
3
|
+
+polymorphic_identity+ dynamically generates aliases for polymorphic associations
|
4
4
|
based on the class names of those associations.
|
5
5
|
|
6
6
|
== Resources
|
@@ -44,7 +44,9 @@ dynamically checking the name of the polymorphic record's class and creating
|
|
44
44
|
methods that allow you to access the polymorphic association based on that
|
45
45
|
class name.
|
46
46
|
|
47
|
-
==
|
47
|
+
== Usage
|
48
|
+
|
49
|
+
=== Example
|
48
50
|
|
49
51
|
class Comment < ActiveRecord::Base
|
50
52
|
belongs_to :commentable,
|
@@ -71,4 +73,13 @@ class name.
|
|
71
73
|
>> c.commenter
|
72
74
|
=> #<User:0xb775d764 @attributes={"id"=>"1"}>
|
73
75
|
>> c.user
|
74
|
-
=> #<User:0xb775d764 @attributes={"id"=>"1"}>
|
76
|
+
=> #<User:0xb775d764 @attributes={"id"=>"1"}>
|
77
|
+
|
78
|
+
== Testing
|
79
|
+
|
80
|
+
Before you can run any tests, the following gem must be installed:
|
81
|
+
* plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
|
82
|
+
|
83
|
+
== Dependencies
|
84
|
+
|
85
|
+
This plugin does not depend on the presence of any other plugin.
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
|
|
4
4
|
require 'rake/contrib/sshpublisher'
|
5
5
|
|
6
6
|
PKG_NAME = 'polymorphic_identity'
|
7
|
-
PKG_VERSION = '0.0.
|
7
|
+
PKG_VERSION = '0.0.3'
|
8
8
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
9
9
|
RUBY_FORGE_PROJECT = 'pluginaweek'
|
10
10
|
|
@@ -33,12 +33,11 @@ spec = Gem::Specification.new do |s|
|
|
33
33
|
s.platform = Gem::Platform::RUBY
|
34
34
|
s.summary = 'Dynamically generates aliases for polymorphic associations based on their class names'
|
35
35
|
|
36
|
-
s.files = FileList['{lib,tasks,test}/**/*'].to_a + %w(init.rb MIT-LICENSE Rakefile README)
|
36
|
+
s.files = FileList['{lib,tasks,test}/**/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
|
37
37
|
s.require_path = 'lib'
|
38
38
|
s.autorequire = 'polymorphic_identity'
|
39
39
|
s.has_rdoc = true
|
40
40
|
s.test_files = Dir['test/**/*_test.rb']
|
41
|
-
s.add_dependency 'activerecord', '>= 1.15.0'
|
42
41
|
|
43
42
|
s.author = 'Aaron Pfeifer, Neil Abraham'
|
44
43
|
s.email = 'info@pluginaweek.org'
|
@@ -77,4 +76,4 @@ task :release => [:gem, :package] do
|
|
77
76
|
|
78
77
|
ruby_forge.add_release(RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, file)
|
79
78
|
end
|
80
|
-
end
|
79
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,28 +1,24 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
Comment.class_eval do
|
4
|
-
public :find_polymorphic_association_name
|
5
|
-
end
|
6
|
-
|
7
3
|
class PolymorphicIdentityTest < Test::Unit::TestCase
|
8
4
|
fixtures :authors, :articles, :pages, :users, :comments
|
9
5
|
|
10
6
|
def test_should_find_polymorphic_association_name_for_valid_symbolized_association
|
11
7
|
c = Comment.new
|
12
8
|
c.commenter_type = 'Article'
|
13
|
-
assert_equal :commenter, c.
|
9
|
+
assert_equal :commenter, c.send(:find_polymorphic_association_name, :article)
|
14
10
|
end
|
15
11
|
|
16
12
|
def test_should_find_polymorphic_association_name_for_valid_stringified_association
|
17
13
|
c = Comment.new
|
18
14
|
c.commenter_type = 'Article'
|
19
|
-
assert_equal :commenter, c.find_polymorphic_association_name
|
15
|
+
assert_equal :commenter, c.send(:find_polymorphic_association_name, 'article')
|
20
16
|
end
|
21
17
|
|
22
18
|
def test_should_not_find_polymorphic_association_name_for_invalid_association
|
23
19
|
c = Comment.new
|
24
20
|
c.commenter_type = 'Article'
|
25
|
-
assert_equal nil, c.find_polymorphic_association_name
|
21
|
+
assert_equal nil, c.send(:find_polymorphic_association_name, 'page')
|
26
22
|
end
|
27
23
|
|
28
24
|
def test_should_not_respond_to_polymorhic_association_name_if_association_is_nil
|
@@ -63,4 +59,4 @@ class PolymorphicIdentityTest < Test::Unit::TestCase
|
|
63
59
|
assert_equal pages(:about), c.page
|
64
60
|
assert_equal users(:anonymous), c.user
|
65
61
|
end
|
66
|
-
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: polymorphic_identity
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2007-09-26 00:00:00 -04:00
|
8
8
|
summary: Dynamically generates aliases for polymorphic associations based on their class names
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,31 +30,31 @@ authors:
|
|
30
30
|
- Aaron Pfeifer, Neil Abraham
|
31
31
|
files:
|
32
32
|
- lib/polymorphic_identity.rb
|
33
|
+
- test/test_helper.rb
|
34
|
+
- test/fixtures
|
33
35
|
- test/app_root
|
36
|
+
- test/unit
|
37
|
+
- test/fixtures/users.yml
|
38
|
+
- test/fixtures/authors.yml
|
39
|
+
- test/fixtures/articles.yml
|
40
|
+
- test/fixtures/comments.yml
|
41
|
+
- test/fixtures/pages.yml
|
34
42
|
- test/app_root/app
|
43
|
+
- test/app_root/db
|
35
44
|
- test/app_root/app/models
|
36
|
-
- test/app_root/app/models/article.rb
|
37
45
|
- test/app_root/app/models/author.rb
|
38
|
-
- test/app_root/app/models/
|
39
|
-
- test/app_root/app/models/page.rb
|
46
|
+
- test/app_root/app/models/article.rb
|
40
47
|
- test/app_root/app/models/user.rb
|
41
|
-
- test/app_root/
|
48
|
+
- test/app_root/app/models/page.rb
|
49
|
+
- test/app_root/app/models/comment.rb
|
42
50
|
- test/app_root/db/migrate
|
43
|
-
- test/app_root/db/migrate/001_create_authors.rb
|
44
|
-
- test/app_root/db/migrate/002_create_articles.rb
|
45
|
-
- test/app_root/db/migrate/003_create_pages.rb
|
46
51
|
- test/app_root/db/migrate/004_create_users.rb
|
47
52
|
- test/app_root/db/migrate/005_create_comments.rb
|
48
|
-
- test/app_root/
|
49
|
-
- test/app_root/
|
50
|
-
- test/app_root/
|
51
|
-
- test/app_root/test/fixtures/authors.yml
|
52
|
-
- test/app_root/test/fixtures/comments.yml
|
53
|
-
- test/app_root/test/fixtures/pages.yml
|
54
|
-
- test/app_root/test/fixtures/users.yml
|
55
|
-
- test/test_helper.rb
|
56
|
-
- test/unit
|
53
|
+
- test/app_root/db/migrate/002_create_articles.rb
|
54
|
+
- test/app_root/db/migrate/003_create_pages.rb
|
55
|
+
- test/app_root/db/migrate/001_create_authors.rb
|
57
56
|
- test/unit/polymorphic_identity_test.rb
|
57
|
+
- CHANGELOG
|
58
58
|
- init.rb
|
59
59
|
- MIT-LICENSE
|
60
60
|
- Rakefile
|
@@ -71,13 +71,5 @@ extensions: []
|
|
71
71
|
|
72
72
|
requirements: []
|
73
73
|
|
74
|
-
dependencies:
|
75
|
-
|
76
|
-
name: activerecord
|
77
|
-
version_requirement:
|
78
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.15.0
|
83
|
-
version:
|
74
|
+
dependencies: []
|
75
|
+
|