Class: PermissionTest

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

Instance Method Summary collapse

Methods included from Goldberg::TestHelper

#form_login, #form_logout, included, #login_user

Instance Method Details

#test_invalid_without_nameObject



6
7
8
9
10
11
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/permission_test.rb', line 6

def test_invalid_without_name
  permission = Goldberg::Permission.new
  assert(!permission.valid?)
  assert(permission.errors.invalid?(:name))
  assert(!permission.save)
end

#test_uniqueness_of_nameObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/permission_test.rb', line 14

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

  permission_1 = Goldberg::Permission.new
  permission_2 = Goldberg::Permission.new

  permission_1.name = name_1
  permission_2.name = name_2

  assert(permission_1.save)
  assert(permission_2.save)

  permission_2.name = name_1

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