test(nonprofit): fix xhr deprecation warnings
`xhr` and `xml_http_request` are deprecated, changed to new syntax
This commit is contained in:
parent
d4f6e2d91d
commit
e08d7836c6
1 changed files with 10 additions and 9 deletions
|
@ -52,15 +52,16 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
e.run
|
||||
Rails.configuration.action_controller.allow_forgery_protection = false
|
||||
}
|
||||
it 'rejects csrf' do
|
||||
|
||||
xhr :post, '/api/v1/nonprofit'
|
||||
it 'rejects csrf' do
|
||||
post '/api/v1/nonprofit', params: {}, xhr: true
|
||||
expect(response.code).to eq "401"
|
||||
end
|
||||
end
|
||||
|
||||
it 'validates nothing' do
|
||||
input = {}
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "400"
|
||||
expect_validation_errors(JSON.parse(response.body), create_errors("nonprofit", "user"))
|
||||
end
|
||||
|
@ -72,7 +73,7 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
phone: "notphone",
|
||||
url: ""
|
||||
}}
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "400"
|
||||
expected = create_errors("user")
|
||||
expected[:errors].push(h(params:["nonprofit[email]"], messages: gr_e("regexp")))
|
||||
|
@ -92,7 +93,7 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
password_confirmation: 'doesn\'t match'
|
||||
}
|
||||
}
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "400"
|
||||
expect(JSON.parse(response.body)['errors']).to include(h(params:["user[password]", "user[password_confirmation]"], messages: gr_e("is_equal_to")))
|
||||
|
||||
|
@ -107,7 +108,7 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
|
||||
expect_any_instance_of(SlugNonprofitNamingAlgorithm).to receive(:create_copy_name).and_raise(UnableToCreateNameCopyError.new)
|
||||
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "400"
|
||||
|
||||
expect_validation_errors(JSON.parse(response.body), {
|
||||
|
@ -128,7 +129,7 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
user: {name: "Name", email: "em@em.com", password: "12345678", password_confirmation: "12345678"}
|
||||
}
|
||||
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "400"
|
||||
|
||||
expect_validation_errors(JSON.parse(response.body), {
|
||||
|
@ -155,7 +156,7 @@ describe Houdini::V1::Nonprofit, :type => :request do
|
|||
|
||||
#expect(Houdini::V1::Nonprofit).to receive(:sign_in)
|
||||
|
||||
xhr :post, '/api/v1/nonprofit', input
|
||||
post '/api/v1/nonprofit', params: input, xhr: true
|
||||
expect(response.code).to eq "201"
|
||||
|
||||
our_np = Nonprofit.all[1]
|
||||
|
|
Loading…
Reference in a new issue