Sha256: b1abafb8d776e61a36377c26f231ec5113a85d57af987811a4b593eead50404c

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

class AutoLinkMockResource
  attr_accessor :namespace
  def initialize(namespace)
    @namespace = namespace
  end
end

describe "auto linking resources" do
  include ActiveAdmin::ViewHelpers::ActiveAdminApplicationHelper
  include ActiveAdmin::ViewHelpers::AutoLinkHelper
  include ActiveAdmin::ViewHelpers::DisplayHelper

  let(:active_admin_config) { AutoLinkMockResource.new(namespace) }
  let(:namespace){ ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin) }
  let(:post){ Post.create! :title => "Hello World" }

  def admin_post_path(post)
    "/admin/posts/#{post.id}"
  end

  context "when the resource is not registered" do
    it "should return the display name of the object" do
      auto_link(post).should == "Hello World"
    end
  end

  context "when the resource is registered" do
    before do
      namespace.register Post
    end
    it "should return a link with the display name of the object" do
      self.should_receive(:link_to).with("Hello World", admin_post_path(post))
      auto_link(post)
    end
  end

end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
andrewroth_activeadmin-0.3.4 spec/unit/auto_link_spec.rb
activeadmin-0.3.4 spec/unit/auto_link_spec.rb
activeadmin-0.3.3 spec/unit/auto_link_spec.rb
activeadmin-0.3.2 spec/unit/auto_link_spec.rb
activeadmin-0.3.1 spec/unit/auto_link_spec.rb
activeadmin-0.3.0 spec/unit/auto_link_spec.rb
nsm-activeadmin-0.2.2 spec/unit/auto_link_spec.rb
saulolso-activeadmin-0.2.2.1 spec/unit/auto_link_spec.rb
saulolso-activeadmin-0.2.2 spec/unit/auto_link_spec.rb