Browse files

Cells.setup now yields Cell::Base. Removed the completely unusable an…

…d UNTESTED view_paths= methods in Cells. Thanks to Thierry Passeron for spotting.
  • Loading branch information...
1 parent 8d66f2d commit 175dbd9e4e9e023a4e3f7657fb096146b3dd1b02 @apotonick apotonick committed Dec 23, 2010
Showing with 31 additions and 22 deletions.
  1. +6 −0 CHANGES.textile
  2. +4 −22 lib/cells.rb
  3. +21 −0 test/cells_module_test.rb
View
6 CHANGES.textile
@@ -1,3 +1,9 @@
+h2. 3.4.4
+
+h3. Changes
+ * Cells.setup now yields Cell::Base, so you can really call append_view_path and friends here.
+
+
h2. 3.4.3
h3. Changes
View
26 lib/cells.rb
@@ -66,40 +66,22 @@
require 'cell/test_case' if Object.const_defined?("Rails") and Rails.env == "test"
module Cells
- # Any config should be placed here using +mattr_accessor+.
-
# Default view paths for Cells.
DEFAULT_VIEW_PATHS = [
File.join('app', 'cells'),
File.join('app', 'cells', 'layouts')
]
- class << self
- # Holds paths in which Cells should look for cell views (i.e. view template files).
- #
- # == Default:
- #
- # * +app/cells+
- # * +app/cells/layouts+
- #
- def self.view_paths
- ::Cell::Base.view_paths
- end
- def self.view_paths=(paths)
- ::Cell::Base.view_paths = paths
- end
- end
-
- # Cells setup/configuration helper for initializer.
+ # Setup your special needs for Cells here. Use this to add new view paths.
#
- # == Usage/Examples:
+ # Example:
#
# Cells.setup do |config|
- # config.cell_view_paths << Rails.root.join('lib', 'cells')
+ # config.append_view_path << "app/view_models"
# end
#
def self.setup
- yield(self)
+ yield(Cell::Base)
end
end
View
21 test/cells_module_test.rb
@@ -0,0 +1,21 @@
+require 'test_helper'
+
+class CellsModuleTest < ActiveSupport::TestCase
+ context "Cells" do
+ setup do
+ @old_view_paths = Cell::Base.view_paths.clone
+ end
+
+ should "provide .setup" do
+ Cells.setup do |c|
+ c.append_view_path "/road/to/nowhere"
+ end
+
+ assert_equal "/road/to/nowhere", Cell::Base.view_paths.last.to_s
+ end
+
+ teardown do
+ Cell::Base.view_paths = @old_view_paths
+ end
+ end
+end

0 comments on commit 175dbd9

Please sign in to comment.