schematic 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -96,6 +96,12 @@ module Schematic
96
96
  "type" => nested_attribute.klass.schematic_sandbox.xsd_generator.names.type,
97
97
  "minOccurs" => "0",
98
98
  "maxOccurs" => "1"
99
+ when :belongs_to
100
+ all.xs :element,
101
+ "name" => nested_attribute_name(nested_attribute.name, {:pluralized => false}),
102
+ "type" => nested_attribute.klass.schematic_sandbox.xsd_generator.names.type,
103
+ "minOccurs" => "0",
104
+ "maxOccurs" => "1"
99
105
  end
100
106
  end
101
107
 
@@ -1,3 +1,3 @@
1
1
  module Schematic
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
data/schematic.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency('activerecord', '>= 3.0.0')
18
18
  s.add_dependency('builder')
19
19
  s.add_development_dependency('rspec-rails', '>= 2.1')
20
- s.add_development_dependency('with_model')
20
+ s.add_development_dependency('with_model', '>= 0.2.4')
21
21
  s.add_development_dependency('nokogiri')
22
22
  s.add_development_dependency('sqlite3')
23
23
  s.add_development_dependency('autotest')
@@ -397,6 +397,54 @@ describe Schematic::Serializers::Xsd do
397
397
  end
398
398
  end
399
399
 
400
+ context "when the model has a belongs_to nested attribute with an alternate class name" do
401
+ with_model :school do
402
+ table do |t|
403
+ t.string :name
404
+ end
405
+ end
406
+
407
+ with_model :student do
408
+ table do |t|
409
+ t.string :university_id
410
+ end
411
+
412
+ model do
413
+ belongs_to :university, class_name: "School"
414
+
415
+ accepts_nested_attributes_for :university
416
+ end
417
+ end
418
+
419
+ describe "the parent XSD" do
420
+ subject { School.to_xsd }
421
+ it "should be valid" do
422
+ validate_xsd(subject)
423
+ end
424
+ end
425
+
426
+ describe "the child XSD" do
427
+ subject { Student.to_xsd }
428
+ it "should be valid" do
429
+ validate_xsd(subject)
430
+ end
431
+
432
+ it "should validate XML" do
433
+ xml = <<-XML
434
+ <?xml version="1.0" encoding="UTF-8"?>
435
+ <students type="array">
436
+ <student>
437
+ <university-attributes>
438
+ <name>Harvard</name>
439
+ </university>
440
+ </student>
441
+ </students>
442
+ XML
443
+ validate_xml_against_xsd(xml, subject)
444
+ end
445
+ end
446
+ end
447
+
400
448
  context "when the model has a polymorphic nested attribute and ignores a required method of the nested attribute" do
401
449
  with_model :person do
402
450
  model do
metadata CHANGED
@@ -1,104 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: schematic
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.8
4
5
  prerelease:
5
- version: 0.5.7
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Case Commons, LLC
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-10-14 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activerecord
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2152968460 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
22
21
  version: 3.0.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2152968460
25
+ - !ruby/object:Gem::Dependency
27
26
  name: builder
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2152967400 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2152967400
36
+ - !ruby/object:Gem::Dependency
38
37
  name: rspec-rails
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2152965580 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "2.1"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '2.1'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2152965580
47
+ - !ruby/object:Gem::Dependency
49
48
  name: with_model
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2152964860 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.4
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2152964860
58
+ - !ruby/object:Gem::Dependency
60
59
  name: nokogiri
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2152964260 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2152964260
69
+ - !ruby/object:Gem::Dependency
71
70
  name: sqlite3
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &2152963260 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *2152963260
80
+ - !ruby/object:Gem::Dependency
82
81
  name: autotest
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &2152962680 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
90
+ version_requirements: *2152962680
92
91
  description: Automatic XSD generation from ActiveRecord models
93
- email:
92
+ email:
94
93
  - casecommons-dev@googlegroups.com
95
94
  executables: []
96
-
97
95
  extensions: []
98
-
99
96
  extra_rdoc_files: []
100
-
101
- files:
97
+ files:
102
98
  - .gitignore
103
99
  - .rspec
104
100
  - .rvmrc
@@ -145,38 +141,35 @@ files:
145
141
  - spec/xsd/xml.xsd
146
142
  homepage: https://github.com/Casecommons/schematic
147
143
  licenses: []
148
-
149
144
  post_install_message:
150
145
  rdoc_options: []
151
-
152
- require_paths:
146
+ require_paths:
153
147
  - lib
154
- required_ruby_version: !ruby/object:Gem::Requirement
148
+ required_ruby_version: !ruby/object:Gem::Requirement
155
149
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 697916379530530678
160
- segments:
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
161
155
  - 0
162
- version: "0"
163
- required_rubygems_version: !ruby/object:Gem::Requirement
156
+ hash: -2592805779284739061
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
158
  none: false
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- hash: 697916379530530678
169
- segments:
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ segments:
170
164
  - 0
171
- version: "0"
165
+ hash: -2592805779284739061
172
166
  requirements: []
173
-
174
167
  rubyforge_project: schematic
175
- rubygems_version: 1.8.8
168
+ rubygems_version: 1.8.10
176
169
  signing_key:
177
170
  specification_version: 3
178
171
  summary: Automatic XSD generation from ActiveRecord models
179
- test_files:
172
+ test_files:
180
173
  - spec/schematic/generator/restrictions/custom_spec.rb
181
174
  - spec/schematic/generator/restrictions/enumeration_spec.rb
182
175
  - spec/schematic/generator/restrictions/length_spec.rb