Commit 6005ec89 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #3392 from hiroponz/fix-non-ascii-char-username

Fix RoutingError when changing username to non ascii char.
parents 4449ac3a 33e236c6
......@@ -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
......
......@@ -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
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment