Skip to content

Commit

Permalink
fixing bugs in root.xml dates. adding schema validation tests for roo…
Browse files Browse the repository at this point in the history
…t.xml document, updating rails to 3.2.2
  • Loading branch information
rdingwell committed Mar 6, 2012
1 parent 25826ff commit dcc7c19
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'http://rubygems.org'


gem 'rails', '3.2.2.rc1'
gem 'rails', '3.2.2'
gem "health-data-standards", :git => "http://github.com/projectcypress/health-data-standards.git", :branch => "develop"
gem 'ruby-openid', :git => 'https://github.com/rdingwell/ruby-openid.git',:branch => "master"
gem "mongoid"
Expand Down
56 changes: 28 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ GIT
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.2.rc1)
actionpack (= 3.2.2.rc1)
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2.rc1)
activemodel (= 3.2.2.rc1)
activesupport (= 3.2.2.rc1)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2.rc1)
activesupport (= 3.2.2.rc1)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2.rc1)
activemodel (= 3.2.2.rc1)
activesupport (= 3.2.2.rc1)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2.rc1)
activemodel (= 3.2.2.rc1)
activesupport (= 3.2.2.rc1)
activesupport (3.2.2.rc1)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
Expand Down Expand Up @@ -137,7 +137,7 @@ GEM
nokogiri (>= 1.3.3)
macaddr (1.5.0)
systemu (>= 2.4.0)
mail (2.4.1)
mail (2.4.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand Down Expand Up @@ -174,7 +174,7 @@ GEM
pry-nav (0.1.0)
pry (~> 0.9.8.1)
rack (1.4.1)
rack-cache (1.1)
rack-cache (1.2)
rack (>= 0.4)
rack-oauth2 (0.11.0)
activesupport (>= 2.3)
Expand All @@ -190,17 +190,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2.rc1)
actionmailer (= 3.2.2.rc1)
actionpack (= 3.2.2.rc1)
activerecord (= 3.2.2.rc1)
activeresource (= 3.2.2.rc1)
activesupport (= 3.2.2.rc1)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2.rc1)
railties (3.2.2.rc1)
actionpack (= 3.2.2.rc1)
activesupport (= 3.2.2.rc1)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
Expand Down Expand Up @@ -238,7 +238,7 @@ GEM
polyglot (>= 0.3.1)
turn (0.9.3)
ansi
tzinfo (0.3.31)
tzinfo (0.3.32)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
Expand Down Expand Up @@ -271,7 +271,7 @@ DEPENDENCIES
omniauth-openid
pry
pry-nav
rails (= 3.2.2.rc1)
rails (= 3.2.2)
ruby-openid!
sass-rails (~> 3.2.3)
therubyracer
Expand Down
1 change: 1 addition & 0 deletions app/controllers/authentications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def index


def create

omniauth = request.env["omniauth.auth"]
authentication = Authentication.first(conditions: { provider: omniauth['provider'], uid: omniauth['uid']})
#binding.pry
Expand Down
4 changes: 2 additions & 2 deletions app/views/records/root.xml.builder
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
xml.root xmlns: "http://projecthdata.org/hdata/schemas/2009/06/core", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance" do
xml.id @record.medical_record_number
xml.version @record.version
xml.created @record.created_at
xml.lastModified @record.updated_at
xml.created @record.created_at.to_s(:xsd)
xml.lastModified @record.updated_at.to_s(:xsd)

extensions = SectionRegistry.instance.extensions
ids = extensions.collect{|x| x.extension_id }.uniq
Expand Down
1 change: 1 addition & 0 deletions config/initializers/date_formats.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Time::DATE_FORMATS[:xsd] = "%Y-%m-%d"
8 changes: 7 additions & 1 deletion test/functional/records_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class RecordsControllerTest < ActionController::TestCase
include Devise::TestHelpers

ROOT_SCHEMA = File.expand_path("../../xsd/root.xsd",__FILE__)
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
Expand Down Expand Up @@ -35,6 +35,12 @@ def setup
assert_response :success

doc = Nokogiri::XML::Document.parse(response.body)



xsd = Nokogiri::XML::Schema(open(ROOT_SCHEMA))
assert_equal [], xsd.validate(doc)

doc.root.add_namespace_definition('hrf', 'http://projecthdata.org/hdata/schemas/2009/06/core')


Expand Down
74 changes: 74 additions & 0 deletions test/xsd/root.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2009 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://projecthdata.org/hdata/schemas/2009/06/core" xmlns:core="http://projecthdata.org/hdata/schemas/2009/06/core">
<xs:element name="root">
<xs:complexType>
<xs:all>
<xs:element ref="core:id"/>
<xs:element ref="core:version"/>
<xs:element ref="core:created"/>
<xs:element ref="core:lastModified"/>
<xs:element ref="core:extensions"/>
<xs:element ref="core:sections"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="id" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
<xs:element name="created" type="xs:date"/>
<xs:element name="lastModified" type="xs:date"/>
<xs:element name="extensions">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="core:extension"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="extension">
<xs:complexType mixed="true">
<xs:attributeGroup ref="core:extension"/>
</xs:complexType>
</xs:element>
<xs:element name="sections">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="core:section"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="extension">
<xs:attribute name="contentType" type="xs:string" use="optional"/>
<xs:attribute name="extensionId" type="xs:string" use="required"/>
</xs:attributeGroup>
<xs:element name="section">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="core:section"/>
</xs:sequence>
<xs:attribute name="path" use="required"/>
<xs:attribute name="name" use="optional"/>
<xs:attribute name="extensionId" use="required"/>
<xs:attribute name="requirement" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="mandatory"/>
<xs:enumeration value="optional"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

0 comments on commit dcc7c19

Please sign in to comment.