cells 4.0.0.beta4 → 4.0.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +19 -0
- data/Rakefile +11 -0
- data/cells.gemspec +3 -4
- data/gemfiles/rails4.2.gemfile +0 -7
- data/lib/cell.rb +19 -19
- data/lib/cell/abstract.rb +9 -0
- data/lib/cell/caching.rb +16 -17
- data/lib/cell/concept.rb +2 -4
- data/lib/cell/prefixes.rb +3 -2
- data/lib/cell/rails.rb +27 -4
- data/lib/cell/railtie.rb +47 -42
- data/lib/cell/testing.rb +12 -9
- data/lib/cell/twin.rb +2 -2
- data/lib/cell/util.rb +16 -0
- data/lib/cell/version.rb +1 -8
- data/lib/cell/view_model.rb +63 -90
- data/test/builder_test.rb +5 -5
- data/test/caching_test.rb +2 -2
- data/test/cell_test.rb +1 -1
- data/test/concept_test.rb +24 -10
- data/test/dummy/config/application.rb +1 -1
- data/test/public_test.rb +8 -9
- data/test/rails4.2/.gitignore +13 -0
- data/test/rails4.2/Gemfile +16 -0
- data/test/rails4.2/README.rdoc +3 -0
- data/test/rails4.2/Rakefile +6 -0
- data/test/rails4.2/app/assets/images/.keep +0 -0
- data/test/rails4.2/app/assets/stylesheets/application.css +17 -0
- data/test/rails4.2/app/cells/song/song.css +1 -0
- data/test/rails4.2/app/cells/song_cell.rb +2 -0
- data/test/rails4.2/app/controllers/application_controller.rb +5 -0
- data/test/rails4.2/app/controllers/concerns/.keep +0 -0
- data/test/rails4.2/app/controllers/index_controller.rb +7 -0
- data/test/rails4.2/app/helpers/application_helper.rb +2 -0
- data/test/rails4.2/app/mailers/.keep +0 -0
- data/test/rails4.2/app/models/.keep +0 -0
- data/test/rails4.2/app/models/concerns/.keep +0 -0
- data/test/rails4.2/app/views/index/index.html.erb +6 -0
- data/test/rails4.2/app/views/layouts/application.html.erb +13 -0
- data/test/rails4.2/bin/bundle +3 -0
- data/test/rails4.2/bin/rails +4 -0
- data/test/rails4.2/bin/rake +4 -0
- data/test/rails4.2/bin/setup +29 -0
- data/test/rails4.2/config.ru +4 -0
- data/test/rails4.2/config/application.rb +38 -0
- data/test/rails4.2/config/boot.rb +3 -0
- data/test/rails4.2/config/environment.rb +5 -0
- data/test/rails4.2/config/environments/development.rb +25 -0
- data/test/rails4.2/config/environments/production.rb +64 -0
- data/test/rails4.2/config/environments/test.rb +42 -0
- data/test/rails4.2/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails4.2/config/initializers/cookies_serializer.rb +3 -0
- data/test/rails4.2/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails4.2/config/initializers/inflections.rb +16 -0
- data/test/rails4.2/config/initializers/mime_types.rb +4 -0
- data/test/rails4.2/config/initializers/session_store.rb +3 -0
- data/test/rails4.2/config/initializers/wrap_parameters.rb +9 -0
- data/test/rails4.2/config/locales/en.yml +23 -0
- data/test/rails4.2/config/routes.rb +4 -0
- data/test/rails4.2/config/secrets.yml +22 -0
- data/test/rails4.2/db/seeds.rb +7 -0
- data/test/rails4.2/engines/my_engine/.gitignore +3 -0
- data/test/rails4.2/engines/my_engine/Gemfile +15 -0
- data/test/rails4.2/engines/my_engine/MIT-LICENSE +20 -0
- data/test/rails4.2/engines/my_engine/README.rdoc +3 -0
- data/test/rails4.2/engines/my_engine/Rakefile +24 -0
- data/test/rails4.2/engines/my_engine/app/assets/images/my_engine/.keep +0 -0
- data/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css +15 -0
- data/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb +8 -0
- data/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb +1 -0
- data/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss +3 -0
- data/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb +4 -0
- data/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb +7 -0
- data/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb +4 -0
- data/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb +4 -0
- data/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb +14 -0
- data/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb +3 -0
- data/test/rails4.2/engines/my_engine/bin/rails +12 -0
- data/test/rails4.2/engines/my_engine/config/routes.rb +3 -0
- data/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb +8 -0
- data/test/rails4.2/engines/my_engine/lib/my_engine.rb +6 -0
- data/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb +9 -0
- data/test/rails4.2/engines/my_engine/lib/my_engine/version.rb +3 -0
- data/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake +4 -0
- data/test/rails4.2/engines/my_engine/my_engine.gemspec +24 -0
- data/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml +11 -0
- data/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb +9 -0
- data/test/rails4.2/lib/assets/.keep +0 -0
- data/test/rails4.2/lib/tasks/.keep +0 -0
- data/test/rails4.2/log/.keep +0 -0
- data/test/rails4.2/public/404.html +67 -0
- data/test/rails4.2/public/422.html +67 -0
- data/test/rails4.2/public/500.html +66 -0
- data/test/rails4.2/public/favicon.ico +0 -0
- data/test/rails4.2/public/robots.txt +5 -0
- data/test/rails4.2/test/integration/asset_pipeline_test.rb +17 -0
- data/test/rails4.2/test/test_helper.rb +14 -0
- data/test/rails4.2/vendor/assets/stylesheets/.keep +0 -0
- data/test/twin_test.rb +1 -1
- data/test/url_helper_test.rb +1 -1
- metadata +83 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3732dd6583b86eaee3a97d864d066cfe8f4268f3
|
4
|
+
data.tar.gz: 95c3e9832728d606d3118b723904276e4a58c958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e422083ff700c7a9ddd1a5d4d8e2a53833d6b8b55b88042aa5d858210363f331495622c03c264cc1d846ed91f2007a0405755122fb2669108251a524f67910
|
7
|
+
data.tar.gz: 7d691187b2b8123cfc131e58803bf9b5f280ce568486d0449ab86ac1ce704f96db48ea1647c79033c6d22a3c50895119d24079d75d39f2b0818a8a3d953538c7
|
data/CHANGES.md
CHANGED
@@ -18,12 +18,31 @@
|
|
18
18
|
|
19
19
|
* When using HAML, we do not use any of HAML's helper hacks to "fix" ActionView and XSS. While you might not note this, it removes tons of code from our stack.
|
20
20
|
|
21
|
+
|
22
|
+
## 4.0.0.beta5
|
23
|
+
|
24
|
+
* Assets bundled in engine cells now work.
|
25
|
+
* Directory change: Assets like `.css`, `.coffee` and `.js`, no longer have their own `assets/` directory but live inside the views directory of a cell. It turned out that two directories `views/` and `assets/` was too noisy for most users. If you think you have a valid point for re-introducing it, email me, it is not hard to implement.
|
26
|
+
* When bundling your cell's assets into the asset pipeline, you have to specify the full name of your cell. The names will be constantized.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
config.cells.with_assets = ["song/cell", "user_cell"] #=> Song::Cell, UserCell
|
30
|
+
```
|
31
|
+
* `ViewModel` is now completely decoupled from Rails and doesn't inherit from AbstractController anymore.
|
32
|
+
* API change: The controller dependency is now a second-class citizen being passed into the cell via options.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Cell.new(model, {controller: ..})
|
36
|
+
```
|
37
|
+
* Removing `actionpack` from gemspec.
|
38
|
+
|
21
39
|
## 4.0.0.beta4
|
22
40
|
|
23
41
|
* Fixed a bug when rendering more than once with ERB, the output buffer was being reused.
|
24
42
|
* API change: ViewModel::_prefixes now returns the "fully qualified" pathes including the view paths, prepended to the prefixes. This allows multiple view paths and basically fixes cells in engines.
|
25
43
|
* The only public way to retrieve prefixes for a cell is `ViewModel::prefixes`. The result is cached.
|
26
44
|
|
45
|
+
|
27
46
|
## 4.0.0.beta3
|
28
47
|
|
29
48
|
* Introduce `Cell::Testing` for Rspec and MiniTest.
|
data/Rakefile
CHANGED
@@ -11,3 +11,14 @@ Rake::TestTask.new(:test) do |test|
|
|
11
11
|
test.pattern = 'test/*_test.rb'
|
12
12
|
test.verbose = true
|
13
13
|
end
|
14
|
+
|
15
|
+
# Rake::TestTask.new(:rails) do |test|
|
16
|
+
# test.libs << 'test/rails'
|
17
|
+
# test.test_files = FileList['test/rails4.2/*_test.rb']
|
18
|
+
# test.verbose = true
|
19
|
+
# end
|
20
|
+
|
21
|
+
# rails_task = Rake::Task["rails"]
|
22
|
+
# test_task = Rake::Task["test"]
|
23
|
+
# default_task.enhance { test_task.invoke }
|
24
|
+
# default_task.enhance { rails_task.invoke }
|
data/cells.gemspec
CHANGED
@@ -5,13 +5,13 @@ require 'cell/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "cells"
|
8
|
-
spec.version = Cell::VERSION
|
8
|
+
spec.version = Cell::VERSION
|
9
9
|
spec.platform = Gem::Platform::RUBY
|
10
10
|
spec.authors = ["Nick Sutterer"]
|
11
11
|
spec.email = ["apotonick@gmail.com"]
|
12
12
|
spec.homepage = "https://github.com/apotonick/cells"
|
13
|
-
spec.summary = %q{View Models for Rails.}
|
14
|
-
spec.description = %q{Cells
|
13
|
+
spec.summary = %q{View Models for Ruby and Rails.}
|
14
|
+
spec.description = %q{Cells replaces partials and helpers with OOP view models, giving you proper encapsulation, inheritance, testability and a cleaner view architecture.}
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files`.split("\n")
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency 'actionpack', '>= 3.2'
|
23
22
|
spec.add_dependency "uber", "~> 0.0.9"
|
24
23
|
spec.add_dependency 'tilt', '>= 1.4', '< 3'
|
25
24
|
spec.add_dependency 'disposable', '~> 0.0.8'
|
data/gemfiles/rails4.2.gemfile
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
1
|
source "https://rubygems.org"
|
4
2
|
|
5
|
-
gem "minitest-reporters"
|
6
|
-
gem "pry-byebug", :platforms => [:mri_20, :mri_21]
|
7
|
-
gem "appraisal"
|
8
|
-
gem "rake"
|
9
|
-
gem "test_xml"
|
10
3
|
gem "railties", "~> 4.2.0"
|
11
4
|
gem "activemodel", "~> 4.2.0"
|
12
5
|
gem "minitest", "~> 5.2"
|
data/lib/cell.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require 'active_support/dependencies/autoload'
|
1
|
+
require "tilt"
|
2
|
+
require "uber/inheritable_attr"
|
3
|
+
require "uber/delegates"
|
4
|
+
require "cell/version"
|
6
5
|
|
7
6
|
module Cell
|
8
|
-
|
9
|
-
|
10
|
-
autoload :Concept
|
11
|
-
autoload :TestCase
|
12
|
-
autoload :Testing
|
7
|
+
autoload :TestCase, "cell/test_case"
|
8
|
+
autoload :Testing, "cell/testing"
|
13
9
|
|
14
10
|
def self.rails_version
|
15
11
|
Gem::Version.new(ActionPack::VERSION::STRING)
|
@@ -22,13 +18,17 @@ module Cell
|
|
22
18
|
end # Error
|
23
19
|
end
|
24
20
|
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
21
|
+
require "cell/caching"
|
22
|
+
require "cell/caching/notification"
|
23
|
+
require "uber/builder"
|
24
|
+
require "cell/prefixes"
|
25
|
+
require "cell/self_contained"
|
26
|
+
require "cell/layout"
|
27
|
+
require "cell/templates"
|
28
|
+
require "cell/abstract"
|
29
|
+
require "cell/util"
|
30
|
+
require "cell/view_model"
|
31
|
+
require "cell/concept"
|
32
|
+
|
33
33
|
|
34
|
-
require
|
34
|
+
require "cell/railtie" if defined?(Rails)
|
data/lib/cell/caching.rb
CHANGED
@@ -1,25 +1,24 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'active_support/cache'
|
3
1
|
require 'uber/options'
|
4
2
|
|
5
3
|
module Cell
|
6
4
|
module Caching
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
def self.included(includer)
|
6
|
+
includer.class_eval do
|
7
|
+
extend ClassMethods
|
8
|
+
extend Uber::InheritableAttr
|
9
|
+
inheritable_attr :version_procs
|
10
|
+
inheritable_attr :conditional_procs
|
11
|
+
inheritable_attr :cache_options
|
12
|
+
|
13
|
+
self.version_procs = {}
|
14
|
+
self.conditional_procs = {}
|
15
|
+
self.cache_options = Uber::Options.new({})
|
16
|
+
end
|
18
17
|
end
|
19
18
|
|
20
19
|
module ClassMethods
|
21
20
|
def cache(state, *args, &block)
|
22
|
-
options = args.extract_options
|
21
|
+
options = args.last.is_a?(Hash) ? args.pop : {} # I have to admit, Array#extract_options is a brillant tool.
|
23
22
|
|
24
23
|
self.conditional_procs[state] = Uber::Options::Value.new(options.delete(:if) || true)
|
25
24
|
self.version_procs[state] = Uber::Options::Value.new(args.first || block)
|
@@ -38,7 +37,7 @@ module Cell
|
|
38
37
|
private
|
39
38
|
|
40
39
|
def expand_cache_key(key)
|
41
|
-
|
40
|
+
key.join("/") # TODO: test me!
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -53,7 +52,7 @@ module Cell
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def cache_store # we want to use DI to set a cache store in cell/rails.
|
56
|
-
|
55
|
+
raise "No cache store has been set."
|
57
56
|
end
|
58
57
|
|
59
58
|
def cache?(state, *args)
|
@@ -63,7 +62,7 @@ module Cell
|
|
63
62
|
private
|
64
63
|
|
65
64
|
def perform_caching?
|
66
|
-
|
65
|
+
true
|
67
66
|
end
|
68
67
|
|
69
68
|
def fetch_from_cache_for(key, options)
|
data/lib/cell/concept.rb
CHANGED
@@ -9,13 +9,11 @@ class Cell::Concept < Cell::ViewModel
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def controller_path
|
12
|
-
@controller_path ||= name.sub(/::Cell/, '')
|
12
|
+
@controller_path ||= util.underscore(name.sub(/::Cell/, ''))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
self.class.cell(name, parent_controller, *args, &block)
|
18
|
-
end
|
16
|
+
alias_method :concept, :cell # the #cell helper to instantiate cells in cells.
|
19
17
|
|
20
18
|
self_contained!
|
21
19
|
end
|
data/lib/cell/prefixes.rb
CHANGED
data/lib/cell/rails.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
module Cell
|
3
3
|
module RailsExtensions
|
4
4
|
module ActionController
|
5
|
-
def cell(name,
|
6
|
-
ViewModel.cell(name,
|
5
|
+
def cell(name, model=nil, options={}, &block)
|
6
|
+
::Cell::ViewModel.cell(name, model, options.merge(controller: self), &block)
|
7
7
|
end
|
8
8
|
|
9
|
-
def concept(name,
|
10
|
-
Concept.cell(name,
|
9
|
+
def concept(name, model=nil, options={}, &block)
|
10
|
+
::Cell::Concept.cell(name, model, options.merge(controller: self), &block)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -29,5 +29,28 @@ module Cell
|
|
29
29
|
controller.concept(name, *args, &block)
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
# Gets included into Cell::ViewModel in a Rails environment.
|
34
|
+
module ViewModel
|
35
|
+
extend ActiveSupport::Concern
|
36
|
+
|
37
|
+
def call(*)
|
38
|
+
super.html_safe
|
39
|
+
end
|
40
|
+
|
41
|
+
def perform_caching?
|
42
|
+
::ActionController::Base.perform_caching
|
43
|
+
end
|
44
|
+
|
45
|
+
def cache_store # we want to use DI to set a cache store in cell/rails.
|
46
|
+
::ActionController::Base.cache_store
|
47
|
+
end
|
48
|
+
|
49
|
+
module ClassMethods
|
50
|
+
def expand_cache_key(key)
|
51
|
+
::ActiveSupport::Cache.expand_cache_key(key, :cells)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
32
55
|
end
|
33
56
|
end
|
data/lib/cell/railtie.rb
CHANGED
@@ -1,60 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ViewModel.class_eval do
|
12
|
-
include app.routes.url_helpers # TODO: i hate this, make it better in Rails.
|
13
|
-
end
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module Cell
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
require 'cell/rails'
|
6
|
+
config.cells = ActiveSupport::OrderedOptions.new
|
7
|
+
|
8
|
+
initializer('cells.attach_router') do |app|
|
9
|
+
ViewModel.class_eval do
|
10
|
+
include app.routes.url_helpers # TODO: i hate this, make it better in Rails.
|
14
11
|
end
|
12
|
+
end
|
13
|
+
|
14
|
+
initializer 'cells.template_engine' do |app|
|
15
|
+
ViewModel.template_engine = app.config.app_generators.rails.fetch(:template_engine, 'erb').to_s
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
# ruthlessly stolen from the zurb-foundation gem.
|
19
|
+
initializer 'cells.update_asset_paths' do |app|
|
20
|
+
Array(app.config.cells.with_assets).each do |cell_class|
|
21
|
+
# puts "@@@@@ #{cell_class.camelize.constantize.prefixes}"
|
22
|
+
app.config.assets.paths += cell_class.camelize.constantize.prefixes # Song::Cell.prefixes
|
18
23
|
end
|
24
|
+
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
app.config.assets.paths.append "#{app.root}/app/cells/#{name}/assets"
|
25
|
-
app.config.assets.paths.append "#{app.root}/app/concepts/#{name}/assets" # TODO: find out type.
|
26
|
+
initializer('cells.rails_extensions') do |app|
|
27
|
+
ActiveSupport.on_load(:action_controller) do
|
28
|
+
self.class_eval do
|
29
|
+
include ::Cell::RailsExtensions::ActionController
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
include ::Cell::RailsExtensions::ActionController
|
33
|
-
end
|
33
|
+
ActiveSupport.on_load(:action_view) do |app|
|
34
|
+
self.class_eval do
|
35
|
+
include ::Cell::RailsExtensions::ActionView
|
34
36
|
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
#include assert helpers (image_path, font_path, ect)
|
42
|
-
ViewModel.class_eval do
|
43
|
-
include ActionView::Helpers::AssetTagHelper
|
44
|
-
end
|
38
|
+
#include assert helpers (image_path, font_path, ect)
|
39
|
+
ViewModel.class_eval do
|
40
|
+
include ActionView::Helpers::AssetTagHelper
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
# set VM#cache_store, etc.
|
45
|
+
ViewModel.send(:include, RailsExtensions::ViewModel)
|
46
|
+
|
47
|
+
if defined?(ActionView)
|
48
|
+
# always include those helpers so we can override the shitty parts.
|
49
|
+
ViewModel.send(:include, ActionView::Helpers::UrlHelper)
|
50
|
+
ViewModel.send(:include, ActionView::Helpers::FormTagHelper)
|
53
51
|
end
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
initializer('cells.development') do |app|
|
55
|
+
if Rails.env == "development"
|
56
|
+
require "cell/development"
|
57
|
+
ViewModel.send(:include, Development)
|
57
58
|
end
|
58
59
|
end
|
60
|
+
|
61
|
+
rake_tasks do
|
62
|
+
load 'tasks/cells.rake'
|
63
|
+
end
|
59
64
|
end
|
60
65
|
end
|
data/lib/cell/testing.rb
CHANGED
@@ -11,8 +11,8 @@ module Cell
|
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
|
-
def cell_for(baseclass, name,
|
15
|
-
cell = baseclass.cell(name,
|
14
|
+
def cell_for(baseclass, name, model=nil, options={})
|
15
|
+
cell = baseclass.cell(name, model, options.merge(controller: controller))
|
16
16
|
cell.extend(Capybara) if Cell::Testing.capybara? # leaving this here as most people use Capybara.
|
17
17
|
cell
|
18
18
|
end
|
@@ -42,23 +42,26 @@ module Cell
|
|
42
42
|
|
43
43
|
|
44
44
|
# Rails specific.
|
45
|
-
def
|
45
|
+
def controller_for(controller_class)
|
46
46
|
# TODO: test without controller.
|
47
|
-
return unless
|
47
|
+
return unless controller_class
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
ctl.
|
52
|
-
ctl.instance_variable_set :@routes, Rails.application.routes.url_helpers
|
49
|
+
controller_class.new.tap do |ctl|
|
50
|
+
ctl.request = ::ActionController::TestRequest.new
|
51
|
+
ctl.instance_variable_set :@routes, ::Rails.application.routes.url_helpers
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
55
|
+
def controller # FIXME: this won't allow us using let(:controller) in MiniTest.
|
56
|
+
controller_for(self.class.controller_class)
|
57
|
+
end
|
58
|
+
|
56
59
|
def self.included(base)
|
57
60
|
base.class_eval do
|
58
61
|
extend Uber::InheritableAttr
|
59
62
|
inheritable_attr :controller_class
|
60
63
|
|
61
|
-
def self.controller(name)
|
64
|
+
def self.controller(name) # DSL method for the test.
|
62
65
|
self.controller_class = name
|
63
66
|
end
|
64
67
|
end
|