update preferences controller
This commit is contained in:
parent
949808529c
commit
04bb82c8b8
|
@ -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.'
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue