apipie-rails 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +4 -1
- data/CHANGELOG.md +19 -0
- data/Gemfile.rails32 +1 -0
- data/Gemfile.rails41 +1 -1
- data/Gemfile.rails42 +5 -0
- data/README.rst +21 -4
- data/apipie-rails.gemspec +3 -3
- data/app/controllers/apipie/apipies_controller.rb +22 -1
- data/app/public/apipie/javascripts/bundled/jquery.js +5 -0
- data/app/views/apipie/apipies/_disqus.html.erb +3 -3
- data/app/views/apipie/apipies/_errors.html.erb +23 -0
- data/app/views/apipie/apipies/_method_detail.erb +1 -9
- data/app/views/apipie/apipies/_params.html.erb +11 -5
- data/app/views/apipie/apipies/apipie_404.html.erb +4 -4
- data/app/views/apipie/apipies/static.html.erb +1 -6
- data/app/views/layouts/apipie/apipie.html.erb +4 -3
- data/config/locales/de.yml +28 -0
- data/config/locales/en.yml +30 -28
- data/config/locales/es.yml +27 -27
- data/config/locales/pl.yml +27 -28
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/ru.yml +27 -28
- data/config/locales/tr.yml +28 -0
- data/config/locales/zh-CN.yml +2 -2
- data/config/locales/zh-TW.yml +2 -2
- data/lib/apipie/configuration.rb +1 -1
- data/lib/apipie/dsl_definition.rb +1 -1
- data/lib/apipie/errors.rb +9 -1
- data/lib/apipie/extractor/collector.rb +2 -2
- data/lib/apipie/extractor/writer.rb +6 -0
- data/lib/apipie/helpers.rb +22 -1
- data/lib/apipie/param_description.rb +5 -2
- data/lib/apipie/validator.rb +7 -6
- data/lib/apipie/version.rb +1 -1
- data/lib/tasks/apipie.rake +3 -2
- data/spec/controllers/api/v1/architectures_controller_spec.rb +7 -8
- data/spec/controllers/api/v2/architectures_controller_spec.rb +1 -1
- data/spec/controllers/api/v2/nested/resources_controller_spec.rb +1 -1
- data/spec/controllers/apipies_controller_spec.rb +71 -27
- data/spec/controllers/concerns_controller_spec.rb +9 -9
- data/spec/controllers/users_controller_spec.rb +122 -123
- data/spec/dummy/app/controllers/users_controller.rb +2 -1
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/lib/application_spec.rb +3 -3
- data/spec/lib/extractor/writer_spec.rb +4 -4
- data/spec/lib/method_description_spec.rb +7 -7
- data/spec/lib/param_description_spec.rb +61 -46
- data/spec/lib/param_group_spec.rb +11 -11
- data/spec/lib/rake_spec.rb +10 -10
- data/spec/lib/resource_description_spec.rb +6 -6
- data/spec/lib/validator_spec.rb +7 -7
- data/spec/spec_helper.rb +11 -1
- metadata +36 -33
- data/app/public/apipie/javascripts/bundled/jquery-1.7.2.js +0 -9404
@@ -174,8 +174,9 @@ class UsersController < ApplicationController
|
|
174
174
|
error 401, "Unauthorized"
|
175
175
|
error :code => 404, :description => "Not Found"
|
176
176
|
param :id, Integer, :desc => "user id", :required => true
|
177
|
-
param :session, String, :desc => "user is logged in", :required => true
|
177
|
+
param :session, String, :desc => "user is logged in", :required => true, :missing_message => lambda { "session_parameter_is_required" }
|
178
178
|
param :regexp_param, /^[0-9]* years/, :desc => "regexp param"
|
179
|
+
param :regexp2, /\b[A-Z0-9._%+-=]+@[A-Z0-9.-]+.[A-Z]{2,}\b/i, :desc => "email regexp"
|
179
180
|
param :array_param, ["100", "one", "two", "1", "2"], :desc => "array validator"
|
180
181
|
param :boolean_param, [true, false], :desc => "array validator with boolean"
|
181
182
|
param :proc_param, lambda { |val|
|
@@ -5,3 +5,4 @@
|
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
7
|
Dummy::Application.config.secret_token = '431a859f504c40942b0caa3a740492b8bfd87c7898db4b1c39557f440f1cdda99c54810ad81f6ba7e1cece75bc079caa52a5cb54dbd085effd038ba283b837ce'
|
8
|
+
Dummy::Application.config.secret_key_base = '431a859f504c40942b0caa3a740492b8bfd87c7898db4b1c39557f440f1cdda99c54810ad81f6ba7e1cece75bc079caa52a5cb54dbd085effd038ba283b837ce'
|
@@ -21,13 +21,13 @@ describe Apipie::Application do
|
|
21
21
|
context "with a defined base url" do
|
22
22
|
|
23
23
|
it "should not overwrite the parent resource" do
|
24
|
-
|
24
|
+
is_expected.not_to eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with an undefined base url" do
|
30
|
-
before {Apipie.app.
|
30
|
+
before {allow(Apipie.app).to receive(:get_base_url) { nil }}
|
31
31
|
|
32
32
|
it "should not raise an error" do
|
33
33
|
expect { Apipie.get_resource_name(Api::V2::ArchitecturesController) }.
|
@@ -42,7 +42,7 @@ describe Apipie::Application do
|
|
42
42
|
before { Apipie.configuration.namespaced_resources = false }
|
43
43
|
|
44
44
|
it "should overwrite the the parent" do
|
45
|
-
|
45
|
+
is_expected.to eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -60,19 +60,19 @@ describe Apipie::Extractor::Writer do
|
|
60
60
|
describe "with doc_path overriden in configuration" do
|
61
61
|
it "should use the doc_path specified in configuration" do
|
62
62
|
Apipie.configuration.doc_path = "user_specified_doc_path"
|
63
|
-
writer_class.examples_file.
|
63
|
+
expect(writer_class.examples_file).to eql(File.join(Rails.root, "user_specified_doc_path", "apipie_examples.json"))
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "storing of examples" do
|
68
68
|
before do
|
69
|
-
writer_class.
|
70
|
-
collector.
|
69
|
+
allow(writer_class).to receive(:examples_file) { test_examples_file }
|
70
|
+
expect(collector).to receive(:records).and_return(records)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should read and write examples" do
|
74
74
|
writer.write_examples
|
75
|
-
writer.send(:load_recorded_examples).
|
75
|
+
expect(writer.send(:load_recorded_examples)).to eql(loaded_records)
|
76
76
|
end
|
77
77
|
|
78
78
|
after do
|
@@ -12,7 +12,7 @@ describe Apipie::MethodDescription do
|
|
12
12
|
|
13
13
|
it "should return nil when no metadata is provided" do
|
14
14
|
method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
15
|
-
method.to_json[:metadata].
|
15
|
+
expect(method.to_json[:metadata]).to eq(nil)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return the metadata" do
|
@@ -21,7 +21,7 @@ describe Apipie::MethodDescription do
|
|
21
21
|
:weight => '830g'
|
22
22
|
}
|
23
23
|
method = Apipie::MethodDescription.new(:a, @resource, dsl_data.update(:meta => meta))
|
24
|
-
method.to_json[:metadata].
|
24
|
+
expect(method.to_json[:metadata]).to eq(meta)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -34,7 +34,7 @@ describe Apipie::MethodDescription do
|
|
34
34
|
it "should return the deprecated flag when provided" do
|
35
35
|
dsl_data[:api_args] = [[:GET, "/foo/bar", "description", {:deprecated => true}]]
|
36
36
|
method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
37
|
-
method.method_apis_to_json.first[:deprecated].
|
37
|
+
expect(method.method_apis_to_json.first[:deprecated]).to eq(true)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -50,13 +50,13 @@ describe Apipie::MethodDescription do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should be ordered" do
|
53
|
-
@method.params.keys.
|
54
|
-
@method.to_json[:params].map{|h| h[:name]}.
|
53
|
+
expect(@method.params.keys).to eq([:a, :b, :c])
|
54
|
+
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should be still ordered" do
|
58
|
-
@method.params.keys.
|
59
|
-
@method.to_json[:params].map{|h| h[:name]}.
|
58
|
+
expect(@method.params.keys).to eq([:a, :b, :c])
|
59
|
+
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
@@ -16,7 +16,7 @@ describe Apipie::ParamDescription do
|
|
16
16
|
|
17
17
|
it "should return nil when no metadata is provided" do
|
18
18
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String)
|
19
|
-
param.to_json[:metadata].
|
19
|
+
expect(param.to_json[:metadata]).to eq(nil)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return the metadata" do
|
@@ -25,7 +25,7 @@ describe Apipie::ParamDescription do
|
|
25
25
|
:weight => '830g'
|
26
26
|
}
|
27
27
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String, :meta => meta)
|
28
|
-
param.to_json[:metadata].
|
28
|
+
expect(param.to_json[:metadata]).to eq(meta)
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
@@ -34,15 +34,15 @@ describe Apipie::ParamDescription do
|
|
34
34
|
|
35
35
|
it "should return true when show option is not provided" do
|
36
36
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String)
|
37
|
-
param.to_json[:show].
|
37
|
+
expect(param.to_json[:show]).to eq(true)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should return the show option" do
|
41
41
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String, :show => true)
|
42
|
-
param.to_json[:show].
|
42
|
+
expect(param.to_json[:show]).to eq(true)
|
43
43
|
|
44
44
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String, :show => false)
|
45
|
-
param.to_json[:show].
|
45
|
+
expect(param.to_json[:show]).to eq(false)
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -52,7 +52,7 @@ describe Apipie::ParamDescription do
|
|
52
52
|
|
53
53
|
it "should return name" do
|
54
54
|
param = Apipie::ParamDescription.new(method_desc, :some_param, String)
|
55
|
-
param.to_json[:full_name].
|
55
|
+
expect(param.to_json[:full_name]).to eq('some_param')
|
56
56
|
end
|
57
57
|
|
58
58
|
end
|
@@ -63,7 +63,7 @@ describe Apipie::ParamDescription do
|
|
63
63
|
parent_param = Apipie::ParamDescription.new(method_desc, :parent, String)
|
64
64
|
nested_param = Apipie::ParamDescription.new(method_desc, :nested, String, :parent => parent_param)
|
65
65
|
|
66
|
-
nested_param.to_json[:full_name].
|
66
|
+
expect(nested_param.to_json[:full_name]).to eq('parent[nested]')
|
67
67
|
end
|
68
68
|
|
69
69
|
context "with the parent parameter set to not show" do
|
@@ -72,28 +72,43 @@ describe Apipie::ParamDescription do
|
|
72
72
|
parent_param = Apipie::ParamDescription.new(method_desc, :parent, String, :show => false)
|
73
73
|
nested_param = Apipie::ParamDescription.new(method_desc, :nested, String, :parent => parent_param)
|
74
74
|
|
75
|
-
nested_param.to_json[:full_name].
|
75
|
+
expect(nested_param.to_json[:full_name]).to eq('nested')
|
76
76
|
end
|
77
77
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe "manual validation text" do
|
83
|
+
it "should allow manual text" do
|
84
|
+
param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil, :validations => "must be foo")
|
85
|
+
|
86
|
+
expect(param.validations).to include("\n<p>must be foo</p>\n")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should allow multiple items" do
|
90
|
+
param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil, :validations => ["> 0", "< 5"])
|
91
|
+
|
92
|
+
expect(param.validations).to include("\n<p>> 0</p>\n")
|
93
|
+
expect(param.validations).to include("\n<p>< 5</p>\n")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
82
97
|
describe "validator selection" do
|
83
98
|
|
84
99
|
it "should allow nil validator" do
|
85
100
|
param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil)
|
86
|
-
param.validator.
|
101
|
+
expect(param.validator).to be_nil
|
87
102
|
end
|
88
103
|
|
89
104
|
it "should throw exception on unknown validator" do
|
90
|
-
|
105
|
+
expect { Apipie::ParamDescription.new(method_desc, :param, :unknown) }.to raise_error(RuntimeError, /Validator.*not found/)
|
91
106
|
end
|
92
107
|
|
93
108
|
it "should pick type validator" do
|
94
|
-
Apipie::Validator::BaseValidator.
|
109
|
+
expect(Apipie::Validator::BaseValidator).to receive(:find).and_return(:validator_instance)
|
95
110
|
param = Apipie::ParamDescription.new(method_desc, :param, String)
|
96
|
-
param.validator.
|
111
|
+
expect(param.validator).to eq(:validator_instance)
|
97
112
|
end
|
98
113
|
|
99
114
|
end
|
@@ -112,27 +127,27 @@ describe Apipie::ParamDescription do
|
|
112
127
|
|
113
128
|
it "should replace string parameter name with colon prefix" do
|
114
129
|
param = Apipie::ParamDescription.new(concern_method_desc, ":string_subst", String)
|
115
|
-
param.name.
|
130
|
+
expect(param.name).to eq("string")
|
116
131
|
end
|
117
132
|
|
118
133
|
it "should replace symbol parameter name" do
|
119
134
|
param = Apipie::ParamDescription.new(concern_method_desc, :concern, String)
|
120
|
-
param.name.
|
135
|
+
expect(param.name).to eq(:user)
|
121
136
|
end
|
122
137
|
|
123
138
|
it "should keep original value for strings without colon prefixes" do
|
124
139
|
param = Apipie::ParamDescription.new(concern_method_desc, "string_subst", String)
|
125
|
-
param.name.
|
140
|
+
expect(param.name).to eq("string_subst")
|
126
141
|
end
|
127
142
|
|
128
143
|
it "should keep the original value when a string can't be replaced" do
|
129
144
|
param = Apipie::ParamDescription.new(concern_method_desc, ":param", String)
|
130
|
-
param.name.
|
145
|
+
expect(param.name).to eq(":param")
|
131
146
|
end
|
132
147
|
|
133
148
|
it "should keep the original value when a symbol can't be replaced" do
|
134
149
|
param = Apipie::ParamDescription.new(concern_method_desc, :param, String)
|
135
|
-
param.name.
|
150
|
+
expect(param.name).to eq(:param)
|
136
151
|
end
|
137
152
|
end
|
138
153
|
|
@@ -144,12 +159,12 @@ describe Apipie::ParamDescription do
|
|
144
159
|
|
145
160
|
it "should set param as required by default" do
|
146
161
|
param = Apipie::ParamDescription.new(method_desc, :required_by_default, String)
|
147
|
-
param.required.
|
162
|
+
expect(param.required).to be true
|
148
163
|
end
|
149
164
|
|
150
165
|
it "should be possible to set param as optional" do
|
151
166
|
param = Apipie::ParamDescription.new(method_desc, :optional, String, :required => false)
|
152
|
-
param.required.
|
167
|
+
expect(param.required).to be false
|
153
168
|
end
|
154
169
|
|
155
170
|
end
|
@@ -160,12 +175,12 @@ describe Apipie::ParamDescription do
|
|
160
175
|
|
161
176
|
it "should set param as optional by default" do
|
162
177
|
param = Apipie::ParamDescription.new(method_desc, :optional_by_default, String)
|
163
|
-
param.required.
|
178
|
+
expect(param.required).to be false
|
164
179
|
end
|
165
180
|
|
166
181
|
it "should be possible to set param as required" do
|
167
182
|
param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => true)
|
168
|
-
param.required.
|
183
|
+
expect(param.required).to be true
|
169
184
|
end
|
170
185
|
|
171
186
|
end
|
@@ -180,21 +195,21 @@ describe Apipie::ParamDescription do
|
|
180
195
|
context "when the param is required for current action" do
|
181
196
|
it "should set param as required" do
|
182
197
|
param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => :create)
|
183
|
-
param.required.
|
198
|
+
expect(param.required).to be true
|
184
199
|
end
|
185
200
|
end
|
186
201
|
|
187
202
|
context "when the param is required for multiple actions" do
|
188
203
|
it "should set param as required if it match current action" do
|
189
204
|
param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => [:update, :create])
|
190
|
-
param.required.
|
205
|
+
expect(param.required).to be true
|
191
206
|
end
|
192
207
|
end
|
193
208
|
|
194
209
|
context "when the param is not required for current action" do
|
195
210
|
it "should set param as not required" do
|
196
211
|
param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => :update)
|
197
|
-
param.required.
|
212
|
+
expect(param.required).to be false
|
198
213
|
end
|
199
214
|
end
|
200
215
|
end
|
@@ -218,13 +233,13 @@ describe Apipie::ParamDescription do
|
|
218
233
|
end
|
219
234
|
|
220
235
|
it "makes the param required" do
|
221
|
-
required.
|
222
|
-
required.
|
236
|
+
expect(required).to include :name
|
237
|
+
expect(required).to include :pass
|
223
238
|
end
|
224
239
|
|
225
240
|
it "doesn't allow nil" do
|
226
|
-
allowed_nil.
|
227
|
-
allowed_nil.
|
241
|
+
expect(allowed_nil).not_to include :name
|
242
|
+
expect(allowed_nil).not_to include :pass
|
228
243
|
end
|
229
244
|
end
|
230
245
|
|
@@ -235,17 +250,17 @@ describe Apipie::ParamDescription do
|
|
235
250
|
end
|
236
251
|
|
237
252
|
it "doesn't make the param required" do
|
238
|
-
required.
|
239
|
-
required.
|
253
|
+
expect(required).not_to include :name
|
254
|
+
expect(required).not_to include :pass
|
240
255
|
end
|
241
256
|
|
242
257
|
it "doesn't allow nil" do
|
243
|
-
allowed_nil.
|
244
|
-
allowed_nil.
|
258
|
+
expect(allowed_nil).not_to include :name
|
259
|
+
expect(allowed_nil).not_to include :pass
|
245
260
|
end
|
246
261
|
|
247
262
|
it "doesn't touch params with explicitly set allow_nil" do
|
248
|
-
allowed_nil.
|
263
|
+
expect(allowed_nil).not_to include :membership
|
249
264
|
end
|
250
265
|
end
|
251
266
|
|
@@ -255,13 +270,13 @@ describe Apipie::ParamDescription do
|
|
255
270
|
end
|
256
271
|
|
257
272
|
it "makes the param required" do
|
258
|
-
required.
|
259
|
-
required.
|
273
|
+
expect(required).to include :name
|
274
|
+
expect(required).to include :pass
|
260
275
|
end
|
261
276
|
|
262
277
|
it "doesn't allow nil" do
|
263
|
-
allowed_nil.
|
264
|
-
allowed_nil.
|
278
|
+
expect(allowed_nil).not_to include :name
|
279
|
+
expect(allowed_nil).not_to include :pass
|
265
280
|
end
|
266
281
|
end
|
267
282
|
end
|
@@ -279,10 +294,10 @@ describe Apipie::ParamDescription do
|
|
279
294
|
|
280
295
|
it "should include the nested params in the json" do
|
281
296
|
sub_params = subject.to_json[:params]
|
282
|
-
sub_params.size.
|
297
|
+
expect(sub_params.size).to eq(1)
|
283
298
|
sub_param = sub_params.first
|
284
|
-
sub_param[:name].
|
285
|
-
sub_param[:full_name].
|
299
|
+
expect(sub_param[:name]).to eq("answer")
|
300
|
+
expect(sub_param[:full_name]).to eq("param[answer]")
|
286
301
|
end
|
287
302
|
|
288
303
|
end
|
@@ -297,10 +312,10 @@ describe Apipie::ParamDescription do
|
|
297
312
|
|
298
313
|
it "should include the nested params in the json" do
|
299
314
|
sub_params = subject.to_json[:params]
|
300
|
-
sub_params.size.
|
315
|
+
expect(sub_params.size).to eq(1)
|
301
316
|
sub_param = sub_params.first
|
302
|
-
sub_param[:name].
|
303
|
-
sub_param[:full_name].
|
317
|
+
expect(sub_param[:name]).to eq("answer")
|
318
|
+
expect(sub_param[:full_name]).to eq("param[answer]")
|
304
319
|
end
|
305
320
|
|
306
321
|
end
|
@@ -312,7 +327,7 @@ describe Apipie::ParamDescription do
|
|
312
327
|
end
|
313
328
|
|
314
329
|
it "should include the nested params in the json" do
|
315
|
-
subject.to_json[:params].
|
330
|
+
expect(subject.to_json[:params]).to be_nil
|
316
331
|
end
|
317
332
|
|
318
333
|
end
|
@@ -322,8 +337,8 @@ describe Apipie::ParamDescription do
|
|
322
337
|
describe "Array with classes" do
|
323
338
|
it "should be valid for objects included in class array" do
|
324
339
|
param = Apipie::ParamDescription.new(method_desc, :param, [Fixnum, String])
|
325
|
-
expect { param.validate("1") }.
|
326
|
-
expect { param.validate(Fixnum) }.
|
340
|
+
expect { param.validate("1") }.not_to raise_error
|
341
|
+
expect { param.validate(Fixnum) }.to raise_error(Apipie::ParamInvalid)
|
327
342
|
end
|
328
343
|
end
|
329
344
|
|
@@ -10,25 +10,25 @@ describe "param groups" do
|
|
10
10
|
user_update_params = user_update_desc.validator.params_ordered.map(&:name)
|
11
11
|
|
12
12
|
common = user_update_params & user_create_params
|
13
|
-
common.sort_by(&:to_s).
|
13
|
+
expect(common.sort_by(&:to_s)).to eq(user_update_params.sort_by(&:to_s))
|
14
14
|
end
|
15
15
|
|
16
16
|
it "allows using groups is nested param descriptions" do
|
17
17
|
user_create_desc = Apipie["users#update"].params[:user]
|
18
18
|
user_create_params = user_create_desc.validator.params_ordered.map(&:name)
|
19
|
-
user_create_params.map(&:to_s).sort.
|
19
|
+
expect(user_create_params.map(&:to_s).sort).to eq(%w[membership name pass])
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should allow adding additional params to group" do
|
23
23
|
user_create_desc = Apipie["users#create"].params[:user]
|
24
24
|
user_create_params = user_create_desc.validator.params_ordered.map(&:name)
|
25
|
-
user_create_params.map(&:to_s).sort.
|
25
|
+
expect(user_create_params.map(&:to_s).sort).to eq(%w[membership name pass permalink])
|
26
26
|
end
|
27
27
|
|
28
28
|
context "hash param" do
|
29
29
|
it "influences only its childs" do
|
30
|
-
Apipie["users#create"].params[:user].required.
|
31
|
-
Apipie["users#update"].params[:user].required.
|
30
|
+
expect(Apipie["users#create"].params[:user].required).to be true
|
31
|
+
expect(Apipie["users#update"].params[:user].required).to be true
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -39,21 +39,21 @@ describe "param groups" do
|
|
39
39
|
arch_v2_desc = Apipie["2.0#architectures#create"].params[:architecture]
|
40
40
|
arch_v2_params = arch_v2_desc.validator.params_ordered.map(&:name)
|
41
41
|
|
42
|
-
arch_v1_params.sort_by(&:to_s).
|
42
|
+
expect(arch_v1_params.sort_by(&:to_s)).to eq(arch_v2_params.sort_by(&:to_s))
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should replace parameter name in a group when it comes from concern" do
|
46
|
-
Apipie["overridden_concern_resources#update"].params.has_key?(:user).
|
46
|
+
expect(Apipie["overridden_concern_resources#update"].params.has_key?(:user)).to eq(true)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "shouldn't replace parameter name in a group redefined in the controller" do
|
50
|
-
Apipie["overridden_concern_resources#create"].params.has_key?(:concern).
|
51
|
-
Apipie["overridden_concern_resources#create"].params.has_key?(:user).
|
50
|
+
expect(Apipie["overridden_concern_resources#create"].params.has_key?(:concern)).to eq(true)
|
51
|
+
expect(Apipie["overridden_concern_resources#create"].params.has_key?(:user)).to eq(false)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "shouldn't replace name of a parameter defined in the controller" do
|
55
|
-
Apipie["overridden_concern_resources#custom"].params.has_key?(:concern).
|
56
|
-
Apipie["overridden_concern_resources#custom"].params.has_key?(:user).
|
55
|
+
expect(Apipie["overridden_concern_resources#custom"].params.has_key?(:concern)).to eq(true)
|
56
|
+
expect(Apipie["overridden_concern_resources#custom"].params.has_key?(:user)).to eq(false)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|