Skip to content

Commit

Permalink
Add tests for content_type accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
emancu committed Nov 9, 2013
1 parent 152cd07 commit e15c73a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/model/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class Event
assert event.respond_to? :location=
end

test 'model content type by default' do
assert_equal 'application/json', Event.content_type
end

test 'model can change content type' do
Event.content_type 'text/plain'
assert_equal 'text/plain', Event.content_type
Event.content_type 'application/json' # Restore content_type
end

test 'model can change bucket name' do
Event.bucket_name= 'other_bucket_for_event'
assert_equal 'other_bucket_for_event', Event.bucket_name
Expand Down Expand Up @@ -135,6 +145,14 @@ class Event
assert event.send(:__persist_attributes).has_key? '_type'
assert_equal 'Event', event.send(:__persist_attributes)['_type']
end

test 'persist the object with different content-type' do
Event.content_type 'text/plain'
event = Event.create(name: 'Ruby')

assert_equal 'text/plain', event.send(:__robject).content_type
Event.content_type 'application/json'
end
end
end

Expand Down

0 comments on commit e15c73a

Please sign in to comment.