update preferences controller

This commit is contained in:
James Lopez 2017-06-15 15:24:37 +02:00
parent 949808529c
commit 04bb82c8b8
2 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController
def update
begin
if @user.update_attributes(preferences_params)
result = Users::UpdateService.new(current_user, user, preferences_params).execute
if result[:status] == :success
flash[:notice] = 'Preferences saved.'
else
flash[:alert] = 'Failed to save preferences.'

View File

@ -43,7 +43,8 @@ describe Profiles::PreferencesController do
dashboard: 'stars'
}.with_indifferent_access
expect(user).to receive(:update_attributes).with(prefs)
expect(user).to receive(:assign_attributes).with(prefs)
expect(user).to receive(:save)
go params: prefs
end
@ -51,7 +52,7 @@ describe Profiles::PreferencesController do
context 'on failed update' do
it 'sets the flash' do
expect(user).to receive(:update_attributes).and_return(false)
expect(user).to receive(:save).and_return(false)
go