Sha256: 9eaa2bd0d3acba8b66b7d80045248ed3ad1dcaa2f696ca5080985b16a2d993b2

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 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

    should "verify display_link_to_previous" do
      @resource = Post
      params = { :action => "edit", :back_to => "/back_to_param" }
      self.expects(:params).at_least_once.returns(params)

      expected = [ "admin/helpers/resources/display_link_to_previous", { :message => "You're updating a Post." } ]
      output = display_link_to_previous

      assert_equal expected, output
    end
  end

  context "remove_filter_link" do

    should "return nil when blank" do
      output = remove_filter_link("")
      assert_nil output
    end

    should "return link when it's present"

  end

  context "build_list" do

    setup do
      @model = TypusUser
      @fields = %w( email role status )
      @items = TypusUser.all
      @resource = "typus_users"
    end

    should "return a table" do
      expected = [ "admin/typus_users/list", { :items => [] } ]
      output = build_list(@model, @fields, @items, @resource)
      assert_equal expected, output
    end

    should "return a template" do
      self.stubs(:render).returns("a_template")
      File.stubs(:exist?).returns(true)

      expected = "a_template"
      output = build_list(@model, @fields, @items, @resource)

      assert_equal expected, output
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-3.0.2 test/helpers/admin/resources_helper_test.rb
typus-3.0.1 test/helpers/admin/resources_helper_test.rb
typus-3.0.0 test/helpers/admin/resources_helper_test.rb
typus-1.0.0.pre13 test/helpers/admin/resources_helper_test.rb
typus-1.0.0.pre12 test/helpers/admin/resources_helper_test.rb
typus-1.0.0.pre11 test/helpers/admin/resources_helper_test.rb
typus-1.0.0.pre10 test/helpers/admin/resources_helper_test.rb
typus-1.0.0.pre9 test/helpers/admin/resources_helper_test.rb