Skip to content

Commit

Permalink
mailer test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtoddmathes committed Feb 17, 2024
1 parent d2b3703 commit 8d0f4e1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
12 changes: 5 additions & 7 deletions rails_root/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# # frozen_string_literal: true

# class ApplicationMailer < ActionMailer::Base
# default from: '[email protected]'
# layout 'mailer'
# end
# # rubocop:enable Style/Documentation
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
end
24 changes: 24 additions & 0 deletions rails_root/spec/mailers/application_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# require 'rails_helper'

# RSpec.describe ApplicationMailer, type: :mailer do
# describe 'welcome_email' do
# let(:user) { create(:user) }
# let(:mail) { ApplicationMailer.welcome_email(user) }

# it 'renders the subject' do
# expect(mail.subject).to eq('Welcome to My App')
# end

# it 'renders the receiver email' do
# expect(mail.to).to eq([user.email])
# end

# it 'renders the sender email' do
# expect(mail.from).to eq(['[email protected]'])
# end

# it 'renders the body' do
# expect(mail.body.encoded).to match('Welcome to My App')
# end
# end
# end
15 changes: 15 additions & 0 deletions rails_root/spec/requests/survey_profiles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@
expect(response).to have_http_status(:unprocessable_entity)
end
end

context 'with non-unique user_id' do
it 'does not create a new SurveyProfile' do
SurveyProfile.create! valid_attributes
expect do
post survey_profiles_url, params: { survey_profile: valid_attributes }
end.to change(SurveyProfile, :count).by(0)
end

it "renders a response with 422 status (i.e. to display the 'new' template)" do
SurveyProfile.create! valid_attributes
post survey_profiles_url, params: { survey_profile: valid_attributes }
expect(response).to have_http_status(:unprocessable_entity)
end
end
end

describe 'PATCH /update' do
Expand Down

0 comments on commit 8d0f4e1

Please sign in to comment.