Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Unfunctional ActionView::TestCase

#773

When testing helpers with ActionView::TestCase, everything's ok, until I use a route with hash parameters. Then I get these errors:

NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.rewrite

C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:621:in `url_for'
(eval):17:in `admin_advertisements_advertisement_clicked_url'
C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/test_case.rb:54:in `send!'
C:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/test_case.rb:54:in `method_missing'
D:/www/svatba123/app/helpers/admin/advertisements_helper.rb:36:in `link_to_advertisement'
D:/www/svatba123/app/helpers/admin/advertisements_helper.rb:44:in `render_skyscraper'
D:/www/svatba123/app/helpers/admin/advertisements_helper.rb:20:in `render_advertisements'
D:/www/svatba123/app/helpers/admin/advertisements_helper.rb:14:in `each'
D:/www/svatba123/app/helpers/admin/advertisements_helper.rb:14:in `render_advertisements'
test/functional/admin/advertisements_helper_test.rb:13:in `test_render_advertisement_one'
C:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:67:in `__send__'
C:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:67:in `run'

1 tests, 0 assertions, 0 failures, 1 errors

Reported by papricek · August 7th, 2008 @ 02:29 PM

State: stale
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. papricek
    papricek

    require File.dirname(FILE) + '/../../testhelper' require 'admin/advertisementshelper'

    class Admin::AdvertisementsHelperTest < ActionView::TestCase

    include Admin::AdvertisementsHelper fixtures :advertisements, :advertisers, :advertisementassignments, :advertisementpositions

    def testrenderadvertisement_one

    position = advertisement_positions(:one)
    a = advertisements(:one)
    html = render_advertisements(position.slug, 1)
    assert_match /#{a.id}/, html, "HTML reklamy obsahuje id reklamy"
    assert_match /skyscraper/, html, "Div reklamy obsahuje spravny class"
    

    end end

    August 8th, 2008 @ 09:04 AM

  2. papricek
    papricek

    require File.dirname(FILE) + '/../../testhelper' require 'admin/advertisementshelper'

    class Admin::AdvertisementsHelperTest < ActionView::TestCase

    include Admin::AdvertisementsHelper fixtures :advertisements, :advertisers, :advertisementassignments, :advertisementpositions

    def testrenderadvertisement_one

    position = advertisement_positions(:one)
    a = advertisements(:one)
    html = render_advertisements(position.slug, 1)
    assert_match /#{a.id}/, html, "HTML reklamy obsahuje id reklamy"
    assert_match /skyscraper/, html, "Div reklamy obsahuje spravny class"
    

    end end

    module Admin::AdvertisementsHelper

    def render_advertisements(type, count)

    ads = Advertisement.find_for_position(type, count)
    html = ""
    ads.each do |ad|
      if ad.script.empty?
        html << case ad.ad_type
        when "Fullbanner"
          render_fullbanner(ad)
        when "Skyscraper"
          render_skyscraper(ad)
        when "Text"
          render_text_ad(ad)
        when "Flash"
          render_flash(ad)
        when "Halfbanner"
          render_halfbanner(ad)
        end
      else
        html << ad.script
      end
    end
    return html
    

    end etc... end

    August 8th, 2008 @ 09:05 AM

  3. josh
    josh
    • State changed from new to stale

    November 10th, 2008 @ 06:49 PM