-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<li> | ||
<%= gravatar_for user, :size => 30 %> | ||
<%= link_to user.name, user %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<h1>All users</h1> | ||
|
||
<%= will_paginate %> | ||
|
||
<ul class="users"> | ||
<% @users.each do |user| %> | ||
<li> | ||
<%= gravatar_for user, :size => 30 %> | ||
<%= link_to user.name, user %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<%= render @users %> | ||
</ul> | ||
|
||
<%= will_paginate %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'faker' | ||
|
||
namespace :db do | ||
desc "Fill database with sample data" | ||
task :populate => :environment do | ||
Rake::Task['db:reset'].invoke | ||
User.create!(:name => "Example User", | ||
:email => "[email protected]", | ||
:password => "foobar", | ||
:password_confirmation => "foobar") | ||
99.times do |n| | ||
name = Faker::Name.name | ||
email = "example-#{n+1}@railstutorial.org" | ||
password = "password" | ||
User.create!(:name => name, | ||
:email => email, | ||
:password => password, | ||
:password_confirmation => password) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,10 @@ | |
@user = test_sign_in(Factory(:user)) | ||
Factory(:user, :email => "[email protected]") | ||
Factory(:user, :email => "[email protected]") | ||
|
||
30.times do | ||
Factory(:user, :email => Factory.next(:email)) | ||
end | ||
end | ||
|
||
it "should be successful" do | ||
|
@@ -32,10 +36,20 @@ | |
|
||
it "should have an element for each user" do | ||
get :index | ||
User.all.each do |user| | ||
User.paginate(:page => 1).each do |user| | ||
response.should have_selector('li', :content => user.name) | ||
end | ||
end | ||
|
||
it "should paginate users" do | ||
get :index | ||
response.should have_selector('div.pagination') | ||
response.should have_selector('span.disabled', :content => "Previous") | ||
response.should have_selector('a', :href => "/users?page=2", | ||
:content => "2") | ||
response.should have_selector('a', :href => "/users?page=2", | ||
:content => "Next") | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ | |
user.email "[email protected]" | ||
user.password "foobar" | ||
user.password_confirmation "foobar" | ||
end | ||
|
||
Factory.sequence :email do |n| | ||
"person-#{n}@example.com" | ||
end |