Fix for nonprofit being weird
This commit is contained in:
parent
8887a37e55
commit
5026af021d
3 changed files with 13 additions and 6 deletions
app/api/houdini/v1
javascripts/src/components/registration_page
spec/api/houdini
|
@ -30,7 +30,13 @@ class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI
|
||||||
|
|
||||||
requires :nonprofit, type: Hash do
|
requires :nonprofit, type: Hash do
|
||||||
requires :name, type:String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
|
requires :name, type:String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' }
|
||||||
optional :url, type:String, desc: 'Organization website URL', allow_blank:true, regexp: URI::regexp, documentation: { param_type: 'body' }
|
optional :website, type:String, desc: 'Organization website URL', allow_blank:true, regexp: URI::regexp, documentation: { param_type: 'body' }, coerce_with: ->(url) {
|
||||||
|
coerced_url = url
|
||||||
|
unless (url =~ /\Ahttp:\/\/.*/i || url =~ /\Ahttps:\/\/.*/i)
|
||||||
|
coerced_url = 'http://'+ coerced_url
|
||||||
|
end
|
||||||
|
coerced_url
|
||||||
|
}
|
||||||
requires :zip_code, type:String, allow_blank: false, desc: "Organization Address ZIP Code", documentation: { param_type: 'body' }
|
requires :zip_code, type:String, allow_blank: false, desc: "Organization Address ZIP Code", documentation: { param_type: 'body' }
|
||||||
requires :state_code, type:String, allow_blank: false, desc: "Organization Address State Code", documentation: { param_type: 'body' }
|
requires :state_code, type:String, allow_blank: false, desc: "Organization Address State Code", documentation: { param_type: 'body' }
|
||||||
requires :city, type:String, allow_blank: false, desc: "Organization Address City", documentation: { param_type: 'body' }
|
requires :city, type:String, allow_blank: false, desc: "Organization Address City", documentation: { param_type: 'body' }
|
||||||
|
|
|
@ -59,7 +59,7 @@ export class RegistrationPageForm extends HoudiniForm {
|
||||||
|
|
||||||
inputToForm = {
|
inputToForm = {
|
||||||
'nonprofit[name]': 'nonprofitTab.organization_name',
|
'nonprofit[name]': 'nonprofitTab.organization_name',
|
||||||
'nonprofit[url]': 'nonprofitTab.website',
|
'nonprofit[website]': 'nonprofitTab.website',
|
||||||
'nonprofit[email]': 'nonprofitTab.org_email',
|
'nonprofit[email]': 'nonprofitTab.org_email',
|
||||||
'nonprofit[phone]': 'nonprofitTab.org_phone',
|
'nonprofit[phone]': 'nonprofitTab.org_phone',
|
||||||
'nonprofit[city]': 'nonprofitTab.city',
|
'nonprofit[city]': 'nonprofitTab.city',
|
||||||
|
|
|
@ -70,14 +70,14 @@ describe Houdini::V1::Nonprofit, :type => :controller do
|
||||||
nonprofit: {
|
nonprofit: {
|
||||||
email: "noemeila",
|
email: "noemeila",
|
||||||
phone: "notphone",
|
phone: "notphone",
|
||||||
url: "noturl"
|
url: ""
|
||||||
}}
|
}}
|
||||||
xhr :post, '/api/v1/nonprofit', input
|
xhr :post, '/api/v1/nonprofit', input
|
||||||
expect(response.code).to eq "400"
|
expect(response.code).to eq "400"
|
||||||
expected = create_errors("user")
|
expected = create_errors("user")
|
||||||
expected[:errors].push(h(params:["nonprofit[email]"], messages: gr_e("regexp")))
|
expected[:errors].push(h(params:["nonprofit[email]"], messages: gr_e("regexp")))
|
||||||
#expected[:errors].push(h(params:["nonprofit[phone]"], messages: gr_e("regexp")))
|
#expected[:errors].push(h(params:["nonprofit[phone]"], messages: gr_e("regexp")))
|
||||||
expected[:errors].push(h(params:["nonprofit[url]"], messages: gr_e("regexp")))
|
#expected[:errors].push(h(params:["nonprofit[url]"], messages: gr_e("regexp")))
|
||||||
|
|
||||||
expect_validation_errors(JSON.parse(response.body), expected)
|
expect_validation_errors(JSON.parse(response.body), expected)
|
||||||
end
|
end
|
||||||
|
@ -130,7 +130,7 @@ describe Houdini::V1::Nonprofit, :type => :controller do
|
||||||
it "succeeds" do
|
it "succeeds" do
|
||||||
force_create(:nonprofit, slug: "n", state_code_slug: "wi", city_slug: "appleton")
|
force_create(:nonprofit, slug: "n", state_code_slug: "wi", city_slug: "appleton")
|
||||||
input = {
|
input = {
|
||||||
nonprofit: {name: "n", state_code: "WI", city: "appleton", zip_code: 54915},
|
nonprofit: {name: "n", state_code: "WI", city: "appleton", zip_code: 54915, url: 'www.cs.c'},
|
||||||
user: {name: "Name", email: "em@em.com", password: "12345678", password_confirmation: "12345678"}
|
user: {name: "Name", email: "em@em.com", password: "12345678", password_confirmation: "12345678"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,8 @@ describe Houdini::V1::Nonprofit, :type => :controller do
|
||||||
zip_code: "54915",
|
zip_code: "54915",
|
||||||
state_code_slug: "wi",
|
state_code_slug: "wi",
|
||||||
city_slug: "appleton",
|
city_slug: "appleton",
|
||||||
slug: "n-00"
|
slug: "n-00",
|
||||||
|
website: 'http://www.cs.c'
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
|
|
||||||
expected_np = our_np.attributes.with_indifferent_access.merge(expected_np)
|
expected_np = our_np.attributes.with_indifferent_access.merge(expected_np)
|
||||||
|
|
Loading…
Reference in a new issue