Commit 04bb82c8 authored by James Lopez's avatar James Lopez

update preferences controller

parent 94980852
...@@ -6,7 +6,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController ...@@ -6,7 +6,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController
def update def update
begin 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.' flash[:notice] = 'Preferences saved.'
else else
flash[:alert] = 'Failed to save preferences.' flash[:alert] = 'Failed to save preferences.'
......
...@@ -43,7 +43,8 @@ describe Profiles::PreferencesController do ...@@ -43,7 +43,8 @@ describe Profiles::PreferencesController do
dashboard: 'stars' dashboard: 'stars'
}.with_indifferent_access }.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 go params: prefs
end end
...@@ -51,7 +52,7 @@ describe Profiles::PreferencesController do ...@@ -51,7 +52,7 @@ describe Profiles::PreferencesController do
context 'on failed update' do context 'on failed update' do
it 'sets the flash' do it 'sets the flash' do
expect(user).to receive(:update_attributes).and_return(false) expect(user).to receive(:save).and_return(false)
go go
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment