Sha256: 2df15ff6ddb7fd88ba783e1190175ac69f2de6c3f62d14f49b9e8bffcbdafc2a

Contents?: true

Size: 1.29 KB

Versions: 12

Compression:

Stored size: 1.29 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=>"/admin/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=>"/admin/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

12 entries across 12 versions & 1 rubygems

Version Path
typus-3.0.11 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.11.rc5 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.11.rc4 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.11.rc3 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc6 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc5 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc4 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc3 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc2 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.11.rc2 test/app/helpers/admin/resources_helper_test.rb
typus-3.0.11.rc1 test/app/helpers/admin/resources_helper_test.rb
typus-3.1.0.rc1 test/app/helpers/admin/resources_helper_test.rb