Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
ae0d4092
Commit
ae0d4092
authored
Aug 04, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding specs for Tag API
parent
25e96169
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
2 deletions
+96
-2
tag_helpers.rb
lib/noah/helpers/tag_helpers.rb
+2
-2
noahapp_tag_spec.rb
spec/noahapp_tag_spec.rb
+94
-0
No files found.
lib/noah/helpers/tag_helpers.rb
View file @
ae0d4092
module
Noah
module
SinatraTagHelpers
#TODO DRY this sumbitch up
# TODO DRY this sumbitch up
# TODO add status in json response
def
tag
(
primitive
,
name
,
tags
)
case
primitive
...
...
@@ -38,7 +39,6 @@ module Noah
else
halt
404
end
obj
.
nil?
?
(
halt
404
)
:
(
obj
.
untag!
(
tags
))
obj
.
to_json
end
...
...
spec/noahapp_tag_spec.rb
0 → 100644
View file @
ae0d4092
require
File
.
expand_path
(
File
.
dirname
(
__FILE__
)
+
'/spec_helper'
)
describe
"Using the Tag API"
,
:reset_redis
=>
true
do
before
(
:each
)
do
Ohm
.
redis
.
flushdb
@multi_tags
=
{
"tags"
=>
[
"production"
,
"databases"
,
"in-service"
]}
@single_tag
=
{
"tags"
=>
"out-of-service"
}
@host
=
Noah
::
Host
.
create
(
:name
=>
'tagged_host'
,
:status
=>
'up'
)
@service
=
Noah
::
Service
.
create
(
:name
=>
'tagged_service'
,
:status
=>
'down'
,
:host_id
=>
@host
.
id
)
@application
=
Noah
::
Application
.
create
(
:name
=>
'tagged_application'
)
@configuration
=
Noah
::
Configuration
.
create
(
:name
=>
'tagged_configuration'
,
:format
=>
'string'
,
:body
=>
'some_string'
)
@ephemeral
=
Noah
::
Ephemeral
.
create
(
:path
=>
'/tagged/ephemeral'
)
end
after
(
:each
)
do
Ohm
.
redis
.
flushdb
end
describe
"calling"
do
describe
"PUT"
do
[
'host'
,
'service'
,
'application'
,
'configuration'
,
'ephemeral'
].
each
do
|
primitive
|
it
"multiple tags to
#{
primitive
}
should work"
do
obj
=
instance_variable_get
(
"@
#{
primitive
}
"
)
case
primitive
when
"ephemeral"
put
"/
#{
primitive
}
s
#{
obj
.
path
}
/tag"
,
@multi_tags
.
to_json
when
"service"
put
"/
#{
primitive
}
s/
#{
obj
.
name
}
/
#{
@host
.
name
}
/tag"
,
@multi_tags
.
to_json
else
put
"/
#{
primitive
}
s/
#{
obj
.
name
}
/tag"
,
@multi_tags
.
to_json
end
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
'tags'
].
sort
.
should
==
@multi_tags
[
"tags"
].
sort
end
end
[
'host'
,
'service'
,
'application'
,
'configuration'
,
'ephemeral'
].
each
do
|
primitive
|
it
"single tag to
#{
primitive
}
should work"
do
obj
=
instance_variable_get
(
"@
#{
primitive
}
"
)
case
primitive
when
"ephemeral"
put
"/
#{
primitive
}
s
#{
obj
.
path
}
/tag"
,
@single_tag
.
to_json
when
"service"
put
"/
#{
primitive
}
s/
#{
obj
.
name
}
/
#{
@host
.
name
}
/tag"
,
@single_tag
.
to_json
else
put
"/
#{
primitive
}
s/
#{
obj
.
name
}
/tag"
,
@single_tag
.
to_json
end
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
'tags'
].
should
==
[
@single_tag
[
"tags"
]]
end
end
end
describe
"DELETE"
do
[
'host'
,
'service'
,
'application'
,
'configuration'
,
'ephemeral'
].
each
do
|
primitive
|
it
"multiple tags from
#{
primitive
}
should work"
do
obj
=
instance_variable_get
(
"@
#{
primitive
}
"
)
case
primitive
when
"ephemeral"
delete
"/
#{
primitive
}
s
#{
obj
.
path
}
/tag"
,
@multi_tags
.
to_json
when
"service"
delete
"/
#{
primitive
}
s/
#{
obj
.
name
}
/
#{
@host
.
name
}
/tag"
,
@multi_tags
.
to_json
else
delete
"/
#{
primitive
}
s/
#{
obj
.
name
}
/tag"
,
@multi_tags
.
to_json
end
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
'tags'
].
sort
.
should_not
==
@multi_tags
[
"tags"
].
sort
response
[
'tags'
].
size
.
should
==
0
end
end
[
'host'
,
'service'
,
'application'
,
'configuration'
,
'ephemeral'
].
each
do
|
primitive
|
it
"single tag from
#{
primitive
}
should work"
do
obj
=
instance_variable_get
(
"@
#{
primitive
}
"
)
case
primitive
when
"ephemeral"
delete
"/
#{
primitive
}
s
#{
obj
.
path
}
/tag"
,
@single_tag
.
to_json
when
"service"
delete
"/
#{
primitive
}
s/
#{
obj
.
name
}
/
#{
@host
.
name
}
/tag"
,
@single_tag
.
to_json
else
delete
"/
#{
primitive
}
s/
#{
obj
.
name
}
/tag"
,
@single_tag
.
to_json
end
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
'tags'
].
should_not
==
[
@single_tag
[
"tags"
]]
response
[
'tags'
].
size
.
should
==
0
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment