Sha256: d0ac06230918def1489d7ea375f58964cda8891807e11cc9d6887aa9ab2607d7

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe "Configuration" do
  it "should have an array of namespaces which allow comments" do
    ActiveAdmin.allow_comments_in.should be_an_instance_of(Array)
  end

  it "should allow comments in the default namespace by default" do
    ActiveAdmin.allow_comments_in.should include(ActiveAdmin.default_namespace)
  end
end

describe ActiveAdmin::Comment do
  describe "Associations and Validations" do
    it { should belong_to :resource }
    it { should belong_to :author }

    it { should validate_presence_of :resource_id }
    it { should validate_presence_of :resource_type }
    it { should validate_presence_of :body }
    it { should validate_presence_of :namespace }
  end
end

describe ActiveAdmin::Comments::NamespaceHelper do
  describe "#comments?" do
    it "should have comments if the namespace is in the settings" do
      ns = ActiveAdmin::Namespace.new(ActiveAdmin.default_namespace)
      ns.comments?.should be_true
    end
    it "should not have comments if the namespace is not in the settings" do
      ns = ActiveAdmin::Namespace.new(:not_in_comments)
      ns.comments?.should be_false
    end
  end
end

describe ActiveAdmin::Comments::ResourceHelper do
  it "should add an attr_accessor :comments to ActiveAdmin::Resource" do
    ns = ActiveAdmin::Namespace.new(:admin)
    resource = ActiveAdmin::Resource.new(ns, Post)
    resource.comments.should be_nil
    resource.comments = true
    resource.comments.should be_true
  end

  it "should not have comment if set to false by in allow_comments_in" do
    ns = ActiveAdmin::Namespace.new(ActiveAdmin.default_namespace)
    resource = ActiveAdmin::Resource.new(ns, Post)
    resource.comments = false
    resource.comments?.should be_false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeadmin-0.2.2 spec/unit/comments_spec.rb