summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Macklin <richard.github@nrm.com>2017-02-03 20:49:45 -0800
committerRichard Macklin <richard.github@nrm.com>2017-02-03 20:49:45 -0800
commit0e2c96e709161b35daeae2dad3aefcf9c85a75aa (patch)
treebfe42f3a7e0c5d4aa5b11701619b33fdce2a3255
parent4647d13893d84dea5d0863c48a933dcc8a1ba679 (diff)
downloadgitlab-ce-0e2c96e709161b35daeae2dad3aefcf9c85a75aa.tar.gz
Use `let` in Profiles::NotificationsController spec
-rw-r--r--spec/controllers/profiles/notifications_controller_spec.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/spec/controllers/profiles/notifications_controller_spec.rb b/spec/controllers/profiles/notifications_controller_spec.rb
index c056ba852f0..58caf7999cf 100644
--- a/spec/controllers/profiles/notifications_controller_spec.rb
+++ b/spec/controllers/profiles/notifications_controller_spec.rb
@@ -1,9 +1,17 @@
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
@@ -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 }
@@ -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: '' }
@@ -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