Skip to content

Commit

Permalink
fix update email
Browse files Browse the repository at this point in the history
  • Loading branch information
ka8725 committed Jun 28, 2024
1 parent d54af67 commit 1c7acbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 0 additions & 4 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def edit_profile

private

def update_resource(resource, params)
resource.update(params)
end

def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
Expand Down
15 changes: 14 additions & 1 deletion spec/controllers/users/registrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@
it { subject; expect(created_account).to have_attributes(name: email, email: email) }
it { subject; expect(created_user.account).to eq(created_account) }
end
end

describe '#update' do
before { sign_in user }

let(:password) { FFaker::Internet.password }
let(:user) { create(:user, password: password) }
let(:new_email) { FFaker::Internet.email }

subject { put :update, params: { id: user.id, user: { email: new_email, current_password: password } } }

it { expect(subject).to have_http_status(:redirect) }
it { expect { subject }.to change { user.reload.email }.to(new_email) }
end
end

0 comments on commit 1c7acbb

Please sign in to comment.