Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-03-26 09:42:08 +0400
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-03-26 09:47:11 +0400
commit33e236c63124e5c59dba5979d641ba174f4a1479 (patch)
treee530c4117d83e8dd56df90726bcfc035d2029e25
parent90db28d6d0a031cad8dc58bc5936e381ce82a764 (diff)
Fix RoutingError when changing username to non ascii char.
-rw-r--r--app/controllers/admin/users_controller.rb2
-rw-r--r--features/admin/users.feature8
-rw-r--r--features/steps/admin/admin_users.rb23
3 files changed, 33 insertions, 0 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 43e6f09904f..20cb13e7746 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -84,6 +84,8 @@ class Admin::UsersController < Admin::ApplicationController
format.html { redirect_to [:admin, admin_user], notice: 'User was successfully updated.' }
format.json { head :ok }
else
+ # restore username to keep form action url.
+ admin_user.username = params[:id]
format.html { render action: "edit" }
format.json { render json: admin_user.errors, status: :unprocessable_entity }
end
diff --git a/features/admin/users.feature b/features/admin/users.feature
index 03ac86a367b..4c951df9fe2 100644
--- a/features/admin/users.feature
+++ b/features/admin/users.feature
@@ -6,3 +6,11 @@ Feature: Admin Users
Scenario: On Admin Users
Given I visit admin users page
Then I should see all users
+
+ Scenario: Edit user and change username to non ascii char
+ When I visit admin users page
+ And Click edit
+ And Input non ascii char in username
+ And Click save
+ Then See username error message
+ And Not chenged form action url
diff --git a/features/steps/admin/admin_users.rb b/features/steps/admin/admin_users.rb
index 1828ae705ce..61b3ed91beb 100644
--- a/features/steps/admin/admin_users.rb
+++ b/features/steps/admin/admin_users.rb
@@ -8,4 +8,27 @@ class AdminUsers < Spinach::FeatureSteps
page.should have_content user.name
end
end
+
+ And 'Click edit' do
+ @user = User.first
+ find("#edit_user_#{@user.id}").click
+ end
+
+ And 'Input non ascii char in username' do
+ fill_in 'user_username', with: "\u3042\u3044"
+ end
+
+ And 'Click save' do
+ click_button("Save")
+ end
+
+ Then 'See username error message' do
+ within "#error_explanation" do
+ page.should have_content "Username"
+ end
+ end
+
+ And 'Not chenged form action url' do
+ page.should have_selector %(form[action="/admin/users/#{@user.username}"])
+ end
end