test/controller_test.rb in menu_builder-0.4.4 vs test/controller_test.rb in menu_builder-0.5
- old
+ new
@@ -1,41 +1,33 @@
require "test_helper"
+require_relative "./support/controllers"
-class ActiveSupport::TestCase
- setup do
- @routes = MenuBuilder::Routes
- end
-end
-
-class BooksController < ApplicationController
- menu_item :books
- def index ; end
-end
-
-class SettingsController < ApplicationController
- menu_items :settings, :home
-
- def index ; end
-
- def notifications
- menu_item :notification
- end
-end
-
class BooksControllerTest < ActionController::TestCase
test "assigns the current tab" do
get :index
assert_equal([:books], assigns(:menu_items))
end
end
class SettingsControllerTest < ActionController::TestCase
- test "ability to assign more than one current tab" do
+ test "can assign more than one current tab" do
get :index
- assert_equal([:settings, :home], assigns(:menu_items))
+ assert_equal(%i[settings home], assigns(:menu_items))
end
- test "that instance level menu_items override class level" do
+ test "can set action level menu_items" do
get :notifications
assert_equal([:notification], assigns(:menu_items))
end
-end
\ No newline at end of file
+end
+
+class AuthorsControllerTest < ActionController::TestCase
+ test "ability to append items" do
+ get :profile
+ assert_equal(%i[authors author_1 profile], assigns(:menu_items))
+ end
+
+ test "that instance level menu_items override class level" do
+ get :related
+ assert_equal(%i[related authors author_1], assigns(:menu_items))
+ end
+end