From 65fa3ff018e37d2424f3fa30a11b801b2f189441 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 22 Dec 2021 00:48:05 +0100 Subject: [PATCH] Add test for updating user profile --- spec/controllers/user_controller_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index d3789066..8635d9d3 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -43,6 +43,28 @@ describe UserController, type: :controller do end end + describe "#update_profile" do + subject { patch :update_profile, params: { profile: profile_params } } + let(:profile_params) do + { + display_name: 'sneaky cune' + } + end + + context "user signed in" do + before(:each) { sign_in user } + + it "updates the user's profile" do + expect { subject }.to change{ user.profile.reload.display_name }.to('sneaky cune') + end + + it "redirects to the edit_user_profile page" do + subject + expect(response).to redirect_to(:edit_user_profile) + end + end + end + describe "#update" do subject { patch :update, params: { user: header_params } } let(:header_params) do