decent_decoration 0.0.6 → 0.1.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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +134 -102
- data/LICENSE.txt +2 -2
- data/README.md +5 -3
- data/decent_decoration.gemspec +8 -6
- data/lib/decent_decoration/decorate.rb +6 -7
- data/lib/decent_decoration/version.rb +1 -1
- data/spec/decoration_spec.rb +21 -21
- data/spec/fixtures/controllers.rb +4 -12
- data/spec/fixtures/fake_rails_application.rb +7 -11
- data/spec/integration/draper_spec.rb +3 -3
- data/spec/integration/rails_application_spec.rb +8 -8
- metadata +28 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 675e5cca86a5c81f3cccc32a847bfae584b6e567
|
|
4
|
+
data.tar.gz: 4671f0e9906c0334084b145825ff87cd57257de3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a75179eead1974c0cd04ce3cd7e5aa952970c48747da2472981349dbf1081b8a89c500a48daf83d57bcd83eaebcab75b4b6b724e075fddbe6481762c912dfd3
|
|
7
|
+
data.tar.gz: 6a7a969661910ce530fbe2c9c4072a56f234dc92170942b468394af4462b748884e3d07488197fe3eb48b87a112836a14c50fad52f5df67862005288eee20663
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,127 +1,159 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
decent_decoration (0.0
|
|
5
|
-
decent_exposure (
|
|
4
|
+
decent_decoration (0.1.0)
|
|
5
|
+
decent_exposure (~> 3.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actionmailer (4.
|
|
11
|
-
actionpack (= 4.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
actionmailer (4.2.6)
|
|
11
|
+
actionpack (= 4.2.6)
|
|
12
|
+
actionview (= 4.2.6)
|
|
13
|
+
activejob (= 4.2.6)
|
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
16
|
+
actionpack (4.2.6)
|
|
17
|
+
actionview (= 4.2.6)
|
|
18
|
+
activesupport (= 4.2.6)
|
|
19
|
+
rack (~> 1.6)
|
|
18
20
|
rack-test (~> 0.6.2)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
23
|
+
actionview (4.2.6)
|
|
24
|
+
activesupport (= 4.2.6)
|
|
25
|
+
builder (~> 3.1)
|
|
26
|
+
erubis (~> 2.7.0)
|
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
29
|
+
activejob (4.2.6)
|
|
30
|
+
activesupport (= 4.2.6)
|
|
31
|
+
globalid (>= 0.3.0)
|
|
32
|
+
activemodel (4.2.6)
|
|
33
|
+
activesupport (= 4.2.6)
|
|
34
|
+
builder (~> 3.1)
|
|
35
|
+
activerecord (4.2.6)
|
|
36
|
+
activemodel (= 4.2.6)
|
|
37
|
+
activesupport (= 4.2.6)
|
|
38
|
+
arel (~> 6.0)
|
|
39
|
+
activesupport (4.2.6)
|
|
40
|
+
i18n (~> 0.7)
|
|
41
|
+
json (~> 1.7, >= 1.7.7)
|
|
42
|
+
minitest (~> 5.1)
|
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
44
|
+
tzinfo (~> 1.1)
|
|
45
|
+
arel (6.0.3)
|
|
46
|
+
builder (3.2.2)
|
|
47
|
+
concurrent-ruby (1.0.2)
|
|
48
|
+
coveralls (0.8.14)
|
|
49
|
+
json (>= 1.8, < 3)
|
|
50
|
+
simplecov (~> 0.12.0)
|
|
51
|
+
term-ansicolor (~> 1.3)
|
|
52
|
+
thor (~> 0.19.1)
|
|
53
|
+
tins (~> 1.6.0)
|
|
54
|
+
decent_exposure (3.0.0)
|
|
55
|
+
activesupport (>= 4.0)
|
|
56
|
+
diff-lcs (1.2.5)
|
|
57
|
+
docile (1.1.5)
|
|
58
|
+
draper (2.1.0)
|
|
47
59
|
actionpack (>= 3.0)
|
|
60
|
+
activemodel (>= 3.0)
|
|
48
61
|
activesupport (>= 3.0)
|
|
49
|
-
request_store (~> 1.0
|
|
62
|
+
request_store (~> 1.0)
|
|
50
63
|
erubis (2.7.0)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
globalid (0.3.6)
|
|
65
|
+
activesupport (>= 4.1.0)
|
|
66
|
+
i18n (0.7.0)
|
|
67
|
+
json (1.8.3)
|
|
68
|
+
loofah (2.0.3)
|
|
69
|
+
nokogiri (>= 1.5.9)
|
|
70
|
+
mail (2.6.4)
|
|
71
|
+
mime-types (>= 1.16, < 4)
|
|
72
|
+
mime-types (3.1)
|
|
73
|
+
mime-types-data (~> 3.2015)
|
|
74
|
+
mime-types-data (3.2016.0521)
|
|
75
|
+
mini_portile2 (2.1.0)
|
|
76
|
+
minitest (5.9.0)
|
|
77
|
+
nokogiri (1.6.8)
|
|
78
|
+
mini_portile2 (~> 2.1.0)
|
|
79
|
+
pkg-config (~> 1.1.7)
|
|
80
|
+
pkg-config (1.1.7)
|
|
81
|
+
rack (1.6.4)
|
|
82
|
+
rack-test (0.6.3)
|
|
62
83
|
rack (>= 1.0)
|
|
63
|
-
rails (4.
|
|
64
|
-
actionmailer (= 4.
|
|
65
|
-
actionpack (= 4.
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
rails (4.2.6)
|
|
85
|
+
actionmailer (= 4.2.6)
|
|
86
|
+
actionpack (= 4.2.6)
|
|
87
|
+
actionview (= 4.2.6)
|
|
88
|
+
activejob (= 4.2.6)
|
|
89
|
+
activemodel (= 4.2.6)
|
|
90
|
+
activerecord (= 4.2.6)
|
|
91
|
+
activesupport (= 4.2.6)
|
|
68
92
|
bundler (>= 1.3.0, < 2.0)
|
|
69
|
-
railties (= 4.
|
|
70
|
-
sprockets-rails
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
railties (= 4.2.6)
|
|
94
|
+
sprockets-rails
|
|
95
|
+
rails-deprecated_sanitizer (1.0.3)
|
|
96
|
+
activesupport (>= 4.2.0.alpha)
|
|
97
|
+
rails-dom-testing (1.0.7)
|
|
98
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
|
99
|
+
nokogiri (~> 1.6.0)
|
|
100
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
|
101
|
+
rails-html-sanitizer (1.0.3)
|
|
102
|
+
loofah (~> 2.0)
|
|
103
|
+
railties (4.2.6)
|
|
104
|
+
actionpack (= 4.2.6)
|
|
105
|
+
activesupport (= 4.2.6)
|
|
74
106
|
rake (>= 0.8.7)
|
|
75
107
|
thor (>= 0.18.1, < 2.0)
|
|
76
|
-
rake (
|
|
77
|
-
request_store (1.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
rspec (
|
|
81
|
-
|
|
82
|
-
rspec-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
rspec-mocks (2.14.3)
|
|
88
|
-
rspec-rails (2.14.0)
|
|
108
|
+
rake (11.2.2)
|
|
109
|
+
request_store (1.3.1)
|
|
110
|
+
rspec-core (3.5.1)
|
|
111
|
+
rspec-support (~> 3.5.0)
|
|
112
|
+
rspec-expectations (3.5.0)
|
|
113
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
114
|
+
rspec-support (~> 3.5.0)
|
|
115
|
+
rspec-mocks (3.5.0)
|
|
116
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
117
|
+
rspec-support (~> 3.5.0)
|
|
118
|
+
rspec-rails (3.5.1)
|
|
89
119
|
actionpack (>= 3.0)
|
|
90
120
|
activesupport (>= 3.0)
|
|
91
121
|
railties (>= 3.0)
|
|
92
|
-
rspec-core (~>
|
|
93
|
-
rspec-expectations (~>
|
|
94
|
-
rspec-mocks (~>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
rspec-core (~> 3.5.0)
|
|
123
|
+
rspec-expectations (~> 3.5.0)
|
|
124
|
+
rspec-mocks (~> 3.5.0)
|
|
125
|
+
rspec-support (~> 3.5.0)
|
|
126
|
+
rspec-support (3.5.0)
|
|
127
|
+
simplecov (0.12.0)
|
|
128
|
+
docile (~> 1.1.0)
|
|
129
|
+
json (>= 1.8, < 3)
|
|
130
|
+
simplecov-html (~> 0.10.0)
|
|
131
|
+
simplecov-html (0.10.0)
|
|
132
|
+
sprockets (3.6.3)
|
|
133
|
+
concurrent-ruby (~> 1.0)
|
|
134
|
+
rack (> 1, < 3)
|
|
135
|
+
sprockets-rails (3.1.1)
|
|
136
|
+
actionpack (>= 4.0)
|
|
137
|
+
activesupport (>= 4.0)
|
|
138
|
+
sprockets (>= 3.0.0)
|
|
139
|
+
term-ansicolor (1.3.2)
|
|
140
|
+
tins (~> 1.0)
|
|
141
|
+
thor (0.19.1)
|
|
142
|
+
thread_safe (0.3.5)
|
|
143
|
+
tins (1.6.0)
|
|
144
|
+
tzinfo (1.2.2)
|
|
145
|
+
thread_safe (~> 0.1)
|
|
116
146
|
|
|
117
147
|
PLATFORMS
|
|
118
148
|
ruby
|
|
119
149
|
|
|
120
150
|
DEPENDENCIES
|
|
121
|
-
activesupport (
|
|
151
|
+
activesupport (~> 4.0)
|
|
122
152
|
coveralls
|
|
123
153
|
decent_decoration!
|
|
124
|
-
draper (
|
|
125
|
-
rails (
|
|
126
|
-
rspec (~>
|
|
127
|
-
|
|
154
|
+
draper (~> 2.1)
|
|
155
|
+
rails (~> 4.0)
|
|
156
|
+
rspec-rails (~> 3.0)
|
|
157
|
+
|
|
158
|
+
BUNDLED WITH
|
|
159
|
+
1.11.2
|
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2012
|
|
1
|
+
Copyright (c) 2012-2014 netguru
|
|
2
2
|
|
|
3
3
|
MIT License
|
|
4
4
|
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
[](https://coveralls.io/r/netguru/decent_decoration)
|
|
5
5
|
[](http://badge.fury.io/rb/decent_decoration)
|
|
6
6
|
|
|
7
|
-
decent_decoration allows you to use excellent [decent_exposure][decent_exposure] gem with decorators.
|
|
7
|
+
decent_decoration allows you to use excellent [decent_exposure 3.0][decent_exposure] gem with decorators.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
Add this line to your application's Gemfile:
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
gem 'decent_decoration'
|
|
14
|
+
gem 'decent_decoration', '~> 0.1.0'
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
And then execute:
|
|
@@ -67,7 +67,7 @@ decent_decoration supports most of the awesome [decent_exposure api][decent_expo
|
|
|
67
67
|
# app/controllers/attendees_controller.rb
|
|
68
68
|
class AttendeesController < ApplicationController
|
|
69
69
|
expose_decorated(:conference)
|
|
70
|
-
expose_decorated(:attendees,
|
|
70
|
+
expose_decorated(:attendees, scope: :conference)
|
|
71
71
|
end
|
|
72
72
|
```
|
|
73
73
|
|
|
@@ -84,3 +84,5 @@ You can use any decorator mechanism as long as `ConferenceDecorator` responds to
|
|
|
84
84
|
[decent_exposure]: https://github.com/voxdolo/decent_exposure
|
|
85
85
|
[decent_exposure_api]: https://github.com/voxdolo/decent_exposure#usage
|
|
86
86
|
[draper]: https://github.com/drapergem/draper
|
|
87
|
+
|
|
88
|
+
Copyright © 2012–2014 [netguru](https://netguru.co). See LICENSE for further details.
|
data/decent_decoration.gemspec
CHANGED
|
@@ -16,10 +16,12 @@ Gem::Specification.new do |gem|
|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
19
|
-
|
|
20
|
-
gem.
|
|
21
|
-
|
|
22
|
-
gem.
|
|
23
|
-
gem.add_development_dependency '
|
|
24
|
-
gem.add_development_dependency '
|
|
19
|
+
|
|
20
|
+
gem.required_ruby_version = "~> 2.0"
|
|
21
|
+
|
|
22
|
+
gem.add_runtime_dependency 'decent_exposure', '~> 3.0'
|
|
23
|
+
gem.add_development_dependency 'rspec-rails', "~> 3.0"
|
|
24
|
+
gem.add_development_dependency 'rails', '~> 4.0'
|
|
25
|
+
gem.add_development_dependency 'activesupport', '~> 4.0'
|
|
26
|
+
gem.add_development_dependency 'draper', '~> 2.1'
|
|
25
27
|
end
|
|
@@ -13,9 +13,7 @@ module DecentDecoration
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def options
|
|
16
|
-
original_options.except(:decorator, :collection)
|
|
17
|
-
h[:model] ||= name
|
|
18
|
-
end
|
|
16
|
+
original_options.except(:decorator, :collection)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def decorator_class
|
|
@@ -35,7 +33,7 @@ module DecentDecoration
|
|
|
35
33
|
private
|
|
36
34
|
|
|
37
35
|
def infer_decorator_class
|
|
38
|
-
"#{
|
|
36
|
+
"#{name.to_s.classify}Decorator".constantize
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
def decorate_collection?
|
|
@@ -60,15 +58,16 @@ module DecentDecoration
|
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
module ControllerMethods
|
|
63
|
-
def expose_decorated(name,
|
|
61
|
+
def expose_decorated(name, *args, &block)
|
|
62
|
+
options = args.extract_options!
|
|
64
63
|
decoration = Decoration.new(name, options)
|
|
65
64
|
|
|
66
65
|
decorator_class = decoration.decorator_class
|
|
67
66
|
decorate_method = decoration.decorate_method
|
|
68
|
-
decorated_name
|
|
67
|
+
decorated_name = decoration.decorated_name
|
|
69
68
|
options = decoration.options
|
|
70
69
|
|
|
71
|
-
expose(name, options, &block)
|
|
70
|
+
expose(name, *args, options, &block)
|
|
72
71
|
expose(decorated_name) { decorator_class.public_send(decorate_method, public_send(name)) }
|
|
73
72
|
|
|
74
73
|
helper Module.new do
|
data/spec/decoration_spec.rb
CHANGED
|
@@ -5,27 +5,27 @@ describe DecentDecoration::Decoration do
|
|
|
5
5
|
|
|
6
6
|
it "should be initialized with name" do
|
|
7
7
|
subject = klass.new(:conference)
|
|
8
|
-
subject.name.
|
|
8
|
+
expect(subject.name).to eq :conference
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "should be initialized with options" do
|
|
12
12
|
subject = klass.new(:conference, { model: :conference })
|
|
13
|
-
subject.options.
|
|
13
|
+
expect(subject.options).to eq({ model: :conference })
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
describe "#decorated_name" do
|
|
17
17
|
it "should consist of name prepended by decorated" do
|
|
18
|
-
klass.new(:conference).decorated_name.
|
|
18
|
+
expect(klass.new(:conference).decorated_name).to eq :decorated_conference
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
describe "#decorator_class" do
|
|
23
23
|
it "should infer the class from name" do
|
|
24
|
-
klass.new(:conference).decorator_class.
|
|
24
|
+
expect(klass.new(:conference).decorator_class).to eq ConferenceDecorator
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "should use :decorator if passed" do
|
|
28
|
-
klass.new(:conference, decorator: AttendeeDecorator).decorator_class.
|
|
28
|
+
expect(klass.new(:conference, decorator: AttendeeDecorator).decorator_class).to eq AttendeeDecorator
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -35,24 +35,24 @@ describe DecentDecoration::Decoration do
|
|
|
35
35
|
let(:decorator) { double }
|
|
36
36
|
|
|
37
37
|
it "should be :decorate_collection if decorator supports it" do
|
|
38
|
-
decorator.
|
|
39
|
-
subject.decorate_method.
|
|
38
|
+
allow(decorator).to receive(:decorate_collection)
|
|
39
|
+
expect(subject.decorate_method).to eq :decorate_collection
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should be :decorate if decorator does not support :decorate_collection and supports :decorate" do
|
|
43
|
-
decorator.
|
|
44
|
-
subject.decorate_method.
|
|
43
|
+
allow(decorator).to receive(:decorate)
|
|
44
|
+
expect(subject.decorate_method).to eq :decorate
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "should be :new if decorator does not support :decorate_collection or :decorate" do
|
|
48
|
-
subject.decorate_method.
|
|
48
|
+
expect(subject.decorate_method).to eq :new
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should be :decorate if decorator supports it and collection: false" do
|
|
52
|
-
decorator.
|
|
53
|
-
decorator.
|
|
52
|
+
allow(decorator).to receive(:decorate)
|
|
53
|
+
allow(decorator).to receive(:decorate_collection)
|
|
54
54
|
subject = klass.new(:conferences, decorator: decorator, collection: false)
|
|
55
|
-
subject.decorate_method.
|
|
55
|
+
expect(subject.decorate_method).to eq :decorate
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -61,24 +61,24 @@ describe DecentDecoration::Decoration do
|
|
|
61
61
|
let(:decorator) { double }
|
|
62
62
|
|
|
63
63
|
it "should not be :decorate_collection even if decorator supports it" do
|
|
64
|
-
decorator.
|
|
65
|
-
subject.decorate_method.
|
|
64
|
+
allow(decorator).to receive(:decorate_collection)
|
|
65
|
+
expect(subject.decorate_method).not_to eq :decorate_collection
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "should be :decorate_collection if decorator supports it and collection: true" do
|
|
69
|
-
decorator.
|
|
70
|
-
decorator.
|
|
69
|
+
allow(decorator).to receive(:decorate)
|
|
70
|
+
allow(decorator).to receive(:decorate_collection)
|
|
71
71
|
subject = klass.new(:conference, decorator: decorator, collection: true)
|
|
72
|
-
subject.decorate_method.
|
|
72
|
+
expect(subject.decorate_method).to eq :decorate_collection
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
it "should be :decorate if decorator supports it" do
|
|
76
|
-
decorator.
|
|
77
|
-
subject.decorate_method.
|
|
76
|
+
allow(decorator).to receive(:decorate)
|
|
77
|
+
expect(subject.decorate_method).to eq :decorate
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "should be :new if decorator does not support :decorate" do
|
|
81
|
-
subject.decorate_method.
|
|
81
|
+
expect(subject.decorate_method).to eq :new
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
class ConferencesController < ActionController::Base
|
|
2
2
|
include Rails.application.routes.url_helpers
|
|
3
3
|
|
|
4
|
-
expose_decorated
|
|
5
|
-
expose_decorated
|
|
4
|
+
expose_decorated :conference
|
|
5
|
+
expose_decorated :other_conference, model: Conference, decorator: CoolConferenceDecorator
|
|
6
6
|
|
|
7
7
|
def show
|
|
8
8
|
render :text => "foo"
|
|
9
9
|
end
|
|
10
|
-
|
|
11
|
-
def new
|
|
12
|
-
render :text => "foo"
|
|
13
|
-
end
|
|
14
10
|
end
|
|
15
11
|
|
|
16
12
|
class AttendeesController < ActionController::Base
|
|
17
13
|
include Rails.application.routes.url_helpers
|
|
18
14
|
|
|
19
|
-
expose_decorated
|
|
20
|
-
expose_decorated
|
|
15
|
+
expose_decorated :attendee
|
|
16
|
+
expose_decorated :attendees, ->{ [Attendee.new, Attendee.new] }
|
|
21
17
|
|
|
22
18
|
def show
|
|
23
19
|
render :text => "foo"
|
|
24
20
|
end
|
|
25
|
-
|
|
26
|
-
def new
|
|
27
|
-
render :text => "foo"
|
|
28
|
-
end
|
|
29
21
|
end
|
|
@@ -10,21 +10,17 @@ require 'active_model'
|
|
|
10
10
|
module Rails
|
|
11
11
|
class App
|
|
12
12
|
def env_config; {} end
|
|
13
|
+
|
|
13
14
|
def routes
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
get '/attendees/new' => "attendees#new"
|
|
20
|
-
get '/attendee/(:id)' => "attendees#show"
|
|
15
|
+
@routes ||= ActionDispatch::Routing::RouteSet.new.tap do |routes|
|
|
16
|
+
routes.draw do
|
|
17
|
+
resources :conferences, only: %i(show)
|
|
18
|
+
resources :attendees, only: %i(show)
|
|
19
|
+
end
|
|
21
20
|
end
|
|
22
|
-
@routes
|
|
23
|
-
end
|
|
24
|
-
def call(*args)
|
|
25
|
-
routes.call(*args)
|
|
26
21
|
end
|
|
27
22
|
end
|
|
23
|
+
|
|
28
24
|
def self.application
|
|
29
25
|
@app ||= App.new
|
|
30
26
|
end
|
|
@@ -4,16 +4,16 @@ require 'rspec/rails'
|
|
|
4
4
|
|
|
5
5
|
describe AttendeesController, type: :controller do
|
|
6
6
|
before do
|
|
7
|
-
get '
|
|
7
|
+
get :show, id: 'dave'
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "should be a decorator" do
|
|
11
|
-
controller.view_context.attendee.
|
|
11
|
+
expect(controller.view_context.attendee).to be_instance_of(AttendeeDecorator)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should be a decorator in collection" do
|
|
15
15
|
controller.view_context.attendees.each do |attendee|
|
|
16
|
-
attendee.
|
|
16
|
+
expect(attendee).to be_instance_of(AttendeeDecorator)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -3,38 +3,38 @@ require 'rspec/rails'
|
|
|
3
3
|
|
|
4
4
|
describe ConferencesController, type: :controller do
|
|
5
5
|
before do
|
|
6
|
-
get '
|
|
6
|
+
get :show, id: 'RuPy'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
describe "inside a view" do
|
|
10
10
|
it "should be a decorator" do
|
|
11
|
-
controller.view_context.conference.
|
|
11
|
+
expect(controller.view_context.conference).to be_instance_of(ConferenceDecorator)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "should have decorated conference" do
|
|
15
|
-
controller.view_context.conference.decorated_object.
|
|
15
|
+
expect(controller.view_context.conference.decorated_object).to be_instance_of(Conference)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should be specified decorator" do
|
|
19
|
-
controller.view_context.other_conference.
|
|
19
|
+
expect(controller.view_context.other_conference).to be_instance_of(CoolConferenceDecorator)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "should cache decorator" do
|
|
23
|
-
controller.view_context.conference.object_id.
|
|
23
|
+
expect(controller.view_context.conference.object_id).to eq controller.view_context.conference.object_id
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should cache decorated object" do
|
|
27
|
-
controller.view_context.conference.decorated_object.object_id.
|
|
27
|
+
expect(controller.view_context.conference.decorated_object.object_id).to eq controller.view_context.conference.decorated_object.object_id
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
describe "inside a controller" do
|
|
32
32
|
it "should be undecorated object" do
|
|
33
|
-
controller.conference.
|
|
33
|
+
expect(controller.conference).to be_instance_of(Conference)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "should not be specified decorator" do
|
|
37
|
-
controller.other_conference.
|
|
37
|
+
expect(controller.other_conference).to be_instance_of(Conference)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
metadata
CHANGED
|
@@ -1,99 +1,85 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decent_decoration
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tomasz Pewiński
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: decent_exposure
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rspec
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ~>
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '2.13'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ~>
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.13'
|
|
26
|
+
version: '3.0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: rspec-rails
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
44
30
|
requirements:
|
|
45
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
46
32
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
33
|
+
version: '3.0'
|
|
48
34
|
type: :development
|
|
49
35
|
prerelease: false
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
52
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
40
|
+
version: '3.0'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
42
|
name: rails
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
|
-
- -
|
|
45
|
+
- - "~>"
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
47
|
+
version: '4.0'
|
|
62
48
|
type: :development
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
|
-
- -
|
|
52
|
+
- - "~>"
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
54
|
+
version: '4.0'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
56
|
name: activesupport
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
|
-
- -
|
|
59
|
+
- - "~>"
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
61
|
+
version: '4.0'
|
|
76
62
|
type: :development
|
|
77
63
|
prerelease: false
|
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
65
|
requirements:
|
|
80
|
-
- -
|
|
66
|
+
- - "~>"
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
68
|
+
version: '4.0'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
70
|
name: draper
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
|
-
- -
|
|
73
|
+
- - "~>"
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 1
|
|
75
|
+
version: '2.1'
|
|
90
76
|
type: :development
|
|
91
77
|
prerelease: false
|
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
79
|
requirements:
|
|
94
|
-
- -
|
|
80
|
+
- - "~>"
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 1
|
|
82
|
+
version: '2.1'
|
|
97
83
|
description: Use decent_exposure with decorators (e.g. Draper)
|
|
98
84
|
email:
|
|
99
85
|
- pewniak747@gmail.com
|
|
@@ -101,8 +87,8 @@ executables: []
|
|
|
101
87
|
extensions: []
|
|
102
88
|
extra_rdoc_files: []
|
|
103
89
|
files:
|
|
104
|
-
- .gitignore
|
|
105
|
-
- .travis.yml
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".travis.yml"
|
|
106
92
|
- CHANGELOG.md
|
|
107
93
|
- Gemfile
|
|
108
94
|
- Gemfile.lock
|
|
@@ -130,17 +116,17 @@ require_paths:
|
|
|
130
116
|
- lib
|
|
131
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
118
|
requirements:
|
|
133
|
-
- -
|
|
119
|
+
- - "~>"
|
|
134
120
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '0'
|
|
121
|
+
version: '2.0'
|
|
136
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
123
|
requirements:
|
|
138
|
-
- -
|
|
124
|
+
- - ">="
|
|
139
125
|
- !ruby/object:Gem::Version
|
|
140
126
|
version: '0'
|
|
141
127
|
requirements: []
|
|
142
128
|
rubyforge_project:
|
|
143
|
-
rubygems_version: 2.
|
|
129
|
+
rubygems_version: 2.4.5.1
|
|
144
130
|
signing_key:
|
|
145
131
|
specification_version: 4
|
|
146
132
|
summary: Use decent_exposure with decorators (e.g. Draper)
|