Skip to content

Commit

Permalink
Change 'opportunity_email' to just 'email'
Browse files Browse the repository at this point in the history
  • Loading branch information
rorJeremy committed Aug 15, 2019
1 parent 0f3e47d commit 9ca1be9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -3,7 +3,7 @@
class WCC::Contentful::App::ContactFormController < ApplicationController
def create
address = form_model.to_address(
opportunity_email: params[:opportunity_email],
email: params[:email],
email_object_id: params[:email_object_id]
)

Expand Down
Expand Up @@ -11,8 +11,8 @@ def page
::WCC::Contentful::Model::Page.find_by(sections: { id: id })
end

def to_address(opportunity_email: nil, email_object_id: nil)
return opportunity_email if opportunity_email.present?
def to_address(email: nil, email_object_id: nil)
return email if email.present?
return email_address(email_model(email_object_id)) if email_object_id.present?

notification_email
Expand Down
Expand Up @@ -19,24 +19,24 @@
expect(section_contact_form.to_address).to eq(section_contact_form.notification_email)
end

it 'returns opportunity_email if provided without email_object_id' do
it 'returns email if provided without email_object_id' do
expect(
section_contact_form.to_address(opportunity_email: 'test@email.com', email_object_id: nil)
section_contact_form.to_address(email: 'test@email.com', email_object_id: nil)
).to eq('test@email.com')
end

it 'returns opportunity_email if provided with email_object_id' do
it 'returns email if provided with email_object_id' do
expect(
section_contact_form.to_address(opportunity_email: 'test@email.com', email_object_id: person.id)
section_contact_form.to_address(email: 'test@email.com', email_object_id: person.id)
).to eq('test@email.com')
end

it 'returns person email if email_object_id given without an opportunity_email' do
it 'returns person email if email_object_id given without an email' do
allow(WCC::Contentful::Model).to receive(:find).with(person.id)
.and_return(person)

expect(
section_contact_form.to_address(opportunity_email: nil, email_object_id: person.id)
section_contact_form.to_address(email: nil, email_object_id: person.id)
).to eq(person.email)
end
end
Expand Down

0 comments on commit 9ca1be9

Please sign in to comment.