Navigation Menu

Skip to content

Commit

Permalink
missing ?
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Dec 13, 2009
1 parent 22f5532 commit a1ff5b5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/restfulie/media_type.rb
Expand Up @@ -55,7 +55,7 @@ def self.media_type(name)
media_types[name]
end

def self.supports(name)
def self.supports?(name)
name = normalize(name)
!media_types[name].nil?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/restfulie/server/restfulie_controller.rb
Expand Up @@ -5,7 +5,7 @@ module Controller
def create

type = self.class.name[/(.*)Controller/,1].singularize.constantize
return head 415 if Restfulie::MediaType.not_supported?(request.headers['CONTENT_TYPE'])
return head 415 unless Restfulie::MediaType.supports?(request.headers['CONTENT_TYPE'])
return head 415 unless Restfulie::MediaType.media_type(request.headers['CONTENT_TYPE']) == type

@model = Restfulie.from request
Expand Down
4 changes: 2 additions & 2 deletions spec/media_type_spec.rb
Expand Up @@ -29,8 +29,8 @@ class Country
extend Restfulie::MediaTypeControl
media_type 'vnd/country+xml'
end
Restfulie::MediaType.supports('vnd/country+xml').should be_true
Restfulie::MediaType.supports('vnd/caelum_unknown_city+xml').should be_false
Restfulie::MediaType.supports?('vnd/country+xml').should be_true
Restfulie::MediaType.supports?('vnd/caelum_unknown_city+xml').should be_false
lambda {Restfulie::MediaType.media_type('vnd/caelum_unknown_city+xml')}.should raise_error(Restfulie::UnsupportedContentType)
end

Expand Down

0 comments on commit a1ff5b5

Please sign in to comment.