forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenu_spec.rb
More file actions
53 lines (42 loc) · 1.41 KB
/
menu_spec.rb
File metadata and controls
53 lines (42 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'
describe ActiveAdmin::Menu do
context "with no items" do
it "should be empty" do
ActiveAdmin::Menu.new.items.should == []
end
it "should accept new items" do
menu = ActiveAdmin::Menu.new
menu.add "Dashboard", "/admin"
menu.items.first.should be_an_instance_of(ActiveAdmin::MenuItem)
menu.items.first.name.should == "Dashboard"
end
it "should default new items to the priority of 10" do
menu = ActiveAdmin::Menu.new
menu.add "Dashboard", "/admin"
menu.items.first.priority.should == 10
end
end
context "with many item" do
let(:menu) do
ActiveAdmin::Menu.new do |m|
m.add "Dashboard", "/admin"
m.add "Blog", "/admin/blog"
m.add "Users", "/admin/users"
m.add "Settings", "/admin/settings" do |s|
s.add "Admin Settings", "/admin/settings/admin" do |as|
s.add "User Settings", "/admin/settings/users"
end
end
end
end
it "should give access to the menu item as an array" do
menu['Dashboard'].name.should == 'Dashboard'
end
it "should find the item by a url on the top level" do
menu.find_by_url("/admin").name.should == "Dashboard"
end
it "should find the item deep in the tree" do
menu.find_by_url("/admin/settings/users").name.should == "User Settings"
end
end
end