Class: ODDB::View::TestSponsorHead

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

Defined Under Namespace

Classes: StubCompany, StubHeadSession, StubPackage

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



103
104
105
106
107
108
109
110
111
112
113
114
# File 'test/test_view/sponsorhead.rb', line 103

def setup
  @session = StubHeadSession.new
  @comp = StubCompany.new
  @sponsor = ODDB::.new
  @sponsor.company = @comp
  @sponsor.logo_filenames.store(:default, 'sponsorlogo')
  @other = StubCompany.new
  @other.represents = false
  @pac = StubPackage.new
  @pac.company = @comp
  @logo_pattern = /<A><IMG src="sponsor\/sponsorlogo" alt="sponsorlogo"><SPAN class="sponsor\s+right">SPONSOR_UNTIL<.SPAN><.A>/
end

- (Object) test_display_sponsor



139
140
141
142
143
144
145
# File 'test/test_view/sponsorhead.rb', line 139

def test_display_sponsor
  @session. = @sponsor
  @sponsor. = Date.today
  view = View::SponsorHead.new([@pac], @session)
  html = view.to_html(CGI.new)
  assert_not_nil(@logo_pattern.match(html), "expected:\n#{@logo_pattern}\nbut was:\n#{html}")
end

- (Object) test_empty_model



115
116
117
118
# File 'test/test_view/sponsorhead.rb', line 115

def test_empty_model
  view = View::SponsorHead.new([], @session)
  assert_nil(@logo_pattern.match(view.to_html(CGI.new)))
end

- (Object) test_matching_sponsor_no_date



128
129
130
131
132
# File 'test/test_view/sponsorhead.rb', line 128

def test_matching_sponsor_no_date
  @session. = @sponsor
  view = View::SponsorHead.new([@pac], @session)
  assert_nil(@logo_pattern.match(view.to_html(CGI.new)))
end

- (Object) test_model_no_sponsor



119
120
121
122
# File 'test/test_view/sponsorhead.rb', line 119

def test_model_no_sponsor
  view = View::SponsorHead.new([@pac], @session)
  assert_nil(@logo_pattern.match(view.to_html(CGI.new)))
end

- (Object) test_model_nonmatching_sponsor



123
124
125
126
127
# File 'test/test_view/sponsorhead.rb', line 123

def test_model_nonmatching_sponsor
  @session. = @other
  view = View::SponsorHead.new([@pac], @session)
  assert_nil(@logo_pattern.match(view.to_html(CGI.new)))
end

- (Object) test_sponsor_time_over



133
134
135
136
137
138
# File 'test/test_view/sponsorhead.rb', line 133

def test_sponsor_time_over
  @session. = @sponsor
  @sponsor. = Date.new(2002,12,31)
  view = View::SponsorHead.new([@pac], @session)
  assert_nil(@logo_pattern.match(view.to_html(CGI.new)))
end