summaryrefslogtreecommitdiff
path: root/spec/controllers/profiles_controller_spec.rb
diff options
context:
space:
mode:
authorShah El-Rahman <selrahman@gitlab.com>2018-04-06 09:36:22 +0000
committerFilipa Lacerda <filipa@gitlab.com>2018-04-06 09:36:22 +0000
commit43ef375e084884ed4260ac9c9de8f601d5594c90 (patch)
treeb5214f9deb9f389e5428f5c011b9c7cbfc55d506 /spec/controllers/profiles_controller_spec.rb
parentca330f7ea30b368b928f5468a1f53264d74aa8aa (diff)
downloadgitlab-ce-43ef375e084884ed4260ac9c9de8f601d5594c90.tar.gz
Add confirmation modal to "Change username"
Diffstat (limited to 'spec/controllers/profiles_controller_spec.rb')
-rw-r--r--spec/controllers/profiles_controller_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 891485406c6..de6ef919221 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -84,6 +84,28 @@ describe ProfilesController, :request_store do
expect(user.username).to eq(new_username)
end
+ it 'updates a username using JSON request' do
+ sign_in(user)
+
+ put :update_username,
+ user: { username: new_username },
+ format: :json
+
+ expect(response.status).to eq(200)
+ expect(json_response['message']).to eq('Username successfully changed')
+ end
+
+ it 'renders an error message when the username was not updated' do
+ sign_in(user)
+
+ put :update_username,
+ user: { username: 'invalid username.git' },
+ format: :json
+
+ expect(response.status).to eq(422)
+ expect(json_response['message']).to match(/Username change failed/)
+ end
+
it 'raises a correct error when the username is missing' do
sign_in(user)