Skip to content

Instantly share code, notes, and snippets.

@eedrummer
Created November 24, 2009 04:00
Show Gist options
  • Save eedrummer/241617 to your computer and use it in GitHub Desktop.
Save eedrummer/241617 to your computer and use it in GitHub Desktop.
context "when receiving a POST" do
should "not allow an incomplete request" do
post '/', {:type => 'extension'}
assert_equal 400, last_response.status
end
should "allow the registration of a new extension" do
post '/', {:type => 'extension',
:typeId =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy',
:requirement => 'mandatory'}
assert_equal 201, last_response.status
extension = Extension.first(
:type_id =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy')
assert extension
assert_equal 'mandatory', extension.requirement
end
should "not allow the registration of a duplicate extension" do
Extension.new(
:type_id =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy',
:requirement => 'mandatory').save
post '/', {:type => 'extension',
:typeId =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy',
:requirement => 'mandatory'}
assert_equal 409, last_response.status
end
should "allow the creation of a new section" do
Extension.new(
:type_id =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy',
:requirement => 'mandatory').save
post '/', {:type => 'section',
:typeId =>
'http://projecthdata.org/hdata/schemas/2009/06/allergy',
:path => 'allergies',
:name => 'Allergies'}
assert_equal 201, last_response.status
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment