Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lotus/view
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Dec 8, 2014
2 parents b755116 + 27df9c2 commit ce56fdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/lotus/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def self.dupe
# #
# # 1. Generate MyApp::View
# # 2. Generate MyApp::Layout
# # 3. Generate MyApp::Views
# # 4. Configure MyApp::Views as the default namespace for views
# # 3. Generate MyApp::Presenter
# # 4. Generate MyApp::Views
# # 5. Configure MyApp::Views as the default namespace for views
#
# module MyApp::Views::Dashboard
# class Index
Expand Down Expand Up @@ -227,7 +228,10 @@ def self.dupe
def self.duplicate(mod, views = 'Views', &blk)
dupe.tap do |duplicated|
mod.module_eval %{ module #{ views }; end } if views
mod.module_eval %{ Layout = Lotus::Layout.dup }
mod.module_eval %{
Layout = Lotus::Layout.dup
Presenter = Lotus::Presenter.dup
}

duplicated.configure do
namespace [mod, views].compact.join '::'
Expand Down
4 changes: 4 additions & 0 deletions test/view_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class AppLayout
assert defined?(Duplicated::Layout), 'Duplicated::Layout expected'
end

it 'duplicates Presenter' do
assert defined?(Duplicated::Presenter), 'Duplicated::Presenter expected'
end

it 'optionally accepts a block to configure the generated module' do
expected = DuplicatedConfigure::Views::AppLayout
DuplicatedConfigure::View.configuration.layout.must_equal expected
Expand Down

0 comments on commit ce56fdb

Please sign in to comment.