Skip to content

Commit a028b22

Browse files
committed
Users => Hackers.
I think it's way more fun to call Users 'Hackers', so there you go.
1 parent 937d0a5 commit a028b22

13 files changed

Lines changed: 33 additions & 33 deletions

File tree

controllers/hacker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
get '/hackers/:name' do
2-
@hacker = User.first(:username => params[:name])
2+
@hacker = Hacker.first(:username => params[:name])
33
haml :"hackers/show"
44
end

controllers/sessions.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
get '/signup' do
2-
haml :"users/signup"
2+
haml :"sessions/signup"
33
end
44

55
post '/signup' do
6-
@user = User.create(params[:user])
7-
if @user && @user.valid?
6+
@hacker = Hacker.create(params[:user])
7+
if @hacker && @hacker.valid?
88
session[:user] = @user.id
99
flash[:notice] = "Account created."
1010
redirect '/'
@@ -15,12 +15,12 @@
1515
end
1616

1717
get '/login' do
18-
haml :"users/login"
18+
haml :"sessions/login"
1919
end
2020

2121
post '/login' do
22-
if user = User.authenticate(params[:username], params[:password])
23-
session[:user_id] = user.id
22+
if hacker = Hacker.authenticate(params[:username], params[:password])
23+
session[:hacker_id] = hacker.id
2424
flash[:notice] = "Login successful."
2525

2626
if session[:return_to]
@@ -37,7 +37,7 @@
3737
end
3838

3939
get '/logout' do
40-
session[:user_id] = nil
40+
session[:hacker_id] = nil
4141
flash[:notice] = "Logout successful."
4242
redirect '/'
4343
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"user#{n}@example.com"
33
end
44

5-
Factory.define :user do |u|
5+
Factory.define :hacker do |u|
66
u.username "steve"
77
u.email { Factory.next(:email) }
88
u.password "foobar"
99
u.password_confirmation {|user| user.password }
1010
u.admin false
1111
end
1212

13-
Factory.define :admin, :parent => :user do |u|
13+
Factory.define :admin, :parent => :hacker do |u|
1414
u.admin true
1515
end

features/step_definitions/common_steps.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
def login user
1+
def login hacker
22
visit "/login"
3-
fill_in "username", :with => user.username
4-
fill_in "password", :with => user.password
3+
fill_in "username", :with => hacker.username
4+
fill_in "password", :with => hacker.password
55
click_button "login"
66
end
77

88
Given /^I'm logged in as admin$/ do
99
password = "foobar"
10-
user = Factory(:admin,:password => password, :password_confirmation => password)
11-
login user
10+
hacker = Factory(:admin,:password => password, :password_confirmation => password)
11+
login hacker
1212
end
1313

1414
Given /^I'm not logged in$/ do
@@ -17,18 +17,18 @@ def login user
1717

1818
Given /^I'm logged in$/ do
1919
password = "foobar"
20-
user = Factory(:user,:password => password, :password_confirmation => password)
21-
login user
20+
hacker = Factory(:hacker,:password => password, :password_confirmation => password)
21+
login hacker
2222
end
2323

2424
Given /^I'm logged in as "([^"]*)"$/ do |email|
2525
password = "foobar"
26-
user = Factory(:user,:email => email, :password => password, :password_confirmation => password)
27-
login user
26+
hacker = Factory(:hacker,:email => email, :password => password, :password_confirmation => password)
27+
login hacker
2828
end
2929

30-
Given /^there's a user with the username "([^"]*)"$/ do |username|
31-
Factory(:user, :username => username)
30+
Given /^there's a hacker with the username "([^"]*)"$/ do |username|
31+
Factory(:hacker, :username => username)
3232
end
3333

3434
And /^open page$/ do

features/support/paths.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def path_to(page_name)
3232
when /a blog post page/
3333
post = Post.first
3434
"/posts/#{post.id}"
35-
when /the new user page/
35+
when /the new hacker page/
3636
"/signup"
3737
when /the main page/
3838
"/"

features/user.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Feature: User management
22
Scenario: Users can register
33
Given I'm not logged in
4-
And I go to the new user page
4+
And I go to the new hacker page
55
And I fill in "Email" with "steve@example.com"
66
And I fill in "Username" with "steve"
77
And I fill in "Password" with "foobar"
@@ -10,17 +10,17 @@ Feature: User management
1010
Then I should see "Account created."
1111
And I should be on the main page
1212
Scenario: No duplicate usernames
13-
Given there's a user with the username "steve"
13+
Given there's a hacker with the username "steve"
1414
And I'm not logged in
15-
And I go to the new user page
15+
And I go to the new hacker page
1616
And I fill in "Email" with "steve@example.com"
1717
And I fill in "Username" with "steve"
1818
And I fill in "Password" with "foobar"
1919
And I fill in "Confirm Password" with "foobar"
2020
When I press "Create account"
2121
Then I should see "There were some problems"
22-
And I should be on the new user page
22+
And I should be on the new hacker page
2323
Scenario: User pages
24-
Given there's a user with the username "steve"
24+
Given there's a hacker with the username "steve"
2525
When I go to the hacker page for "steve"
2626
Then I should see "steve's page"

helpers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
helpers do
22

33
def current_user
4-
return User.first(:id => session[:user_id]) if session[:user_id]
4+
return Hacker.first(:id => session[:hacker_id]) if session[:hacker_id]
55
nil
66
end
77

88
def logged_in?
9-
return session[:user_id] != nil
9+
return session[:hacker_id] != nil
1010
end
1111

1212
end

models/user.rb renamed to models/hacker.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#most of the stuff in this is based off of sinatra-authentication
2-
class User
2+
class Hacker
33
include MongoMapper::Document
44
key :username, String, :unique => true
55
key :email, String, :unique => true
@@ -12,13 +12,13 @@ class User
1212
def password=(pass)
1313
@password = pass
1414
self.salt = random_string(10) if !self.salt
15-
self.hashed_password = User.encrypt(@password, self.salt)
15+
self.hashed_password = Hacker.encrypt(@password, self.salt)
1616
end
1717

1818
def self.authenticate(username, pass)
19-
current_user = User.first(:username => username)
19+
current_user = Hacker.first(:username => username)
2020
return nil if current_user.nil?
21-
return current_user if User.encrypt(pass, current_user.salt) == current_user.hashed_password
21+
return current_user if Hacker.encrypt(pass, current_user.salt) == current_user.hashed_password
2222
nil
2323
end
2424

0 commit comments

Comments
 (0)