Sha256: 07812e9598e5b4709fc0b47ac325d929d4ec6aa67100be905b553f3e8ecfef63

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'

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

  let(:active_admin_config)   { double namespace: namespace }
  let(:active_admin_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
      active_admin_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

5 entries across 5 versions & 1 rubygems

Version Path
yousty-activeadmin-1.0.4.pre spec/unit/auto_link_spec.rb
yousty-activeadmin-1.0.3.pre spec/unit/auto_link_spec.rb
yousty-activeadmin-1.0.2.pre spec/unit/auto_link_spec.rb
yousty-activeadmin-1.0.1.pre spec/unit/auto_link_spec.rb
yousty-activeadmin-1.0.0.pre spec/unit/auto_link_spec.rb