Class: ODDB::View::TestSearch

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_view/asearch.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



27
28
29
30
31
32
33
34
35
36
37
# File 'test/test_view/asearch.rb', line 27

def setup
  ODBA.storage = Mock.new
  ODBA.storage.__next(:next_id) {
    1
  }
  GalenicGroup.reset_oid
  validator = Validator.new
  @session = Session.new("test", App.new, validator)
  @session.lookandfeel = LookandfeelBase.new(@session)
  @view = View::Search.new(nil, @session)
end

- (Object) teardown



38
39
40
# File 'test/test_view/asearch.rb', line 38

def teardown
  ODBA.storage = nil
end

- (Object) test_http_headers

def test_to_html

      result = ''
      assert_nothing_raised {
        result << @view.to_html(CGI.new)
      }
      expected = [
        '<INPUT name="search_query" class="search-center" onFocus="if (value==\'HIER Medikament / Wirkstoff eingeben\') { value=\'\' }" type="text" onBlur="if (value==\'\') { value=\'HIER Medikament / Wirkstoff eingeben\' }" value="HIER Medikament / Wirkstoff eingeben" tabIndex="1">',
      ]
      expected.each { |line|
        assert(result.index(line), "expected #{line} in\n#{CGI.pretty(result)}")
      }
    end


55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'test/test_view/asearch.rb', line 55

def test_http_headers
  headers = @view.http_headers
  time = headers["Expires"]
  expected = {
    "Content-Type"  => "text/html; charset=UTF-8",
    "Cache-Control" =>  "private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
    "Pragma"        =>  "no-cache",
    "Expires"       => time,
    "P3P"           => "CP='OTI NID CUR OUR STP ONL UNI PRE'",
  }
  assert_equal(expected, headers)
  pattern = /^[A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} (\d{2}:){2}\d{2} GMT$/
  assert_match(pattern, time)
end