Skip to content

Commit

Permalink
NodeController: autodetect custom node builder
Browse files Browse the repository at this point in the history
  • Loading branch information
miks committed Jan 21, 2015
1 parent f47d85e commit 141c17c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Expand Up @@ -18,6 +18,14 @@ def content_type_dialog
end
end

def builder_scopes
[node_builder_scope] + super
end

def node_builder_scope
[Releaf.mount_location.capitalize, "Nodes"].reject(&:empty?).join("::")
end

def copy_dialog
copy_move_dialog_common
end
Expand Down
@@ -0,0 +1,20 @@
require 'spec_helper'

describe Releaf::Content::NodesController do
describe "#builder_scopes" do
it "adds node builder scope as first scope before default builder scopes" do
allow(subject).to receive(:node_builder_scope).and_return("xx")
expect(subject.builder_scopes).to eq(["xx", "Releaf::Content::Nodes"])
end
end

describe "#node_builder_scope" do
it "returns node builder scope within releaf mount location scope" do
allow(Releaf).to receive(:mount_location).and_return("admin")
expect(subject.node_builder_scope).to eq("Admin::Nodes")

allow(Releaf).to receive(:mount_location).and_return("")
expect(subject.node_builder_scope).to eq("Nodes")
end
end
end

0 comments on commit 141c17c

Please sign in to comment.