schematic 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,11 @@ module Schematic
|
|
64
64
|
generate_column_elements(all, additional_methods, ignored_methods)
|
65
65
|
|
66
66
|
nested_attributes.each do |nested_attribute|
|
67
|
-
all.xs :element,
|
67
|
+
all.xs :element,
|
68
|
+
"name" => nested_attribute_name(nested_attribute.name),
|
69
|
+
"type" => nested_attribute.klass.xsd_generator.names.collection_type,
|
70
|
+
"minOccurs" => "0",
|
71
|
+
"maxOccurs" => "1"
|
68
72
|
end
|
69
73
|
|
70
74
|
generate_additional_methods(all, additional_methods)
|
@@ -128,6 +132,10 @@ module Schematic
|
|
128
132
|
{ "xmlns:#{ns}" => Namespaces::PROVIDERS[provider][key] }
|
129
133
|
end
|
130
134
|
|
135
|
+
def nested_attribute_name(name)
|
136
|
+
"#{name.to_s.pluralize}-attributes"
|
137
|
+
end
|
138
|
+
|
131
139
|
end
|
132
140
|
end
|
133
141
|
end
|
data/lib/schematic/version.rb
CHANGED
@@ -135,6 +135,34 @@ describe Schematic::Serializers::Xsd do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
context "when the model has a nested attribute on a subclass with a different class name than the association" do
|
139
|
+
with_model :parent do
|
140
|
+
table {}
|
141
|
+
model do
|
142
|
+
has_many :children, :class_name => "SpecialChild"
|
143
|
+
accepts_nested_attributes_for :children
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
with_model :special_child do
|
148
|
+
table do |t|
|
149
|
+
t.integer :parent_id
|
150
|
+
end
|
151
|
+
|
152
|
+
model do
|
153
|
+
belongs_to :parent
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
subject { Parent.to_xsd }
|
158
|
+
|
159
|
+
it "should generate a valid XSD" do
|
160
|
+
subject.should include "children-attributes"
|
161
|
+
subject.should_not include "special-children-attributes"
|
162
|
+
validate_xsd(subject)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
138
166
|
context "when the model has a circular nested attribute reference" do
|
139
167
|
with_model :plate do
|
140
168
|
table {}
|
@@ -343,4 +371,14 @@ describe Schematic::Serializers::Xsd do
|
|
343
371
|
|
344
372
|
end
|
345
373
|
|
374
|
+
describe "#nested_attribute_name" do
|
375
|
+
let(:xsd) {Schematic::Generator::Xsd.new(Object)}
|
376
|
+
it "turns 'child' into 'children-attributes'" do
|
377
|
+
xsd.nested_attribute_name('child').should == "children-attributes"
|
378
|
+
end
|
379
|
+
|
380
|
+
it "turns 'children' into 'children-attributes'" do
|
381
|
+
xsd.nested_attribute_name('children').should == "children-attributes"
|
382
|
+
end
|
383
|
+
end
|
346
384
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: schematic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Case Commons, LLC
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-08 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|