spec/unit/comments_spec.rb in activeadmin-0.6.0 vs spec/unit/comments_spec.rb in activeadmin-0.6.1

- old
+ new

@@ -2,20 +2,15 @@ describe "Comments" do let(:application){ ActiveAdmin::Application.new } describe ActiveAdmin::Comment do - subject { ActiveAdmin::Comment } + subject { ActiveAdmin::Comment.new } describe "Associations and Validations" do - before do - pending "This is not passing on Travis-CI. See Issue #1273." - end - it { should belong_to :resource } it { should belong_to :author } - it { should validate_presence_of :resource } it { should validate_presence_of :body } it { should validate_presence_of :namespace } end @@ -40,15 +35,15 @@ it "should not return a comment for a different resource" do another_post = Post.create! :title => "Another Hello World" ActiveAdmin::Comment.find_for_resource_in_namespace(another_post, namespace_name).should == [] end end - + describe ".resource_id_cast" do let(:post) { Post.create!(:title => "Testing.") } let(:namespace_name) { "admin" } - + it "should cast resource_id as string" do comment = ActiveAdmin::Comment.create! :resource => post, :body => "Another Comment", :namespace => namespace_name ActiveAdmin::Comment.resource_id_cast(comment).class.should eql String @@ -58,20 +53,20 @@ describe ".resource_id_type" do it "should be :string" do ActiveAdmin::Comment.resource_id_type.should eql :string end end - + describe "Commenting on resource with string id" do let(:tag){ Tag.create!(:name => "cooltags") } let(:namespace_name){ "admin" } - + it "should allow commenting" do - comment = ActiveAdmin::Comment.create! :resource => tag, - :body => "Another Comment", + comment = ActiveAdmin::Comment.create! :resource => tag, + :body => "Another Comment", :namespace => namespace_name - + ActiveAdmin::Comment.find_for_resource_in_namespace(tag, namespace_name).should == [comment] end end end @@ -88,22 +83,10 @@ ns = ActiveAdmin::Namespace.new(application, :admin) ns.allow_comments = false ns.comments?.should be_false end - it "should have comments when the application allows comments and no local namespace config" do - application.allow_comments = true - ns = ActiveAdmin::Namespace.new(application, :admin) - ns.comments?.should be_true - end - - it "should not have comments when the application does not allow commands and no local namespace config" do - application.allow_comments = false - ns = ActiveAdmin::Namespace.new(application, :admin) - ns.comments?.should be_false - end - end end describe ActiveAdmin::Comments::ResourceHelper do it "should add an attr_accessor :comments to ActiveAdmin::Resource" do @@ -111,12 +94,11 @@ 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) + it "should disable comments if set to false" do + ns = ActiveAdmin::Namespace.new(application, :admin) resource = ActiveAdmin::Resource.new(ns, Post) resource.comments = false resource.comments?.should be_false end end