Class: MenuItemTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
Goldberg::TestHelper
Defined in:
lib/six-updater-web/vendor/plugins/goldberg/test/unit/menu_item_test.rb

Instance Method Summary collapse

Methods included from Goldberg::TestHelper

#form_login, #form_logout, included, #login_user

Instance Method Details

#test_must_have_content_page_or_controller_actionObject



38
39
40
41
42
43
44
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/menu_item_test.rb', line 38

def test_must_have_content_page_or_controller_action
  mi = Goldberg::MenuItem.new(:name => 'test', :label => 'Test')
  assert(!mi.valid?)
  assert(mi.errors.invalid?(:content_page_id))
  assert(mi.errors.invalid?(:controller_action_id))
  assert(!mi.save)
end

#test_name_is_requiredObject



30
31
32
33
34
35
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/menu_item_test.rb', line 30

def test_name_is_required
  mi = Goldberg::MenuItem.new(:content_page_id => 1)
  assert(!mi.valid?)
  assert(mi.errors.invalid?(:name))
  assert(!mi.save)
end

#test_name_is_uniqueObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/menu_item_test.rb', line 6

def test_name_is_unique
  name_1 = 'THIS_IS_NAME_1'
  name_2 = 'THIS_IS_NAME_2'
  name_1.freeze
  name_2.freeze

  menu_item_1 = Goldberg::MenuItem.new(:content_page_id => 1)
  menu_item_2 = Goldberg::MenuItem.new(:content_page_id => 1)

  menu_item_1.name = name_1
  menu_item_1.label = 'This is name 1'
  menu_item_2.name = name_2
  menu_item_2.label = 'This is name 2'

  assert(menu_item_1.save)
  assert(menu_item_2.save)

  menu_item_2.name = name_1

  assert(!menu_item_2.save)
  assert(menu_item_2.errors.invalid?(:name))
end