Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix test cases to match new error handling

  • Loading branch information...
commit bdc0dd5b7b475f9faaea814da843308bb4e7548f 1 parent 7cf267d
Christian Holm authored
Showing with 18 additions and 27 deletions.
  1. +18 −27 test/active_podio_test.rb
View
45 test/active_podio_test.rb
@@ -30,17 +30,6 @@ class TestModel < ActivePodio::Base
delegate_to_hash :prefixed_hash_property, :key3, :prefix => true
delegate_to_hash :hash_property_with_setter, :key4, :setter => true
delegate_to_hash :prefixed_hash_property_with_setter, :key5, :setter => true, :prefix => true
-
-
- def save(exception_class = nil)
- if exception_class
- raise exception_class.new({
- 'error' => 'test status',
- 'error_description' => 'test desc',
- 'error_parameters' => 'test parms'
- }, 500, 'http://api.podio.dev')
- end
- end
end
class TestInheritedModel < TestModel
@@ -218,22 +207,24 @@ class TestInheritedModel < TestModel
@test.key4 = 'new'
assert_equal 'new', @test.key4
end
-
- test 'should handle non failing api requests' do
- @test = TestModel.new
- assert @test.save
- end
-
- [Podio::BadRequestError, Podio::AuthorizationError].each do |exception_class|
- test "should handle failing api requests with #{exception_class.name} exception" do
- @test = TestModel.new
- assert_equal false, @test.save(exception_class)
- assert_equal 'test status', @test.error_code
- assert_equal 'test desc', @test.error_message
- assert_equal 'test parms', @test.error_parameters
- end
- end
-
+
+ test 'should instantiate exception properly' do
+ exc = Podio::BadRequestError.new(
+ {
+ "error" => "forbidden",
+ "error_detail" => nil,
+ "error_description" => "Only available for clients with a trust level of 4 or higher. To get your API client upgraded to a higher trust level contact support at support@podio.com.",
+ "error_parameters" => {"foo" => "bar"},
+ "error_propagate" => false
+ }, 400, "https://api.podio.com/foo/bar")
+
+ assert_equal exc.code, "forbidden"
+ assert_equal exc.sub_code, nil
+ assert_equal exc.message, "Only available for clients with a trust level of 4 or higher. To get your API client upgraded to a higher trust level contact support at support@podio.com."
+ assert_equal exc.propagate, false
+ assert_equal exc.parameters["foo"], "bar"
+ end
+
test 'should return instance from member' do
assert TestModel.member(:string => 'string').instance_of?(TestModel)
end
Please sign in to comment.
Something went wrong with that request. Please try again.