RootView.proto.activateExtension requires extensions to have names

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-06-14 11:20:36 -06:00
parent 810b9849ee
commit 940b7b0e7a
2 changed files with 4 additions and 0 deletions

View File

@ -355,6 +355,9 @@ describe "RootView", ->
newRootView.activateExtension(extension)
expect(extension.activate).toHaveBeenCalledWith(newRootView, "it worked")
it "throws an exception if the extension has no 'name' property", ->
expect(-> rootView.activateExtension({ activate: -> })).toThrow()
describe "deactivation", ->
it "is deactivated when the rootView is deactivated", ->
rootView.activateExtension(extension)

View File

@ -80,6 +80,7 @@ class RootView extends View
when 'Editor' then Editor.deserialize(viewState, this)
activateExtension: (extension) ->
throw new Error("Trying to activate an extension with no name") unless extension.name?
@extensions[extension.name] = extension
extension.activate(this, @extensionStates[extension.name])