Skip to content

Commit

Permalink
Added some comments and test for user profile redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
LindseyB committed Mar 29, 2011
1 parent 08fb22a commit 5fde150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Rstatus

user = User.first :username => params[:slug]
if user.nil?
#check for a case insensitive match and then redirect to the correct address
slug = Regexp.escape(params[:slug])
user = User.first("$where" => "this.username.match(/#{slug}/i)")
if user.nil?
Expand Down
7 changes: 7 additions & 0 deletions test/rstatus_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def test_user_profile
assert_equal 200, page.status_code
end

def test_user_profile_redirect
u = Factory(:user)
url = "http://www.example.com/users/#{u.username}"
visit "/users/#{u.username.upcase}"
assert_equal url, page.current_url
end

def test_user_follows_themselves_upon_create
u = Factory(:user)
a = Factory(:authorization, :user => u)
Expand Down

0 comments on commit 5fde150

Please sign in to comment.