Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/update_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call

def manage_phone_configuration
if attributes[:phone_id].present?
update_phone_configuration
update_phone_configuration unless phone_configuration.nil?
else
create_phone_configuration
end
Expand Down
10 changes: 10 additions & 0 deletions spec/services/update_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@
to be_within(1.second).of original_made_default_at
end
end

context 'when phone does not belong to user' do
it 'does not update the user if the phone does not belong to them' do
other_phone = create(:phone_configuration)
attributes[:phone_id] = other_phone.id
expect do
UpdateUser.new(user: user, attributes: attributes).call
end.to_not(change { other_phone.updated_at })
end
end
end
end
end