autolink 0.0.2 → 1.0.0
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/README.rdoc
CHANGED
@@ -14,10 +14,10 @@ Then add this to your 'spec/spec_helper.rb', under the line that requires 'spec/
|
|
14
14
|
|
15
15
|
Now add this to any models that you want to autolink:
|
16
16
|
|
17
|
-
def
|
18
|
-
[:path, :to, :model,
|
17
|
+
def default_lineage
|
18
|
+
[:path, :to, :model, parent, self]
|
19
19
|
end
|
20
20
|
|
21
|
-
This default lineage works exactly like ActionController's PolymorphicRouting lineage (since that's what it is...).
|
21
|
+
This default lineage works exactly like ActionController's PolymorphicRouting lineage (since that's what it is...).
|
22
22
|
|
23
23
|
I make no guarantees that this will work for you.
|
data/autolink.gemspec
CHANGED
data/lib/autolink.rb
CHANGED
@@ -4,8 +4,8 @@ module ActionView
|
|
4
4
|
def url_for(options = {})
|
5
5
|
options ||= {}
|
6
6
|
url = case options
|
7
|
-
when ActiveRecord::Base
|
8
|
-
polymorphic_path(options.
|
7
|
+
when ActiveRecord::Base # This method is the same as 2.3.8,
|
8
|
+
polymorphic_path(options.default_lineage) # Except for the addition of these two lines.
|
9
9
|
when String
|
10
10
|
escape = true
|
11
11
|
options
|
data/lib/autolink/rspec.rb
CHANGED
@@ -21,5 +21,36 @@ module Spec
|
|
21
21
|
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
module Mocks
|
26
|
+
|
27
|
+
def __post_mock_model(model_class, mock)
|
28
|
+
|
29
|
+
mock.__send__(:__mock_proxy).instance_eval <<-CODE
|
30
|
+
def @target.default_lineage
|
31
|
+
# self == @target
|
32
|
+
syms = __mock_proxy.instance_variable_get("@stubs").map(&:sym)
|
33
|
+
@__sub = #{model_class}.new
|
34
|
+
syms.each do |sym|
|
35
|
+
# Define this method to call the same method on @target.
|
36
|
+
that = self
|
37
|
+
(class << @__sub; self; end).send(:define_method, sym) do
|
38
|
+
that.send(sym)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@__sub.default_lineage
|
42
|
+
end
|
43
|
+
CODE
|
44
|
+
|
45
|
+
mock
|
46
|
+
end
|
47
|
+
|
48
|
+
alias __mock_model mock_model
|
49
|
+
def mock_model(model_class, options_and_stubs = {})
|
50
|
+
mock = __mock_model(model_class, options_and_stubs)
|
51
|
+
__post_mock_model(model_class, mock)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
24
55
|
end
|
25
56
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autolink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Burke Libbey
|
@@ -30,7 +30,6 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- lib/autolink/action_controller_extensions.rb
|
32
32
|
- lib/autolink/action_view_extensions.rb
|
33
|
-
- lib/autolink/active_record_extensions.rb
|
34
33
|
- lib/autolink/rspec.rb
|
35
34
|
- lib/autolink.rb
|
36
35
|
- spec/spec_helper.rb
|