Commit 1a001230 authored by John E. Vincent's avatar John E. Vincent

finishing tag ruby api specs

parent e08e9597
...@@ -8,7 +8,7 @@ describe "Using the Tag Model", :reset_redis => true do ...@@ -8,7 +8,7 @@ describe "Using the Tag Model", :reset_redis => true do
@host = Noah::Host.create(:name => 'tagged_host', :status => 'up') @host = Noah::Host.create(:name => 'tagged_host', :status => 'up')
@service = Noah::Service.create(:name => 'tagged_service', :status => 'down', :host_id => @host.id) @service = Noah::Service.create(:name => 'tagged_service', :status => 'down', :host_id => @host.id)
@application = Noah::Application.create(:name => 'tagged_application') @application = Noah::Application.create(:name => 'tagged_application')
@configuration = Noah::Configuration.create(:name => 'tagged_configuration') @configuration = Noah::Configuration.create(:name => 'tagged_configuration', :format => 'string', :body => 'some_string')
@ephemeral = Noah::Ephemeral.create(:path => '/tagged/ephemeral') @ephemeral = Noah::Ephemeral.create(:path => '/tagged/ephemeral')
end end
after(:each) do after(:each) do
...@@ -47,15 +47,30 @@ describe "Using the Tag Model", :reset_redis => true do ...@@ -47,15 +47,30 @@ describe "Using the Tag Model", :reset_redis => true do
end end
Noah::Tag.all.size.should == 3 Noah::Tag.all.size.should == 3
end end
it "find all objects tagged" it "tag all object types and find via tagged" do
it "support tagging all object types" [@host, @service, @application, @configuration, @ephemeral].each do |o|
o.tag! @tags1
end
@tags1.each do |tag|
Noah::Tag.tagged(tag).size.should == 5
[@host, @service, @application, @configuration, @ephemeral].each do |o|
Noah::Tag.tagged(tag).values.flatten.member?(o.name).should == true
end
end
end
end end
describe "should not" do describe "should not" do
it "should not create a new Noah::Tag without a name" do it "create a new Noah::Tag without a name" do
a = Noah::Tag.create a = Noah::Tag.create
a.valid?.should == false a.valid?.should == false
a.errors.should == [[:name, :not_present]] a.errors.should == [[:name, :not_present]]
end end
it "create a tag with a duplicate name" do
a = Noah::Tag.create(:name => 'tag1')
b = Noah::Tag.create(:name => 'tag1')
b.valid?.should == false
b.errors.should == [[:name, :not_unique]]
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment