forked from Apipie/apipie-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers_controller_spec.rb
793 lines (678 loc) · 28.7 KB
/
users_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
require 'spec_helper'
def compare_hashes(h1, h2)
if h1.is_a? String
expect(h1).to eq(h2)
else
h1.each do |key, val|
case val
when Hash
compare_hashes val, h2[key]
when Array
val.each_with_index do |v, i|
compare_hashes val[i], h2[key][i]
end
else
expect(val).to eq(h2[key])
end
end
end
end
describe UsersController do
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
describe "resource description" do
subject do
Apipie.get_resource_description(UsersController, Apipie.configuration.default_version)
end
it "should contain all resource methods" do
methods = subject._methods
expect(methods.keys).to include(:show)
expect(methods.keys).to include(:create_route)
expect(methods.keys).to include(:index)
expect(methods.keys).to include(:create)
expect(methods.keys).to include(:update)
expect(methods.keys).to include(:two_urls)
expect(methods.keys).to include(:action_with_headers)
expect(methods.keys).to include(:multiple_required_params)
end
it "should contain info about resource" do
expect(subject._short_description).to eq('Site members')
expect(subject._id).to eq('users')
expect(subject._path).to eq('/users')
expect(subject._version).to eq('development')
expect(subject._name).to eq('Users')
expect(subject._formats).to eq(['json'])
end
it "should contain params defined on resource level" do
expect(subject._params_args.count).to eq(2)
name, type, options = subject._params_args.first
expect(name).to eq(:id)
expect(type).to eq(Integer)
expect(options).to eq({:required=>false, :desc=>"User ID"})
end
end
describe "validators" do
context "validations are disabled" do
before do
Apipie.configuration.validate = false
Apipie.configuration.validate_value = true
Apipie.configuration.validate_presence = true
end
it "should reply to valid request" do
get :show, :params => { :id => '5', :session => "secret_hash" }
assert_response :success
end
it "should pass if required parameter is missing" do
expect { get :show, :params => { :id => 5 } }.not_to raise_error
end
end
context "validations are enabled" do
def reload_controllers
controllers_dirname = File.expand_path('../dummy/app/controllers', File.dirname(__FILE__))
Dir.glob("#{controllers_dirname}/**/*") { |file| load(file) if File.file?(file) }
end
shared_examples "validates correctly" do
context "only presence validations are enabled" do
before do
Apipie.configuration.validate_value = false
Apipie.configuration.validate_presence = true
Apipie.configuration.validate_key = false
end
it "should reply to valid request" do
expect { get :show, :params => { :id => 5, :session => "secret_hash" }}.not_to raise_error
assert_response :success
end
it "should fail if required parameter is missing" do
expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
end
it "should fail if multiple required parameters are missing" do
expect { get :multiple_required_params }.to raise_error(Apipie::ParamMultipleMissing, /required_param1.*\n.*required_param2|required_param2.*\n.*required_parameter1/)
end
it "should pass if required parameter has wrong type" do
expect { get :show, :params => { :id => 5 , :session => "secret_hash" }}.not_to raise_error
expect { get :show, :params => { :id => "ten" , :session => "secret_hash" }}.not_to raise_error
end
end
context "key validations are enabled" do
before do
Apipie.configuration.validate_value = false
Apipie.configuration.validate_presence = true
Apipie.configuration.validate_key = true
end
it "should reply to valid request" do
expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error
assert_response :success
end
it "should fail if extra parameter is passed in" do
expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.to raise_error(Apipie::UnknownParam, /\bbadparam\b/)
end
end
context "key validations are enabled and skip on non-validated keys" do
before do
Apipie.configuration.validate_value = false
Apipie.configuration.validate_presence = true
Apipie.configuration.validate_key = true
Apipie.configuration.action_on_non_validated_keys = :skip
end
it "should reply to valid request" do
expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error
assert_response :success
end
it "should delete the param and not fail if an extra parameter is passed." do
expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.not_to raise_error
expect(controller.params.as_json).to eq({"session"=>"secret_hash", "id"=>"5", "controller"=>"users", "action"=>"show"})
end
after do
Apipie.configuration.action_on_non_validated_keys = :raise
end
end
context "presence and value validations are enabled" do
before do
Apipie.configuration.validate_value = true
Apipie.configuration.validate_presence = true
Apipie.configuration.validate_key = false
end
it "should reply to valid request" do
get :show, :params => { :id => '5', :session => "secret_hash" }
assert_response :success
end
it "should work with nil value for a required hash param" do
expect {
get :show, :params => { :id => '5', :session => "secret_hash", :hash_param => {:dummy_hash => nil} }
}.to raise_error(Apipie::ParamInvalid, /dummy_hash/)
assert_response :success
end
it "should fail if required parameter is missing" do
expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/)
end
it "should work with custom Type validator" do
expect {
get :show,
:params => { :id => "not a number", :session => "secret_hash" }
}.to raise_error(Apipie::ParamError, /id/) # old-style error rather than ParamInvalid
end
it "should work with Regexp validator" do
get :show, :params => { :id => 5, :session => "secret_hash", :regexp_param => "24 years" }
assert_response :success
expect {
get :show, :params => { :id => 5,
:session => "secret_hash",
:regexp_param => "ten years" }
}.to raise_error(Apipie::ParamInvalid, /regexp_param/)
end
it "should work with Array validator" do
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "one" }
assert_response :success
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "two" }
assert_response :success
get :show, :params => { :id => 5, :session => "secret_hash", :array_param => '1' }
assert_response :success
expect {
get :show, :params => { :id => 5,
:session => "secret_hash",
:array_param => "blabla" }
}.to raise_error(Apipie::ParamInvalid, /array_param/)
expect {
get :show, :params => {
:id => 5,
:session => "secret_hash",
:array_param => 3 }
}.to raise_error(Apipie::ParamInvalid, /array_param/)
end
it "should work with Proc validator" do
expect {
get :show,
:params => {
:id => 5,
:session => "secret_hash",
:proc_param => "asdgsag" }
}.to raise_error(Apipie::ParamInvalid, /proc_param/)
get :show,
:params => {
:id => 5,
:session => "secret_hash",
:proc_param => "param value"}
assert_response :success
end
it "should work with Hash validator" do
post :create, params: { :user => { :name => "root", :pass => "12345", :membership => "standard" } }
assert_response :success
a = Apipie[UsersController, :create]
param = a.params_ordered.select {|p| p.name == :user }
expect(param.count).to eq(1)
expect(param.first.validator.class).to eq(Apipie::Validator::HashValidator)
hash_params = param.first.validator.params_ordered
expect(hash_params.count).to eq(4)
hash_params[0].name == :name
hash_params[1].name == :pass
hash_params[2].name == :membership
expect {
post :create, :params => { :user => { :name => "root", :pass => "12345", :membership => "____" } }
}.to raise_error(Apipie::ParamInvalid, /membership/)
# Should include both pass and name
expect {
post :create, :params => { :user => { :membership => "standard" } }
}.to raise_error(Apipie::ParamMultipleMissing, /pass.*\n.*name|name.*\n.*pass/)
expect {
post :create, :params => { :user => { :name => "root" } }
}.to raise_error(Apipie::ParamMissing, /pass/)
expect {
post :create, :params => { :user => "a string is not a hash" }
}.to raise_error(Apipie::ParamInvalid, /user/)
post :create, :params => { :user => { :name => "root", :pass => "pwd" } }
assert_response :success
end
it "should support Hash validator without specifying keys" do
params = Apipie[UsersController, :create].to_json[:params]
expect(params).to include(:name => "facts",
:full_name => "facts",
:validator => "Must be a Hash",
:description => "\n<p>Additional optional facts about the user</p>\n",
:required => false,
:allow_nil => true,
:allow_blank => false,
:metadata => nil,
:show => true,
:deprecated => false,
:expected_type => "hash",
:validations => [])
end
it "should allow nil when allow_nil is set to true" do
post :create,
:params => {
:user => {
:name => "root",
:pass => "12345",
:membership => "standard",
},
:facts => { :test => 'test' }
}
assert_response :success
end
it "should allow blank when allow_blank is set to true" do
post :create,
:params => {
:user => {
:name => "root",
:pass => "12345",
:membership => "standard"
},
:age => ""
}
assert_response :success
end
describe "nested elements" do
context "with valid input" do
it "should succeed" do
put :update,
:params => {
:id => 5,
:user => {
:name => "root",
:pass => "12345"
},
:comments => [
{
:comment => 'comment1'
},
{
:comment => 'comment2'
}
]
}
assert_response :success
end
end
context "with bad input" do
it "should raise an error" do
expect{
put :update,
:params => {
:id => 5,
:user => {
:name => "root",
:pass => "12345"
},
:comments => [
{
:comment => {:bad_input => 4}
},
{
:comment => {:bad_input => 5}
}
]
}
}.to raise_error(Apipie::ParamInvalid)
end
end
it "should work with empty array" do
put :update,
:params => {
:id => 5,
:user => {
:name => "root",
:pass => "12345"
},
:comments => [
]
}
assert_response :success
end
end
end
end
context "using configuration.validate = true" do
before :all do
Apipie.configuration.validate = true
reload_controllers
end
it_behaves_like "validates correctly"
end
context "using configuration.validate = :implicitly" do
before :all do
Apipie.configuration.validate = :implicitly
reload_controllers
end
it_behaves_like "validates correctly"
end
context "using configuration.validate = :explicitly" do
before :all do
Apipie.configuration.validate = :explicitly
reload_controllers
end
it_behaves_like "validates correctly"
end
end
end
describe "method description" do
it "should contain basic info about method" do
a = Apipie[UsersController, :create]
expect(a.apis.count).to eq(1)
expect(a.formats).to eq(['json'])
api = a.apis.first
expect(api.short_description).to eq("Create user")
expect(api.path).to eq("/users")
expect(api.http_method).to eq("POST")
b = Apipie.get_method_description(UsersController, :show)
expect(b).to eq(Apipie[UsersController, :show])
expect(b.method).to eq('show')
expect(b.resource._id).to eq('users')
expect(b.apis.count).to eq(1)
expect(b.formats).to eq(%w[json jsonp])
api = b.apis.first
expect(api.short_description).to eq("Show user profile")
expect(api.path).to eq("/users/:id")
expect(api.http_method).to eq("GET")
expect(b.full_description.length).to be > 400
end
context "Usign routes.rb" do
it "should contain basic info about method" do
a = Apipie[UsersController, :create_route]
expect(a.apis.count).to eq(1)
expect(a.formats).to eq(['json'])
api = a.apis.first
expect(api.short_description).to eq("Create user")
expect(api.path).to eq("/api/users/create_route")
expect(api.from_routes).to be_truthy
expect(api.http_method).to eq("POST")
end
end
context "contain :see option" do
context "the key is valid" do
it "should contain reference to another method" do
api = Apipie[UsersController, :see_another]
expect(api.show).to be false
see = api.see.first
expect(see.see_url).to eql Apipie[UsersController, :create].doc_url
expect(see.link).to eql 'development#users#create'
expect(see.description).to eql 'development#users#create'
see_with_desc = api.see.last
expect(see_with_desc.see_url).to eql Apipie[UsersController, :index].doc_url
expect(see_with_desc.link).to eql 'development#users#index'
expect(see_with_desc.description).to eql 'very interesting method reference'
expect(Apipie['development#users#see_another']).to eql Apipie[UsersController, :see_another]
end
end
context "the key is not valid" do
it "should raise exception" do
api = Apipie[UsersController, :see_another]
api.instance_variable_set :@see, [Apipie::SeeDescription.new(['doesnot#exist'])]
expect {
api.see.first.see_url
}.to raise_error(ArgumentError, /does not exist/)
api.instance_variable_set :@see, []
end
end
end
it "should contain possible errors description" do
a = Apipie.get_method_description(UsersController, :show)
expect(a.errors[0].code).to eq(500)
expect(a.errors[0].description).to include("crashed")
expect(a.errors[1].code).to eq(401)
expect(a.errors[1].description).to eq("Unauthorized")
expect(a.errors[2].code).to eq(404)
expect(a.errors[2].description).to eq("Not Found")
end
it 'should recognize Rack symbols as error codes' do
a = Apipie.get_method_description(UsersController, :create)
error = a.errors.find { |e| e.code == 422 }
expect(error).to be
expect(error.description).to include("Unprocessable Entity")
end
it "should contain all params description" do
a = Apipie.get_method_description(UsersController, :show)
expect(a.params.count).to eq(12)
expect(a.instance_variable_get('@params_ordered').count).to eq(10)
end
context 'headers' do
context 'for methods' do
let(:expected_required_header) do
{
name: :RequredHeaderName,
description: 'Required header description',
options: {
required: true
}
}
end
let(:expected_optional_header) do
{
name: :OptionalHeaderName,
description: 'Optional header description',
options: {
required: false,
type: "string"
}
}
end
let(:expected_header_with_default) do
{
name: :HeaderNameWithDefaultValue,
description: 'Header with default value',
options: {
required: true,
default: 'default value'
}
}
end
it 'contains all headers description in method doc' do
headers = Apipie.get_method_description(UsersController, :action_with_headers).headers
expect(headers).to be_an(Array)
compare_hashes headers[0], expected_required_header
compare_hashes headers[1], expected_optional_header
compare_hashes headers[2], expected_header_with_default
end
end
context 'for resource' do
let(:expected_resource_header) do
{
name: :CommonHeader,
description: 'Common header description',
options: {
required: true
}
}
end
it 'contains all headers description in resource doc' do
headers = Apipie.get_resource_description(UsersController)._headers
expect(headers).to be_an(Array)
compare_hashes headers[0], expected_resource_header
end
end
end
it "should contain all api method description" do
method_description = Apipie[UsersController, :two_urls]
expect(method_description.class).to be(Apipie::MethodDescription)
expect(method_description.apis.count).to eq(2)
a1, a2 = method_description.apis
expect(a1.short_description).to eq('Get company users')
expect(a1.path).to eq('/company_users')
expect(a1.http_method).to eq('GET')
expect(a2.short_description).to eq('Get users working in given company')
expect(a2.path).to eq('/company/:id/users')
expect(a2.http_method).to eq('GET')
end
it "should be described by valid json" do
json = Apipie[UsersController, :two_urls].to_json
expected_hash = {
:errors => [{:code=>404, :description=>"Missing", :metadata => {:some => "metadata"}},
{:code=>500, :description=>"Server crashed for some <%= reason %>"}],
:examples => [],
:doc_url => "#{Apipie.configuration.doc_base_url}/development/users/two_urls",
:formats=>["json"],
:full_description => '',
:params => [{:full_name=>"oauth",
:required=>false,
:allow_nil => false,
:allow_blank => false,
:validator=>"Must be a String",
:description=>"\n<p>Authorization</p>\n",
:name=>"oauth",
:show=>true,
:deprecated=>false,
:expected_type=>"string"},
{:validator=>"Must be a Hash",
:description=>"\n<p>Deprecated parameter not documented</p>\n",
:expected_type=>"hash",
:allow_nil=>false,
:allow_blank => false,
:name=>"legacy_param",
:required=>false,
:full_name=>"legacy_param",
:show=>false,
:deprecated=>false,
:params=>
[{:validator=>"Must be a Hash",
:description=>"\n<p>Param description for all methods</p>\n",
:expected_type=>"hash",
:allow_nil=>false,
:allow_blank => false,
:name=>"resource_param",
:required=>false,
:full_name=>"resource_param",
:deprecated=>false,
:show=>true,
:params=>
[{:required=>true,
:allow_nil => false,
:allow_blank => false,
:validator=>"Must be a String",
:description=>"\n<p>Username for login</p>\n",
:name=>"ausername", :full_name=>"resource_param[ausername]",
:show=>true,
:deprecated=>false,
:expected_type=>"string"},
{:required=>true,
:allow_nil => false,
:allow_blank => false,
:validator=>"Must be a String",
:description=>"\n<p>Password for login</p>\n",
:name=>"apassword", :full_name=>"resource_param[apassword]",
:show=>true,
:deprecated=>false,
:expected_type=>"string"}
]}
]
},
{:required=>false, :validator=>"Parameter has to be Integer.",
:allow_nil => false,
:allow_blank => false,
:description=>"\n<p>Company ID</p>\n",
:name=>"id", :full_name=>"id",
:show=>true,
:deprecated=>false,
:expected_type=>"numeric"},
],
:name => 'two_urls',
:show => true,
:apis => [
{
:http_method => 'GET',
:short_description => 'Get company users',
:api_url => "#{Apipie.api_base_url}/company_users"
},{
:http_method => 'GET',
:short_description => 'Get users working in given company',
:api_url =>"#{Apipie.api_base_url}/company/:id/users"
}
]
}
compare_hashes json, expected_hash
end
end
describe "examples" do
it "should be able to load examples from yml file" do
expect(Apipie.get_method_description(UsersController, :show).examples).to eq [<<EOS1, <<EOS2].map(&:chomp)
GET /users/14?verbose=true
200
{
"name": "Test User"
}
EOS1
GET /users/15
404
EOS2
end
describe "document" do
it "should be able to load document from markup file" do
expect(Apipie.get_method_description(UsersController, :desc_from_file).full_description).to include("description from document")
end
end
end
describe "param description" do
it "should contain all specified information" do
a = Apipie.get_method_description(UsersController, :show)
param = a.params[:session]
expect(param.required).to eq(true)
expect(param.desc).to eq("\n<p>user is logged in</p>\n")
expect(param.validator.class).to be(Apipie::Validator::TypeValidator)
expect(param.validator.instance_variable_get("@type")).to eq(String)
param = a.params[:id]
expect(param.required).to eq(true)
expect(param.desc).to eq("\n<p>user id</p>\n")
expect(param.validator.class).to be(Apipie::Validator::IntegerValidator)
expect(param.validator.instance_variable_get("@type")).to eq(Integer)
param = a.params[:regexp_param]
expect(param.desc).to eq("\n<p>regexp param</p>\n")
expect(param.required).to eq(false)
expect(param.validator.class).to be(Apipie::Validator::RegexpValidator)
expect(param.validator.instance_variable_get("@regexp")).to eq(/^[0-9]* years/)
param = a.params[:array_param]
expect(param.desc).to eq("\n<p>array validator</p>\n")
expect(param.validator.class).to be(Apipie::Validator::EnumValidator)
expect(param.validator.instance_variable_get("@array")).to eq(%w[100 one two 1 2])
param = a.params[:proc_param]
expect(param.desc).to eq("\n<p>proc validator</p>\n")
expect(param.validator.class).to be(Apipie::Validator::ProcValidator)
param = a.params[:briefer_dsl]
expect(param.desc).to eq("\n<p>You dont need :desc => from now</p>\n")
expect(param.validator.class).to be(Apipie::Validator::TypeValidator)
end
end
describe "ignored option" do
class IgnoredController < ApplicationController; end
after do
Apipie.configuration.ignored = %w[]
end
describe "ignored action" do
before do
Apipie.configuration.ignored = %w[UsersController#ignore]
end
it "skips the listed actions from the documentation" do
Apipie.define_method_description(UsersController, :ignore, dsl_data)
expect(Apipie.get_method_description(UsersController, :ignore)).to be_nil
Apipie.define_method_description(UsersController, :dont_ignore, dsl_data)
expect(Apipie.get_method_description(UsersController, :dont_ignore)).not_to be_nil
end
end
describe "ignored controller" do
before do
Apipie.configuration.ignored = %w[IgnoredController]
end
it "skips the listed controller from the documentation" do
Apipie.define_method_description(IgnoredController, :ignore, dsl_data)
expect(Apipie.get_method_description(IgnoredController, :ignore)).to be_nil
Apipie.define_method_description(IgnoredController, :ignore, dsl_data)
expect(Apipie.get_method_description(IgnoredController, :ignore)).to be_nil
end
end
end
describe "Parameter processing / extraction" do
before do
Apipie.configuration.validate = true
Apipie.configuration.process_params = true
controllers_dirname = File.expand_path('../dummy/app/controllers', File.dirname(__FILE__))
Dir.glob("#{controllers_dirname}/**/*") { |file| load(file) if File.file?(file) }
end
it "process correctly the parameters" do
post :create, :params => {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard' }, :facts => {:test => 'test'}}
expect(assigns(:api_params).with_indifferent_access).to eq({:user => {:name=>"dummy", :pass=>"dummy", :membership=>"standard"}, :facts => {:test => 'test'}}.with_indifferent_access)
end
it "ignore not described parameters" do
post :create, :params => {:user => {:name => 'dummy', :pass => 'dummy', :membership => 'standard', :id => 0}}
expect(assigns(:api_params).with_indifferent_access).to eq({:user => {:name=>"dummy", :pass=>"dummy", :membership=>"standard"}}.with_indifferent_access)
end
after do
Apipie.configuration.process_params = false
end
end
end