Skip to content
Snippets Groups Projects
Commit 0e2c96e7 authored by Richard Macklin's avatar Richard Macklin
Browse files

Use `let` in Profiles::NotificationsController spec

parent 4647d138
No related branches found
No related tags found
No related merge requests found
require 'spec_helper'
 
describe Profiles::NotificationsController do
let(:user) do
create(:user) do |user|
user.emails.create(email: 'original@example.com')
user.emails.create(email: 'new@example.com')
user.update(notification_email: 'original@example.com')
user.save!
end
end
describe 'GET show' do
it 'renders' do
user = create_user
sign_in(user)
 
get :show
Loading
Loading
@@ -14,7 +22,6 @@ describe Profiles::NotificationsController do
 
describe 'POST update' do
it 'updates only permitted attributes' do
user = create_user
sign_in(user)
 
put :update, user: { notification_email: 'new@example.com', notified_of_own_activity: true, admin: true }
Loading
Loading
@@ -27,7 +34,6 @@ describe Profiles::NotificationsController do
end
 
it 'shows an error message if the params are invalid' do
user = create_user
sign_in(user)
 
put :update, user: { notification_email: '' }
Loading
Loading
@@ -36,13 +42,4 @@ describe Profiles::NotificationsController do
expect(controller).to set_flash[:alert].to('Failed to save new settings')
end
end
def create_user
create(:user) do |user|
user.emails.create(email: 'original@example.com')
user.emails.create(email: 'new@example.com')
user.update(notification_email: 'original@example.com')
user.save!
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment