brainstem 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +147 -0
- data/Gemfile.lock +68 -39
- data/lib/brainstem/api_docs.rb +9 -4
- data/lib/brainstem/api_docs/atlas.rb +3 -3
- data/lib/brainstem/api_docs/controller.rb +12 -4
- data/lib/brainstem/api_docs/controller_collection.rb +11 -2
- data/lib/brainstem/api_docs/endpoint.rb +17 -7
- data/lib/brainstem/api_docs/endpoint_collection.rb +9 -1
- data/lib/brainstem/api_docs/formatters/open_api_specification/helper.rb +19 -16
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter.rb +52 -80
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb +64 -84
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb +1 -1
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/endpoint_param_formatter.rb +39 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/presenter_field_formatter.rb +147 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/response_field_formatter.rb +146 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter.rb +53 -55
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb +1 -1
- data/lib/brainstem/api_docs/presenter.rb +16 -8
- data/lib/brainstem/api_docs/presenter_collection.rb +8 -5
- data/lib/brainstem/api_docs/sinks/open_api_specification_sink.rb +3 -1
- data/lib/brainstem/cli/generate_api_docs_command.rb +4 -0
- data/lib/brainstem/concerns/controller_dsl.rb +90 -20
- data/lib/brainstem/concerns/presenter_dsl.rb +16 -8
- data/lib/brainstem/dsl/association.rb +12 -0
- data/lib/brainstem/dsl/fields_block.rb +1 -1
- data/lib/brainstem/version.rb +1 -1
- data/spec/brainstem/api_docs/controller_spec.rb +127 -5
- data/spec/brainstem/api_docs/endpoint_spec.rb +489 -57
- data/spec/brainstem/api_docs/formatters/open_api_specification/helper_spec.rb +15 -4
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter_spec.rb +112 -66
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb +404 -32
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/endpoint_param_formatter_spec.rb +335 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/presenter_field_formatter_spec.rb +237 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/response_field_formatter_spec.rb +413 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb +116 -4
- data/spec/brainstem/api_docs/presenter_spec.rb +406 -24
- data/spec/brainstem/cli/generate_api_docs_command_spec.rb +8 -0
- data/spec/brainstem/concerns/controller_dsl_spec.rb +606 -45
- data/spec/brainstem/concerns/presenter_dsl_spec.rb +34 -2
- data/spec/brainstem/dsl/association_spec.rb +54 -3
- metadata +11 -2
@@ -125,12 +125,26 @@ describe Brainstem::Concerns::PresenterDSL do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
describe 'the nodoc! method' do
|
128
|
-
|
128
|
+
it "is stored in the configuration" do
|
129
|
+
presenter_class.nodoc! "Description for why these are nodoc"
|
130
|
+
expect(presenter_class.configuration[:nodoc]).to eq "Description for why these are nodoc"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "is defaults to true" do
|
129
134
|
presenter_class.nodoc!
|
135
|
+
expect(presenter_class.configuration[:nodoc]).to be true
|
130
136
|
end
|
137
|
+
end
|
131
138
|
|
139
|
+
describe 'the internal! method' do
|
132
140
|
it "is stored in the configuration" do
|
133
|
-
|
141
|
+
presenter_class.internal! "Description for why these are internal docs"
|
142
|
+
expect(presenter_class.configuration[:internal]).to eq "Description for why these are internal docs"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "is defaults to true" do
|
146
|
+
presenter_class.internal!
|
147
|
+
expect(presenter_class.configuration[:internal]).to be true
|
134
148
|
end
|
135
149
|
end
|
136
150
|
|
@@ -172,6 +186,24 @@ describe Brainstem::Concerns::PresenterDSL do
|
|
172
186
|
expect(orders[:created_at][:info]).to eq "sorts by creation time"
|
173
187
|
end
|
174
188
|
end
|
189
|
+
|
190
|
+
context "when setting the direction" do
|
191
|
+
it "sets the direction to true by default" do
|
192
|
+
presenter_class.sort_order :created_at, value, info: "sorts by creation time"
|
193
|
+
|
194
|
+
expect(orders[:created_at][:direction]).to be_truthy
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when direction is given" do
|
198
|
+
it "respects the given direction value" do
|
199
|
+
presenter_class.sort_order :created_at, value, info: "sorts by creation time", direction: false
|
200
|
+
presenter_class.sort_order :updated_at, value, info: "sorts by creation time", direction: true
|
201
|
+
|
202
|
+
expect(orders[:created_at][:direction]).to be_falsey
|
203
|
+
expect(orders[:updated_at][:direction]).to be_truthy
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
175
207
|
end
|
176
208
|
|
177
209
|
describe 'the conditional block' do
|
@@ -5,10 +5,13 @@ describe Brainstem::DSL::Association do
|
|
5
5
|
let(:name) { :user }
|
6
6
|
let(:target_class) { User }
|
7
7
|
let(:description) { "This object's user" }
|
8
|
-
let(:
|
8
|
+
let(:type) { :belongs_to }
|
9
|
+
let(:response_key) { :user_id }
|
10
|
+
let(:polymorphic_classes) { [User, Task] }
|
11
|
+
let(:options) { { info: description, response_key: response_key, type: type, polymorphic_classes: polymorphic_classes } }
|
9
12
|
let(:association) { Brainstem::DSL::Association.new(name, target_class, options) }
|
10
13
|
|
11
|
-
describe 'description' do
|
14
|
+
describe '#description' do
|
12
15
|
context 'when `info` is specified in the options' do
|
13
16
|
it 'returns the value specified with the info key' do
|
14
17
|
expect(association.description).to eq(description)
|
@@ -24,8 +27,56 @@ describe Brainstem::DSL::Association do
|
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
30
|
+
describe '#response_key' do
|
31
|
+
context 'when `response_key` is specified in the options' do
|
32
|
+
it 'returns the value specified with the response_key key' do
|
33
|
+
expect(association.response_key).to eq(response_key)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when `response_key` is not specified in the options' do
|
38
|
+
let(:options) { {} }
|
39
|
+
|
40
|
+
it 'returns nil' do
|
41
|
+
expect(association.response_key).to be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#type' do
|
47
|
+
context 'when `type` is specified in the options' do
|
48
|
+
it 'returns the value specified with the type key' do
|
49
|
+
expect(association.type).to eq(type)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when `type` is not specified in the options' do
|
54
|
+
let(:options) { {} }
|
55
|
+
|
56
|
+
it 'returns nil' do
|
57
|
+
expect(association.type).to be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#polymorphic_classes' do
|
63
|
+
context 'when `polymorphic_classes` is specified in the options' do
|
64
|
+
it 'returns the value specified with the polymorphic_classes key' do
|
65
|
+
expect(association.polymorphic_classes).to eq(polymorphic_classes)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when `polymorphic_classes` is not specified in the options' do
|
70
|
+
let(:options) { {} }
|
71
|
+
|
72
|
+
it 'returns nil' do
|
73
|
+
expect(association.polymorphic_classes).to be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
27
78
|
describe "#run_on" do
|
28
|
-
let(:context) { {
|
79
|
+
let(:context) { {} }
|
29
80
|
|
30
81
|
context 'with no special options' do
|
31
82
|
it 'calls the method by name on the model' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brainstem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mavenlink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -240,6 +240,9 @@ files:
|
|
240
240
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb
|
241
241
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter.rb
|
242
242
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb
|
243
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/endpoint_param_formatter.rb
|
244
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/presenter_field_formatter.rb
|
245
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/response_field_formatter.rb
|
243
246
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter.rb
|
244
247
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter.rb
|
245
248
|
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter.rb
|
@@ -308,6 +311,9 @@ files:
|
|
308
311
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb
|
309
312
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb
|
310
313
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb
|
314
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/endpoint_param_formatter_spec.rb
|
315
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/presenter_field_formatter_spec.rb
|
316
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/response_field_formatter_spec.rb
|
311
317
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb
|
312
318
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb
|
313
319
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb
|
@@ -400,6 +406,9 @@ test_files:
|
|
400
406
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb
|
401
407
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb
|
402
408
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb
|
409
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/endpoint_param_formatter_spec.rb
|
410
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/presenter_field_formatter_spec.rb
|
411
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/field_definitions/response_field_formatter_spec.rb
|
403
412
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb
|
404
413
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb
|
405
414
|
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb
|