diff --git a/lib/pact_broker/api.rb b/lib/pact_broker/api.rb index 7ae5dc13d..68e8939ca 100644 --- a/lib/pact_broker/api.rb +++ b/lib/pact_broker/api.rb @@ -67,6 +67,7 @@ module PactBroker add ['matrix'], Api::Resources::Matrix, {resource_name: "matrix"} add ['dashboard'], Api::Resources::Dashboard, {resource_name: "dashboard"} + add ['test','error'], Api::Resources::ErrorTest, {resource_name: "error_test"} add [], Api::Resources::Index, {resource_name: "index"} end end diff --git a/lib/pact_broker/api/resources/error_test.rb b/lib/pact_broker/api/resources/error_test.rb new file mode 100644 index 000000000..07680db9e --- /dev/null +++ b/lib/pact_broker/api/resources/error_test.rb @@ -0,0 +1,36 @@ +require 'pact_broker/api/resources/base_resource' +require 'pact_broker/error' + +module PactBroker + module Api + module Resources + + class ErrorTest < BaseResource + + def content_types_provided + [ + ["application/hal+json", :to_json] + ] + end + + def content_types_accepted + [ + ["application/hal+json", :from_json] + ] + end + + def allowed_methods + ["GET", "POST"] + end + + def to_json + raise PactBroker::Error.new("Don't panic. This is a test API error.") + end + + def from_json + raise PactBroker::Error.new("Don't panic. This is a test API error.") + end + end + end + end +end diff --git a/lib/pact_broker/ui/app.rb b/lib/pact_broker/ui/app.rb index e5bb71123..966fd143f 100644 --- a/lib/pact_broker/ui/app.rb +++ b/lib/pact_broker/ui/app.rb @@ -1,9 +1,9 @@ require 'pact_broker/ui/controllers/index' require 'pact_broker/ui/controllers/groups' require 'pact_broker/ui/controllers/matrix' +require 'pact_broker/ui/controllers/error_test' require 'pact_broker/doc/controllers/app' - module PactBroker module UI class PathInfoFixer @@ -41,6 +41,11 @@ def initialize run PactBroker::UI::Controllers::Matrix end + map "/test/error" do + use PathInfoFixer + run PactBroker::UI::Controllers::ErrorTest + end + map "/" do run PactBroker::UI::Controllers::Index end diff --git a/lib/pact_broker/ui/controllers/error_test.rb b/lib/pact_broker/ui/controllers/error_test.rb new file mode 100644 index 000000000..a330175e8 --- /dev/null +++ b/lib/pact_broker/ui/controllers/error_test.rb @@ -0,0 +1,18 @@ +require 'pact_broker/ui/controllers/base_controller' +require 'pact_broker/logging' +require 'pact_broker/error' + +module PactBroker + module UI + module Controllers + class ErrorTest < Base + include PactBroker::Services + include PactBroker::Logging + + get "/" do + raise PactBroker::Error.new("Don't panic. This is a test UI error.") + end + end + end + end +end