Skip to content

Commit

Permalink
Merge pull request #416 from airbrake/415-fix-build
Browse files Browse the repository at this point in the history
Revert "start using remote XSD file when verifying XML in tests"
  • Loading branch information
shifi committed Sep 10, 2015
2 parents 6ccceb3 + df64082 commit 02d29cc
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 4 deletions.
89 changes: 89 additions & 0 deletions resources/airbrake_2_4.xsd
@@ -0,0 +1,89 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="notice">
<xs:complexType>
<xs:all>
<xs:element name="api-key" type="xs:string"/>
<xs:element name="notifier" type="notifier"/>
<xs:element name="error" type="error"/>
<xs:element name="request" type="request" minOccurs="0"/>
<xs:element name="server-environment" type="serverEnvironment"/>
<xs:element name="current-user" type="current-user" minOccurs="0"/>
<xs:element name="framework" type="xs:string" minOccurs="0"/>
</xs:all>
<xs:attribute name="version" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>

<xs:complexType name="notifier">
<xs:all>
<xs:element name="name" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
<xs:element name="url" type="xs:string"/>
</xs:all>
</xs:complexType>

<xs:complexType name="error">
<xs:all>
<xs:element name="class" type="xs:string"/>
<xs:element name="message" type="xs:string" minOccurs="0"/>
<xs:element name="backtrace" type="backtrace"/>
</xs:all>
</xs:complexType>

<xs:complexType name="backtrace">
<xs:sequence>
<xs:element name="line" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute name="file" type="xs:string" use="required"/>
<xs:attribute name="number" type="xs:string" use="required"/>
<xs:attribute name="method" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="request">
<xs:all>
<xs:element name="url" type="xs:string"/>
<xs:element name="component" type="xs:string"/>
<xs:element name="action" type="xs:string" minOccurs="0"/>
<xs:element name="params" type="varList" minOccurs="0"/>
<xs:element name="session" type="varList" minOccurs="0"/>
<xs:element name="cgi-data" type="varList" minOccurs="0"/>
</xs:all>
</xs:complexType>

<xs:complexType name="varList">
<xs:sequence>
<xs:element name="var" type="var" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="var" mixed="true">
<xs:sequence>
<xs:element name="var" type="var" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="key" type="xs:string" use="required"/>
</xs:complexType>

<xs:complexType name="serverEnvironment">
<xs:sequence>
<xs:element name="project-root" type="xs:string" minOccurs="0"/>
<xs:element name="environment-name" type="xs:string"/>
<xs:element name="app-version" type="xs:string" minOccurs="0"/>
<xs:element name="hostname" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="current-user">
<xs:all>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element name="email" type="xs:string" minOccurs="0"/>
<xs:element name="username" type="xs:string" minOccurs="0"/>
</xs:all>
</xs:complexType>

</xs:schema>
7 changes: 3 additions & 4 deletions test/notice_test.rb
@@ -1,6 +1,5 @@
require File.expand_path '../helper', __FILE__


class NoticeTest < Test::Unit::TestCase

include DefinesConstants
Expand Down Expand Up @@ -43,8 +42,8 @@ def assert_accepts_exception_attribute(attribute, args = {}, &block)
end

def assert_valid_notice_document(document)
xsd_path = URI(XSD_SCHEMA_PATH)
schema = Nokogiri::XML::Schema.new(Net::HTTP.get(xsd_path))
xsd_path = File.expand_path(File.join(File.dirname(__FILE__),"..", "resources", "airbrake_2_4.xsd"))
schema = Nokogiri::XML::Schema.new(IO.read(xsd_path))
errors = schema.validate(document)
assert errors.empty?, errors.collect{|e| e.message }.join
end
Expand Down Expand Up @@ -189,7 +188,7 @@ def user
build_notice
end
end

should "accept any object that responds to :to_hash as CGI data" do
hashlike_obj = Object.new
hashlike_obj.instance_eval do
Expand Down

0 comments on commit 02d29cc

Please sign in to comment.