This project is archived and is in readonly mode.

#773 ✓stale
papricek

Unfunctional ActionView::TestCase

Reported by papricek | August 7th, 2008 @ 02:29 PM | in 2.x

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

Comments and changes to this ticket

  • papricek

    papricek August 8th, 2008 @ 09:04 AM

    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

  • papricek

    papricek August 8th, 2008 @ 09:05 AM

    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

  • josh

    josh November 10th, 2008 @ 06:49 PM

    • State changed from “new” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages