Sha256: cbab5bb3c3750784df1ead166fb679eca07af912a06e42222e753942ea632c4b

Contents?: true

Size: 1.91 KB

Versions: 9

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe "Comments" do
  let(:application){ ActiveAdmin::Application.new }

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

    it "should allow comments in the default namespace by default" do
      application.allow_comments_in.should include(application.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(application, :admin)
        ns.comments?.should be_true
      end
      it "should not have comments if the namespace is not in the settings" do
        ns = ActiveAdmin::Namespace.new(application, :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(application, :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(application, application.default_namespace)
      resource = ActiveAdmin::Resource.new(ns, Post)
      resource.comments = false
      resource.comments?.should be_false
    end
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

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