cells 4.0.0.beta4 → 4.0.0.beta5

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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +19 -0
  3. data/Rakefile +11 -0
  4. data/cells.gemspec +3 -4
  5. data/gemfiles/rails4.2.gemfile +0 -7
  6. data/lib/cell.rb +19 -19
  7. data/lib/cell/abstract.rb +9 -0
  8. data/lib/cell/caching.rb +16 -17
  9. data/lib/cell/concept.rb +2 -4
  10. data/lib/cell/prefixes.rb +3 -2
  11. data/lib/cell/rails.rb +27 -4
  12. data/lib/cell/railtie.rb +47 -42
  13. data/lib/cell/testing.rb +12 -9
  14. data/lib/cell/twin.rb +2 -2
  15. data/lib/cell/util.rb +16 -0
  16. data/lib/cell/version.rb +1 -8
  17. data/lib/cell/view_model.rb +63 -90
  18. data/test/builder_test.rb +5 -5
  19. data/test/caching_test.rb +2 -2
  20. data/test/cell_test.rb +1 -1
  21. data/test/concept_test.rb +24 -10
  22. data/test/dummy/config/application.rb +1 -1
  23. data/test/public_test.rb +8 -9
  24. data/test/rails4.2/.gitignore +13 -0
  25. data/test/rails4.2/Gemfile +16 -0
  26. data/test/rails4.2/README.rdoc +3 -0
  27. data/test/rails4.2/Rakefile +6 -0
  28. data/test/rails4.2/app/assets/images/.keep +0 -0
  29. data/test/rails4.2/app/assets/stylesheets/application.css +17 -0
  30. data/test/rails4.2/app/cells/song/song.css +1 -0
  31. data/test/rails4.2/app/cells/song_cell.rb +2 -0
  32. data/test/rails4.2/app/controllers/application_controller.rb +5 -0
  33. data/test/rails4.2/app/controllers/concerns/.keep +0 -0
  34. data/test/rails4.2/app/controllers/index_controller.rb +7 -0
  35. data/test/rails4.2/app/helpers/application_helper.rb +2 -0
  36. data/test/rails4.2/app/mailers/.keep +0 -0
  37. data/test/rails4.2/app/models/.keep +0 -0
  38. data/test/rails4.2/app/models/concerns/.keep +0 -0
  39. data/test/rails4.2/app/views/index/index.html.erb +6 -0
  40. data/test/rails4.2/app/views/layouts/application.html.erb +13 -0
  41. data/test/rails4.2/bin/bundle +3 -0
  42. data/test/rails4.2/bin/rails +4 -0
  43. data/test/rails4.2/bin/rake +4 -0
  44. data/test/rails4.2/bin/setup +29 -0
  45. data/test/rails4.2/config.ru +4 -0
  46. data/test/rails4.2/config/application.rb +38 -0
  47. data/test/rails4.2/config/boot.rb +3 -0
  48. data/test/rails4.2/config/environment.rb +5 -0
  49. data/test/rails4.2/config/environments/development.rb +25 -0
  50. data/test/rails4.2/config/environments/production.rb +64 -0
  51. data/test/rails4.2/config/environments/test.rb +42 -0
  52. data/test/rails4.2/config/initializers/backtrace_silencers.rb +7 -0
  53. data/test/rails4.2/config/initializers/cookies_serializer.rb +3 -0
  54. data/test/rails4.2/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/test/rails4.2/config/initializers/inflections.rb +16 -0
  56. data/test/rails4.2/config/initializers/mime_types.rb +4 -0
  57. data/test/rails4.2/config/initializers/session_store.rb +3 -0
  58. data/test/rails4.2/config/initializers/wrap_parameters.rb +9 -0
  59. data/test/rails4.2/config/locales/en.yml +23 -0
  60. data/test/rails4.2/config/routes.rb +4 -0
  61. data/test/rails4.2/config/secrets.yml +22 -0
  62. data/test/rails4.2/db/seeds.rb +7 -0
  63. data/test/rails4.2/engines/my_engine/.gitignore +3 -0
  64. data/test/rails4.2/engines/my_engine/Gemfile +15 -0
  65. data/test/rails4.2/engines/my_engine/MIT-LICENSE +20 -0
  66. data/test/rails4.2/engines/my_engine/README.rdoc +3 -0
  67. data/test/rails4.2/engines/my_engine/Rakefile +24 -0
  68. data/test/rails4.2/engines/my_engine/app/assets/images/my_engine/.keep +0 -0
  69. data/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css +15 -0
  70. data/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb +8 -0
  71. data/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb +1 -0
  72. data/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss +3 -0
  73. data/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb +4 -0
  74. data/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb +7 -0
  75. data/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb +4 -0
  76. data/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb +4 -0
  77. data/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb +14 -0
  78. data/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb +3 -0
  79. data/test/rails4.2/engines/my_engine/bin/rails +12 -0
  80. data/test/rails4.2/engines/my_engine/config/routes.rb +3 -0
  81. data/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb +8 -0
  82. data/test/rails4.2/engines/my_engine/lib/my_engine.rb +6 -0
  83. data/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb +9 -0
  84. data/test/rails4.2/engines/my_engine/lib/my_engine/version.rb +3 -0
  85. data/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake +4 -0
  86. data/test/rails4.2/engines/my_engine/my_engine.gemspec +24 -0
  87. data/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml +11 -0
  88. data/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb +9 -0
  89. data/test/rails4.2/lib/assets/.keep +0 -0
  90. data/test/rails4.2/lib/tasks/.keep +0 -0
  91. data/test/rails4.2/log/.keep +0 -0
  92. data/test/rails4.2/public/404.html +67 -0
  93. data/test/rails4.2/public/422.html +67 -0
  94. data/test/rails4.2/public/500.html +66 -0
  95. data/test/rails4.2/public/favicon.ico +0 -0
  96. data/test/rails4.2/public/robots.txt +5 -0
  97. data/test/rails4.2/test/integration/asset_pipeline_test.rb +17 -0
  98. data/test/rails4.2/test/test_helper.rb +14 -0
  99. data/test/rails4.2/vendor/assets/stylesheets/.keep +0 -0
  100. data/test/twin_test.rb +1 -1
  101. data/test/url_helper_test.rb +1 -1
  102. metadata +83 -19
@@ -13,8 +13,8 @@ module Cell
13
13
  end
14
14
  end
15
15
 
16
- def initialize(controller, model, options={})
17
- super(controller, build_twin(model, options))
16
+ def initialize(model, options={})
17
+ super(build_twin(model, options), controller: options.delete(:controller))
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,16 @@
1
+ module Cell::Util
2
+ def util
3
+ Inflector
4
+ end
5
+
6
+ class Inflector
7
+ # copied from ActiveSupport.
8
+ def self.underscore(constant)
9
+ constant.gsub(/::/, '/').
10
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
11
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
12
+ tr("-", "_").
13
+ downcase
14
+ end
15
+ end
16
+ end
@@ -1,10 +1,3 @@
1
1
  module Cell
2
- module VERSION
3
- MAJOR = 4
4
- MINOR = 0
5
- TINY = 0
6
- PRE = "beta4"
7
-
8
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
9
- end
2
+ VERSION = "4.0.0.beta5"
10
3
  end
@@ -1,21 +1,22 @@
1
- # FIXME: remove AC dependency by delegating forgery
2
- require 'action_controller'
3
-
4
1
  # no helper_method calls
5
2
  # no instance variables
6
3
  # no locals
7
4
  # options are automatically made instance methods via constructor.
8
5
  # call "helpers" in class
9
6
 
10
- # TODO: CACHE prefixes.
11
-
12
7
  # TODO: warn when using ::property but not passing in model in constructor.
13
8
  module Cell
14
- class ViewModel < AbstractController::Base
9
+ class ViewModel
10
+ extend Abstract
15
11
  abstract!
16
12
 
13
+ def controller_path
14
+ self.class.controller_path
15
+ end
16
+
17
17
  extend Uber::InheritableAttr
18
18
  extend Uber::Delegates
19
+ include Uber::Builder
19
20
 
20
21
  inheritable_attr :view_paths
21
22
  self.view_paths = ["app/cells"]
@@ -32,35 +33,35 @@ module Cell
32
33
 
33
34
  include Prefixes
34
35
  extend SelfContained
35
-
36
- include Uber::Builder
37
-
36
+ extend Util
38
37
 
39
38
  def self.controller_path
40
- @controller_path ||= name.sub(/Cell$/, '').underscore
39
+ @controller_path ||= util.underscore(name.sub(/Cell$/, ''))
41
40
  end
42
41
 
43
- include ActionController::RequestForgeryProtection
44
- delegate :session, :params, :request, :config, :env, :url_options, :to => :parent_controller
42
+ # FIXME: this is all rails-only.
43
+ # DISCUSS: who actually uses forgery protection with cells? it is not working since 4, anyway?
44
+ # include ActionController::RequestForgeryProtection
45
+ delegates :parent_controller, :session, :params, :request, :config, :env, :url_options
45
46
 
46
47
  attr_reader :model
47
48
 
48
49
 
49
50
  module Helpers
50
51
  # Renders collection of cells.
51
- def cells_collection(name, controller, array, options)
52
+ def _collection(name, array, options) # private.
52
53
  method = options.delete(:method) || :show
53
- join = options.delete(:collection_join)
54
- array.collect { |model| cell_for(name, *[controller, model, options]).call(method) }.join(join).html_safe
54
+ join = options.delete(:collection_join)
55
+ array.collect { |model| cell_for(name, *[model, options]).call(method) }.join(join).html_safe
55
56
  end
56
57
 
57
58
  # Returns cell instance.
58
- def cell(name, controller, model=nil, options={}, &block) # classic Rails fuzzy API.
59
+ def cell(name, model=nil, options={}, &block) # classic Rails fuzzy API.
59
60
  if model.is_a?(Hash) and array = model.delete(:collection)
60
- return cells_collection(name, controller, array, model)
61
+ return _collection(name, array, model.merge(options))
61
62
  end
62
63
 
63
- cell_for(name, controller, model, options, &block)
64
+ cell_for(name, model, options, &block)
64
65
  end
65
66
  end
66
67
  extend Helpers
@@ -74,62 +75,72 @@ module Cell
74
75
  include Helpers
75
76
 
76
77
 
77
- def cell_for(name, controller, *args)
78
- class_from_cell_name(name).build_cell(controller, *args)
78
+ def cell_for(name, *args)
79
+ class_from_cell_name(name).build_cell(*args)
79
80
  end
80
81
 
81
82
  def class_from_cell_name(name)
82
83
  "#{name}_cell".classify.constantize
83
84
  end
84
85
 
85
- def build_cell(controller, *args)
86
- class_builder.call(*args).new(controller, *args) # Uber::Builder::class_builder.
86
+ def build_cell(*args)
87
+ class_builder.call(*args).new(*args) # Uber::Builder::class_builder.
87
88
  end
88
89
  end
89
90
 
90
- def cell(name, *args)
91
- self.class.cell(name, parent_controller, *args)
91
+ # Get nested cell in instance.
92
+ def cell(name, model=nil, options={})
93
+ self.class.cell(name, model, options.merge(controller: parent_controller))
92
94
  end
93
95
 
94
96
 
95
- def initialize(controller, model=nil, options={})
96
- @parent_controller = controller # TODO: this is removed in 4.0.
97
+ def initialize(model=nil, options={}) # in Ruby 2: def m(model: nil, controller:nil, **options) that'll make the controller optional.
98
+ # options = options.clone # DISCUSS: this could be time consuming when rendering many of em.
99
+ @parent_controller = options[:controller] # TODO: filter out controller in a performant way.
97
100
 
98
101
  setup!(model, options)
99
102
  end
100
103
  attr_reader :parent_controller
101
104
  alias_method :controller, :parent_controller
102
105
 
106
+ module Rendering
107
+ # Invokes the passed method (defaults to :show) while respecting caching.
108
+ # In Rails, the return value gets marked html_safe.
109
+ #
110
+ # Yields +self+ to an optional block.
111
+ def call(state=:show, *args)
112
+ content = render_state(state, *args)
113
+ yield self if block_given?
114
+
115
+ content.to_s
116
+ end
103
117
 
104
- # render :show
105
- def render(options={})
106
- options = normalize_options(options, caller) # TODO: call render methods with call(:show), call(:comments) instead of directly #comments?
107
- render_to_string(options)
108
- end
109
-
110
- def render_to_string(options)
111
- template = template_for(options) # TODO: cache template with path/lookup keys.
112
- content = template.render(self, options[:locals])
113
-
114
- # TODO: allow other (global) layout dirs.
115
- with_layout(options, content)
116
- end
118
+ private
119
+ # render :show
120
+ def render(options={})
121
+ options = normalize_options(options, caller) # TODO: call render methods with call(:show), call(:comments) instead of directly #comments?
122
+ render_to_string(options)
123
+ end
117
124
 
125
+ def render_to_string(options)
126
+ template = template_for(options) # TODO: cache template with path/lookup keys.
127
+ content = template.render(self, options[:locals])
118
128
 
119
- # Invokes the passed method (defaults to :show). This will respect caching and marks the string as html_safe.
120
- #
121
- # Please use #call instead of calling methods directly. This allows adding caching later without changing
122
- # your code.
123
- #
124
- # Yields +self+ (the cell instance) to an optional block.
125
- def call(state=:show, *args)
126
- content = render_state(state, *args)
127
- yield self if block_given?
129
+ # TODO: allow other (global) layout dirs.
130
+ with_layout(options, content)
131
+ end
128
132
 
129
- content.to_s.html_safe
133
+ def render_state(*args)
134
+ send(*args)
135
+ end
130
136
  end
131
137
 
132
- alias_method :to_s, :call
138
+ include Rendering
139
+ # alias_method :to_s, :call # FIXME: why doesn't this work?
140
+ def to_s
141
+ call
142
+ end
143
+ include Caching
133
144
 
134
145
  private
135
146
  attr_reader :options
@@ -140,15 +151,6 @@ module Cell
140
151
  # or: create_twin(model, options)
141
152
  end
142
153
 
143
- module Rendering
144
- def render_state(*args)
145
- send(*args)
146
- end
147
- end
148
- include Rendering
149
- include Caching
150
-
151
-
152
154
  class OutputBuffer < Array
153
155
  def encoding
154
156
  "UTF-8"
@@ -192,7 +194,8 @@ module Cell
192
194
 
193
195
  def normalize_options(options, caller) # TODO: rename to #setup_options! to be inline with Trb.
194
196
  options = if options.is_a?(Hash)
195
- options.reverse_merge(:view => state_for_implicit_render(caller))
197
+ # TODO: speedup by not doing state_for_implicit_render.
198
+ {:view => state_for_implicit_render(caller)}.merge(options)
196
199
  else
197
200
  {:view => options.to_s}
198
201
  end
@@ -217,35 +220,5 @@ module Cell
217
220
  end
218
221
 
219
222
  include Layout
220
-
221
-
222
- if defined?(ActionView)
223
- # FIXME: this module is to fix a design flaw in Rails 4.0. the problem is that AV::UrlHelper mixes in the wrong #url_for.
224
- # if we could mix in everything else from the helper except for the #url_for, it would be fine.
225
- # FIXME: fix that in rails core.
226
- if Cell.rails_version <= Gem::Version.new('4.0')
227
- include ActionView::Helpers::UrlHelper # gives us breaking #url_for.
228
-
229
- def url_for(options = nil) # from ActionDispatch:R:UrlFor.
230
- case options
231
- when nil
232
- _routes.url_for(url_options.symbolize_keys)
233
- when Hash
234
- _routes.url_for(options.symbolize_keys.reverse_merge!(url_options))
235
- when String
236
- options
237
- when Array
238
- polymorphic_url(options, options.extract_options!)
239
- else
240
- polymorphic_url(options)
241
- end
242
- end
243
-
244
- public :url_for
245
- else
246
- include ActionView::Helpers::UrlHelper
247
- end
248
- include ActionView::Helpers::FormTagHelper
249
- end
250
223
  end
251
224
  end
@@ -34,25 +34,25 @@ class BuilderTest < MiniTest::Spec
34
34
  end
35
35
 
36
36
  # the original class is used when no builder matches.
37
- it { Cell::ViewModel.cell("builder_test/song", nil, Song.new("Nation States"), {}).must_be_instance_of BuilderTest::SongCell }
37
+ it { Cell::ViewModel.cell("builder_test/song", Song.new("Nation States"), {}).must_be_instance_of BuilderTest::SongCell }
38
38
 
39
39
  it do
40
- cell = Cell::ViewModel.cell("builder_test/song", nil, Hit.new("New York"), {})
40
+ cell = Cell::ViewModel.cell("builder_test/song", Hit.new("New York"), {})
41
41
  cell.must_be_instance_of BuilderTest::HitCell
42
42
  cell.options.must_equal({})
43
43
  end
44
44
 
45
45
  it do
46
- cell = Cell::ViewModel.cell("builder_test/song", nil, Song.new("San Francisco"), evergreen: true)
46
+ cell = Cell::ViewModel.cell("builder_test/song", Song.new("San Francisco"), evergreen: true)
47
47
  cell.must_be_instance_of BuilderTest::EvergreenCell
48
48
  cell.options.must_equal({:evergreen=>true})
49
49
  end
50
50
 
51
51
  # with collection.
52
- it { Cell::ViewModel.cell("builder_test/song", nil, collection: [Song.new("Nation States"), Hit.new("New York")]).must_equal "* Nation States* **New York**" }
52
+ it { Cell::ViewModel.cell("builder_test/song", collection: [Song.new("Nation States"), Hit.new("New York")]).must_equal "* Nation States* **New York**" }
53
53
 
54
54
  # with Concept
55
55
  class Track < Cell::Concept
56
56
  end
57
- it { Cell::Concept.cell("builder_test/track", nil).must_be_instance_of Track }
57
+ it { Cell::Concept.cell("builder_test/track").must_be_instance_of Track }
58
58
  end
@@ -117,7 +117,7 @@ end
117
117
 
118
118
  class CachingTest < MiniTest::Spec
119
119
  class DirectorCell < Cell::ViewModel
120
- def initialize(controller, counter=0)
120
+ def initialize(counter=0)
121
121
  super
122
122
  @counter = counter
123
123
  end
@@ -141,7 +141,7 @@ class CachingTest < MiniTest::Spec
141
141
 
142
142
  # let (:cell) { DirectorCell.new(nil) }
143
143
  def cellule(*args)
144
- DirectorCell.new(nil, *args)
144
+ DirectorCell.new(*args)
145
145
  end
146
146
 
147
147
  # no caching when turned off.
@@ -9,5 +9,5 @@ class CellTest < MiniTest::Spec
9
9
  it { Cell.rails_version.must_equal Gem::Version.new(ActionPack::VERSION::STRING) }
10
10
 
11
11
  # #options
12
- it { SongCell.new(nil, nil, genre: "Punkrock").send(:options)[:genre].must_equal "Punkrock" }
12
+ it { SongCell.new(nil, genre: "Punkrock").send(:options)[:genre].must_equal "Punkrock" }
13
13
  end
@@ -24,6 +24,11 @@ module Record
24
24
  class Hit < ::Cell::Concept
25
25
  inherit_views Record::Cell
26
26
  end
27
+
28
+
29
+ def description
30
+ "A Tribute To Rancid, with #{@options[:tracks]} songs! [#{parent_controller}]"
31
+ end
27
32
  end
28
33
  end
29
34
 
@@ -34,27 +39,36 @@ end
34
39
 
35
40
  class ConceptTest < MiniTest::Spec
36
41
  describe "::controller_path" do
37
- it { Record::Cell.new(@controller).controller_path.must_equal "record" }
38
- it { Record::Cell::Song.new(@controller).controller_path.must_equal "record/song" }
42
+ it { Record::Cell.new.controller_path.must_equal "record" }
43
+ it { Record::Cell::Song.new.controller_path.must_equal "record/song" }
39
44
  end
40
45
 
41
46
 
42
47
  describe "#_prefixes" do
43
- it { Record::Cell.new(@controller)._prefixes.must_equal ["test/fixtures/concepts/record/views"] }
44
- it { Record::Cell::Song.new(@controller)._prefixes.must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] }
45
- it { Record::Cell::Hit.new(@controller)._prefixes.must_equal ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"] } # with inherit_views.
48
+ it { Record::Cell.new._prefixes.must_equal ["test/fixtures/concepts/record/views"] }
49
+ it { Record::Cell::Song.new._prefixes.must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] }
50
+ it { Record::Cell::Hit.new._prefixes.must_equal ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"] } # with inherit_views.
46
51
  end
47
52
 
48
- it { Record::Cell.new(@controller, "Wayne").call(:show).must_equal "Party on, Wayne!" }
53
+ it { Record::Cell.new("Wayne").call(:show).must_equal "Party on, Wayne!" }
49
54
 
50
55
 
51
- describe "#cell" do
52
- it { Cell::Concept.cell("record/cell", @controller).must_be_instance_of( Record::Cell) }
53
- it { Cell::Concept.cell("record/cell/song", @controller).must_be_instance_of Record::Cell::Song }
56
+ describe "::cell" do
57
+ it { Cell::Concept.cell("record/cell").must_be_instance_of( Record::Cell) }
58
+ it { Cell::Concept.cell("record/cell/song").must_be_instance_of Record::Cell::Song }
54
59
  # cell("song", concept: "record/compilation") # record/compilation/cell/song
55
60
  end
56
61
 
57
62
  describe "#render" do
58
- it { Cell::Concept.cell("record/cell/song", @controller).show.must_equal "Lalala" }
63
+ it { Cell::Concept.cell("record/cell/song").show.must_equal "Lalala" }
64
+ end
65
+
66
+ describe "#cell (in cell state)" do
67
+ # test with controller, but remove tests when we don't need it anymore.
68
+ it { Cell::Concept.cell("record/cell", nil, controller: Object).cell("record/cell", nil, tracks: 24).(:description).must_equal "A Tribute To Rancid, with 24 songs! [Object]" }
69
+ it { Cell::Concept.cell("record/cell", nil, controller: Object).concept("record/cell", nil, tracks: 24).(:description).must_equal "A Tribute To Rancid, with 24 songs! [Object]" }
70
+ # concept(.., collection: ..)
71
+ it("xx") { Cell::Concept.cell("record/cell", nil, controller: Object).
72
+ concept("record/cell", collection: [1,2], tracks: 24, method: :description).must_equal "A Tribute To Rancid, with 24 songs! [Object]A Tribute To Rancid, with 24 songs! [Object]" }
59
73
  end
60
74
  end
@@ -21,7 +21,7 @@ module Dummy
21
21
  # enable asset pipeline as in development.
22
22
  config.assets.enabled = true
23
23
  config.assets.compile = true
24
- config.cells.with_assets = ["album", "song"]
24
+ # config.cells.with_assets = ["song/cell"]
25
25
  config.cache_classes = true
26
26
 
27
27
  # Show full error reports and disable caching
@@ -2,8 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class PublicTest < MiniTest::Spec
4
4
  class SongCell < Cell::ViewModel
5
- def initialize(controller, *args)
6
- @parent_controller = controller # TODO: this is removed in 4.0.
5
+ def initialize(*args)
7
6
  @initialize_args = *args
8
7
  end
9
8
  attr_reader :initialize_args
@@ -18,25 +17,25 @@ class PublicTest < MiniTest::Spec
18
17
  end
19
18
 
20
19
  # ViewModel.cell returns the cell instance.
21
- it { Cell::ViewModel.cell("public_test/song", nil).must_be_instance_of SongCell }
20
+ it { Cell::ViewModel.cell("public_test/song").must_be_instance_of SongCell }
22
21
 
23
22
  # ViewModel.cell passes options to cell.
24
- it { Cell::ViewModel.cell("public_test/song", nil, Object, genre: "Metal").initialize_args.must_equal [Object, {:genre=>"Metal"}] }
23
+ it { Cell::ViewModel.cell("public_test/song", Object, genre: "Metal").initialize_args.must_equal [Object, {:genre=>"Metal"}] }
25
24
 
26
25
  # ViewModel.cell(collection: []) renders cells.
27
- it { Cell::ViewModel.cell('public_test/song', nil, collection: [Object, Module]).must_equal '[Object, {}][Module, {}]' }
26
+ it { Cell::ViewModel.cell('public_test/song', collection: [Object, Module]).must_equal '[Object, {}][Module, {}]' }
28
27
 
29
28
  # ViewModel.cell(collection: []) renders cells with custom join.
30
- it { Cell::ViewModel.cell('public_test/song', nil, collection: [Object, Module], collection_join: '<br/>').must_equal '[Object, {}]<br/>[Module, {}]' }
29
+ it { Cell::ViewModel.cell('public_test/song', collection: [Object, Module], collection_join: '<br/>').must_equal '[Object, {}]<br/>[Module, {}]' }
31
30
 
32
31
  # ViewModel.cell(collection: []) renders html_safe.
33
- it { Cell::ViewModel.cell("public_test/song", nil, collection: [Object]).class.must_equal ActiveSupport::SafeBuffer }
32
+ it { Cell::ViewModel.cell("public_test/song", collection: [Object]).class.must_equal ActiveSupport::SafeBuffer }
34
33
 
35
34
  # ViewModel.cell(collection: []) passes generic options to cell.
36
- it { Cell::ViewModel.cell('public_test/song', nil, collection: [Object, Module], genre: 'Metal').must_equal "[Object, {:genre=>\"Metal\"}][Module, {:genre=>\"Metal\"}]" }
35
+ it { Cell::ViewModel.cell('public_test/song', collection: [Object, Module], genre: 'Metal').must_equal "[Object, {:genre=>\"Metal\"}][Module, {:genre=>\"Metal\"}]" }
37
36
 
38
37
  # ViewModel.cell(collection: [], method: :detail) invokes #detail instead of #show.
39
- it { Cell::ViewModel.cell('public_test/song', nil, collection: [Object, Module], method: :detail).must_equal '* [Object, {}]* [Module, {}]' }
38
+ it { Cell::ViewModel.cell('public_test/song', collection: [Object, Module], method: :detail).must_equal '* [Object, {}]* [Module, {}]' }
40
39
  end
41
40
 
42
41
  # TODO: test AV::concept.