Class: ODDB::View::TestPager

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

Defined Under Namespace

Classes: StubSession

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



49
50
51
52
53
54
# File 'test/test_view/pager.rb', line 49

def setup
  @session = StubSession.new
  @session.page = 0
  @model = [0, 1, 2, 3, 4, 5]
  @view = View::Pager.new(@model, @session)
end

- (Object) test_page_link1



55
56
57
58
59
60
61
# File 'test/test_view/pager.rb', line 55

def test_page_link1
  result = @view.page_link(:to_s, 1)
  assert_instance_of(HtmlGrid::Link, result)
  assert_equal("1", result.value)
  url = /http:\/\/www.oddb.org\/de\/gcc\/result(\/state_id\/\d+)?\/page\/1/
  assert(url.match(result.attributes['href']), result.attributes['href'])
end

- (Object) test_page_link2



62
63
64
65
66
# File 'test/test_view/pager.rb', line 62

def test_page_link2
  @session.page = 1
  result = @view.page_link(:to_s, 1)
  assert_equal("1", result)
end

- (Object) test_to_html



67
68
69
70
71
72
73
74
# File 'test/test_view/pager.rb', line 67

def test_to_html
  assert_nothing_raised {
    @view.to_html(CGI.new)
  }
  result = @view.to_html(CGI.new)
  assert_not_nil(result.index('<TD class="pager">0</TD>'), "Page-Number without link did not have css-class")
  assert_nil(result.index('<TD class="pager-bg">'), "The pager should not have alternate bg-classes")
end