Class: SiteControllerTest

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

Defined Under Namespace

Classes: ThereShouldBeNoSuchRealClassNameGoldbergTestController

Instance Method Summary collapse

Methods included from Goldberg::TestHelper

#form_login, #form_logout, included, #login_user

Instance Method Details

#setupObject



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

def setup
  @p = Goldberg::Permission.find :first
end

#test_classes_finds_direct_controller_derivativesObject



47
48
49
50
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/site_controller_test.rb', line 47

def test_classes_finds_direct_controller_derivatives
  classes = Goldberg::SiteController.classes
  assert(classes.has_value?(SiteControllerTest::ThereShouldBeNoSuchRealClassNameGoldbergTestController))
end

#test_invalid_without_nameObject



10
11
12
13
14
15
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/site_controller_test.rb', line 10

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

#test_uniqueness_of_nameObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/site_controller_test.rb', line 18

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

  site_controller_1 = Goldberg::SiteController.new
  site_controller_1.permission = @p
  site_controller_2 = Goldberg::SiteController.new
  site_controller_2.permission = @p

  site_controller_1.name = name_1
  site_controller_2.name = name_2

  assert(site_controller_1.save)
  assert(site_controller_2.save)

  site_controller_2.name = name_1

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