-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from basecrm/error_without_content_type
Error without content type
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.3.1 | ||
1.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module BaseCRM | ||
VERSION = "1.3.1" | ||
VERSION = "1.3.2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "spec_helper" | ||
|
||
describe BaseCRM::Middlewares::RaiseError do | ||
before { @raise_error = BaseCRM::Middlewares::RaiseError.new } | ||
|
||
describe :on_complete do | ||
|
||
it "returns nil when code 200..300" do | ||
expect { @raise_error.on_complete({:status => 204}) }.not_to raise_error | ||
end | ||
|
||
it "raises ResourceError when code 422 and no content type" do | ||
expect { @raise_error.on_complete({:status => 422, :response_headers => {}}) } | ||
.to raise_error do |error| | ||
expect(error).to be_a(BaseCRM::ResourceError) | ||
expect(error.code).to eql(422) | ||
expect(error.message).to eql("Unknown error occurred.") | ||
end | ||
end | ||
|
||
it "raises RequestError when code 400..500 and no content type" do | ||
expect { @raise_error.on_complete({:status => 400, :response_headers => {}}) } | ||
.to raise_error do |error| | ||
expect(error).to be_a(BaseCRM::RequestError) | ||
expect(error.code).to eql(400) | ||
expect(error.message).to eql("Unknown error occurred.") | ||
end | ||
end | ||
|
||
it "raises ServerError when code 500..600 and no content type" do | ||
expect { @raise_error.on_complete({:status => 500, :response_headers => {}}) } | ||
.to raise_error do |error| | ||
expect(error).to be_a(BaseCRM::ServerError) | ||
expect(error.code).to eql(500) | ||
expect(error.message).to eql("Unknown error occurred.") | ||
end | ||
end | ||
|
||
it "raises ResourceError when code 422 and XML (not supported) content type" do | ||
expect { @raise_error.on_complete({:status => 422, :response_headers => {'content-type' => "application/xml"}}) } | ||
.to raise_error do |error| | ||
expect(error).to be_a(BaseCRM::ResourceError) | ||
expect(error.code).to eql(422) | ||
expect(error.message).to eql("Unknown error occurred.") | ||
end | ||
end | ||
end | ||
end |