Sha256: ad3be60de09219fff7111f986833e84989207d0019c6be10bc0a0250148de0ed

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require "test_helper"

class Admin::ResourcesHelperTest < ActiveSupport::TestCase

  include Admin::ResourcesHelper

  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper

  def render(*args); args; end

  context "display_link_to_previous" do

    setup do
      @resource = Comment
    end

    should "set an url to new when not resource_id is passed" do
      params = { :resource => "Post" }

      expected = ["admin/helpers/resources/display_link_to_previous",
                  {:body=>"Cancel adding a new comment?", :url=>{:controller=>"posts", :action => 'new'}}]

      assert_equal expected, display_link_to_previous(params)
    end

    should "set an url to edit when resource_id is passed" do
      @post = Factory(:post)
      params = { :resource => "Post", :resource_id => @post.id }

      expected = ["admin/helpers/resources/display_link_to_previous",
                  {:body=>"Cancel adding a new comment?", :url=>{:controller=>"posts", :action => 'edit', :id => @post.id}}]

      assert_equal expected, display_link_to_previous(params)
    end

    should "return nil if no resource is passed" do
      params = { :action => "edit" }
      self.expects(:params).at_least_once.returns(params)

      assert_nil display_link_to_previous
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typus-3.0.10 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.9 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.8 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.7 test/app/helpers/admin/resources_helper_test.rb